Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
seq_file: constify seq_operations
Browse files Browse the repository at this point in the history
Make all seq_operations structs const, to help mitigate against
revectoring user-triggerable function pointers.

This is derived from the grsecurity patch, although generated from scratch
because it's simpler than extracting the changes from there.

Signed-off-by: James Morris <[email protected]>
Acked-by: Serge Hallyn <[email protected]>
Acked-by: Casey Schaufler <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
James Morris authored and torvalds committed Sep 23, 2009
1 parent b7ed698 commit 88e9d34
Show file tree
Hide file tree
Showing 26 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion arch/mn10300/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ static void c_stop(struct seq_file *m, void *v)
{
}

struct seq_operations cpuinfo_op = {
const struct seq_operations cpuinfo_op = {
.start = c_start,
.next = c_next,
.stop = c_stop,
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/setup-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ static void c_stop(struct seq_file *m, void *v)
{
}

struct seq_operations cpuinfo_op = {
const struct seq_operations cpuinfo_op = {
.start =c_start,
.next = c_next,
.stop = c_stop,
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/pseries/hvCall_inst.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static int hc_show(struct seq_file *m, void *p)
return 0;
}

static struct seq_operations hcall_inst_seq_ops = {
static const struct seq_operations hcall_inst_seq_ops = {
.start = hc_start,
.next = hc_next,
.stop = hc_stop,
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/cciss.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ static void cciss_seq_stop(struct seq_file *seq, void *v)
h->busy_configuring = 0;
}

static struct seq_operations cciss_seq_ops = {
static const struct seq_operations cciss_seq_ops = {
.start = cciss_seq_start,
.show = cciss_seq_show,
.next = cciss_seq_next,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static int misc_seq_show(struct seq_file *seq, void *v)
}


static struct seq_operations misc_seq_ops = {
static const struct seq_operations misc_seq_ops = {
.start = misc_seq_start,
.next = misc_seq_next,
.stop = misc_seq_stop,
Expand Down
4 changes: 2 additions & 2 deletions drivers/char/tpm/tpm_bios.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,14 @@ static int tpm_ascii_bios_measurements_show(struct seq_file *m, void *v)
return 0;
}

static struct seq_operations tpm_ascii_b_measurments_seqops = {
static const struct seq_operations tpm_ascii_b_measurments_seqops = {
.start = tpm_bios_measurements_start,
.next = tpm_bios_measurements_next,
.stop = tpm_bios_measurements_stop,
.show = tpm_ascii_bios_measurements_show,
};

static struct seq_operations tpm_binary_b_measurments_seqops = {
static const struct seq_operations tpm_binary_b_measurments_seqops = {
.start = tpm_bios_measurements_start,
.next = tpm_bios_measurements_next,
.stop = tpm_bios_measurements_stop,
Expand Down
10 changes: 5 additions & 5 deletions drivers/isdn/capi/kcapi_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ static int contrstats_show(struct seq_file *seq, void *v)
return 0;
}

static struct seq_operations seq_controller_ops = {
static const struct seq_operations seq_controller_ops = {
.start = controller_start,
.next = controller_next,
.stop = controller_stop,
.show = controller_show,
};

static struct seq_operations seq_contrstats_ops = {
static const struct seq_operations seq_contrstats_ops = {
.start = controller_start,
.next = controller_next,
.stop = controller_stop,
Expand Down Expand Up @@ -194,14 +194,14 @@ applstats_show(struct seq_file *seq, void *v)
return 0;
}

static struct seq_operations seq_applications_ops = {
static const struct seq_operations seq_applications_ops = {
.start = applications_start,
.next = applications_next,
.stop = applications_stop,
.show = applications_show,
};

static struct seq_operations seq_applstats_ops = {
static const struct seq_operations seq_applstats_ops = {
.start = applications_start,
.next = applications_next,
.stop = applications_stop,
Expand Down Expand Up @@ -264,7 +264,7 @@ static int capi_driver_show(struct seq_file *seq, void *v)
return 0;
}

static struct seq_operations seq_capi_driver_ops = {
static const struct seq_operations seq_capi_driver_ops = {
.start = capi_driver_start,
.next = capi_driver_next,
.stop = capi_driver_stop,
Expand Down
6 changes: 3 additions & 3 deletions drivers/scsi/sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -2233,7 +2233,7 @@ static struct file_operations dev_fops = {
.open = sg_proc_open_dev,
.release = seq_release,
};
static struct seq_operations dev_seq_ops = {
static const struct seq_operations dev_seq_ops = {
.start = dev_seq_start,
.next = dev_seq_next,
.stop = dev_seq_stop,
Expand All @@ -2246,7 +2246,7 @@ static struct file_operations devstrs_fops = {
.open = sg_proc_open_devstrs,
.release = seq_release,
};
static struct seq_operations devstrs_seq_ops = {
static const struct seq_operations devstrs_seq_ops = {
.start = dev_seq_start,
.next = dev_seq_next,
.stop = dev_seq_stop,
Expand All @@ -2259,7 +2259,7 @@ static struct file_operations debug_fops = {
.open = sg_proc_open_debug,
.release = seq_release,
};
static struct seq_operations debug_seq_ops = {
static const struct seq_operations debug_seq_ops = {
.start = dev_seq_start,
.next = dev_seq_next,
.stop = dev_seq_stop,
Expand Down
8 changes: 4 additions & 4 deletions fs/afs/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static int afs_proc_cells_show(struct seq_file *m, void *v);
static ssize_t afs_proc_cells_write(struct file *file, const char __user *buf,
size_t size, loff_t *_pos);

static struct seq_operations afs_proc_cells_ops = {
static const struct seq_operations afs_proc_cells_ops = {
.start = afs_proc_cells_start,
.next = afs_proc_cells_next,
.stop = afs_proc_cells_stop,
Expand Down Expand Up @@ -70,7 +70,7 @@ static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v,
static void afs_proc_cell_volumes_stop(struct seq_file *p, void *v);
static int afs_proc_cell_volumes_show(struct seq_file *m, void *v);

static struct seq_operations afs_proc_cell_volumes_ops = {
static const struct seq_operations afs_proc_cell_volumes_ops = {
.start = afs_proc_cell_volumes_start,
.next = afs_proc_cell_volumes_next,
.stop = afs_proc_cell_volumes_stop,
Expand All @@ -95,7 +95,7 @@ static void *afs_proc_cell_vlservers_next(struct seq_file *p, void *v,
static void afs_proc_cell_vlservers_stop(struct seq_file *p, void *v);
static int afs_proc_cell_vlservers_show(struct seq_file *m, void *v);

static struct seq_operations afs_proc_cell_vlservers_ops = {
static const struct seq_operations afs_proc_cell_vlservers_ops = {
.start = afs_proc_cell_vlservers_start,
.next = afs_proc_cell_vlservers_next,
.stop = afs_proc_cell_vlservers_stop,
Expand All @@ -119,7 +119,7 @@ static void *afs_proc_cell_servers_next(struct seq_file *p, void *v,
static void afs_proc_cell_servers_stop(struct seq_file *p, void *v);
static int afs_proc_cell_servers_show(struct seq_file *m, void *v);

static struct seq_operations afs_proc_cell_servers_ops = {
static const struct seq_operations afs_proc_cell_servers_ops = {
.start = afs_proc_cell_servers_start,
.next = afs_proc_cell_servers_next,
.stop = afs_proc_cell_servers_stop,
Expand Down
12 changes: 6 additions & 6 deletions fs/dlm/debug_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,9 @@ static int table_seq_show(struct seq_file *seq, void *iter_ptr)
return rv;
}

static struct seq_operations format1_seq_ops;
static struct seq_operations format2_seq_ops;
static struct seq_operations format3_seq_ops;
static const struct seq_operations format1_seq_ops;
static const struct seq_operations format2_seq_ops;
static const struct seq_operations format3_seq_ops;

static void *table_seq_start(struct seq_file *seq, loff_t *pos)
{
Expand Down Expand Up @@ -534,21 +534,21 @@ static void table_seq_stop(struct seq_file *seq, void *iter_ptr)
}
}

static struct seq_operations format1_seq_ops = {
static const struct seq_operations format1_seq_ops = {
.start = table_seq_start,
.next = table_seq_next,
.stop = table_seq_stop,
.show = table_seq_show,
};

static struct seq_operations format2_seq_ops = {
static const struct seq_operations format2_seq_ops = {
.start = table_seq_start,
.next = table_seq_next,
.stop = table_seq_stop,
.show = table_seq_show,
};

static struct seq_operations format3_seq_ops = {
static const struct seq_operations format3_seq_ops = {
.start = table_seq_start,
.next = table_seq_next,
.stop = table_seq_stop,
Expand Down
4 changes: 2 additions & 2 deletions fs/jbd2/journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ static void jbd2_seq_history_stop(struct seq_file *seq, void *v)
{
}

static struct seq_operations jbd2_seq_history_ops = {
static const struct seq_operations jbd2_seq_history_ops = {
.start = jbd2_seq_history_start,
.next = jbd2_seq_history_next,
.stop = jbd2_seq_history_stop,
Expand Down Expand Up @@ -872,7 +872,7 @@ static void jbd2_seq_info_stop(struct seq_file *seq, void *v)
{
}

static struct seq_operations jbd2_seq_info_ops = {
static const struct seq_operations jbd2_seq_info_ops = {
.start = jbd2_seq_info_start,
.next = jbd2_seq_info_next,
.stop = jbd2_seq_info_stop,
Expand Down
4 changes: 2 additions & 2 deletions fs/nfs/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,7 @@ static void *nfs_server_list_next(struct seq_file *p, void *v, loff_t *pos);
static void nfs_server_list_stop(struct seq_file *p, void *v);
static int nfs_server_list_show(struct seq_file *m, void *v);

static struct seq_operations nfs_server_list_ops = {
static const struct seq_operations nfs_server_list_ops = {
.start = nfs_server_list_start,
.next = nfs_server_list_next,
.stop = nfs_server_list_stop,
Expand All @@ -1552,7 +1552,7 @@ static void *nfs_volume_list_next(struct seq_file *p, void *v, loff_t *pos);
static void nfs_volume_list_stop(struct seq_file *p, void *v);
static int nfs_volume_list_show(struct seq_file *m, void *v);

static struct seq_operations nfs_volume_list_ops = {
static const struct seq_operations nfs_volume_list_ops = {
.start = nfs_volume_list_start,
.next = nfs_volume_list_next,
.stop = nfs_volume_list_stop,
Expand Down
2 changes: 1 addition & 1 deletion fs/nfsd/export.c
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ static int e_show(struct seq_file *m, void *p)
return svc_export_show(m, &svc_export_cache, cp);
}

struct seq_operations nfs_exports_op = {
const struct seq_operations nfs_exports_op = {
.start = e_start,
.next = e_next,
.stop = e_stop,
Expand Down
4 changes: 2 additions & 2 deletions fs/ocfs2/cluster/netdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static void nst_seq_stop(struct seq_file *seq, void *v)
{
}

static struct seq_operations nst_seq_ops = {
static const struct seq_operations nst_seq_ops = {
.start = nst_seq_start,
.next = nst_seq_next,
.stop = nst_seq_stop,
Expand Down Expand Up @@ -344,7 +344,7 @@ static void sc_seq_stop(struct seq_file *seq, void *v)
{
}

static struct seq_operations sc_seq_ops = {
static const struct seq_operations sc_seq_ops = {
.start = sc_seq_start,
.next = sc_seq_next,
.stop = sc_seq_stop,
Expand Down
2 changes: 1 addition & 1 deletion fs/ocfs2/dlm/dlmdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ static int lockres_seq_show(struct seq_file *s, void *v)
return 0;
}

static struct seq_operations debug_lockres_ops = {
static const struct seq_operations debug_lockres_ops = {
.start = lockres_seq_start,
.stop = lockres_seq_stop,
.next = lockres_seq_next,
Expand Down
2 changes: 1 addition & 1 deletion fs/proc/nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static void *nommu_region_list_next(struct seq_file *m, void *v, loff_t *pos)
return rb_next((struct rb_node *) v);
}

static struct seq_operations proc_nommu_region_list_seqop = {
static const struct seq_operations proc_nommu_region_list_seqop = {
.start = nommu_region_list_start,
.next = nommu_region_list_next,
.stop = nommu_region_list_stop,
Expand Down
2 changes: 1 addition & 1 deletion include/linux/nfsd/nfsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ extern spinlock_t nfsd_drc_lock;
extern unsigned int nfsd_drc_max_mem;
extern unsigned int nfsd_drc_mem_used;

extern struct seq_operations nfs_exports_op;
extern const struct seq_operations nfs_exports_op;

/*
* Function prototypes.
Expand Down
2 changes: 1 addition & 1 deletion ipc/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ static int sysvipc_proc_show(struct seq_file *s, void *it)
return iface->show(s, it);
}

static struct seq_operations sysvipc_proc_seqops = {
static const struct seq_operations sysvipc_proc_seqops = {
.start = sysvipc_proc_start,
.stop = sysvipc_proc_stop,
.next = sysvipc_proc_next,
Expand Down
2 changes: 1 addition & 1 deletion kernel/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -2314,7 +2314,7 @@ static int cgroup_tasks_show(struct seq_file *s, void *v)
return seq_printf(s, "%d\n", *(int *)v);
}

static struct seq_operations cgroup_tasks_seq_operations = {
static const struct seq_operations cgroup_tasks_seq_operations = {
.start = cgroup_tasks_start,
.stop = cgroup_tasks_stop,
.next = cgroup_tasks_next,
Expand Down
2 changes: 1 addition & 1 deletion kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
return 0;
}

static struct seq_operations kprobes_seq_ops = {
static const struct seq_operations kprobes_seq_ops = {
.start = kprobe_seq_start,
.next = kprobe_seq_next,
.stop = kprobe_seq_stop,
Expand Down
2 changes: 1 addition & 1 deletion kernel/lockdep_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ static int ls_show(struct seq_file *m, void *v)
return 0;
}

static struct seq_operations lockstat_ops = {
static const struct seq_operations lockstat_ops = {
.start = ls_start,
.next = ls_next,
.stop = ls_stop,
Expand Down
4 changes: 2 additions & 2 deletions kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,7 @@ static int t_show(struct seq_file *m, void *v)
return 0;
}

static struct seq_operations show_ftrace_seq_ops = {
static const struct seq_operations show_ftrace_seq_ops = {
.start = t_start,
.next = t_next,
.stop = t_stop,
Expand Down Expand Up @@ -2459,7 +2459,7 @@ static int g_show(struct seq_file *m, void *v)
return 0;
}

static struct seq_operations ftrace_graph_seq_ops = {
static const struct seq_operations ftrace_graph_seq_ops = {
.start = g_start,
.next = g_next,
.stop = g_stop,
Expand Down
4 changes: 2 additions & 2 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1949,7 +1949,7 @@ static int s_show(struct seq_file *m, void *v)
return 0;
}

static struct seq_operations tracer_seq_ops = {
static const struct seq_operations tracer_seq_ops = {
.start = s_start,
.next = s_next,
.stop = s_stop,
Expand Down Expand Up @@ -2163,7 +2163,7 @@ static int t_show(struct seq_file *m, void *v)
return 0;
}

static struct seq_operations show_traces_seq_ops = {
static const struct seq_operations show_traces_seq_ops = {
.start = t_start,
.next = t_next,
.stop = t_stop,
Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/ip6mr.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ static int ipmr_mfc_seq_show(struct seq_file *seq, void *v)
return 0;
}

static struct seq_operations ipmr_mfc_seq_ops = {
static const struct seq_operations ipmr_mfc_seq_ops = {
.start = ipmr_mfc_seq_start,
.next = ipmr_mfc_seq_next,
.stop = ipmr_mfc_seq_stop,
Expand Down
4 changes: 2 additions & 2 deletions security/integrity/ima/ima_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static int ima_measurements_show(struct seq_file *m, void *v)
return 0;
}

static struct seq_operations ima_measurments_seqops = {
static const struct seq_operations ima_measurments_seqops = {
.start = ima_measurements_start,
.next = ima_measurements_next,
.stop = ima_measurements_stop,
Expand Down Expand Up @@ -221,7 +221,7 @@ static int ima_ascii_measurements_show(struct seq_file *m, void *v)
return 0;
}

static struct seq_operations ima_ascii_measurements_seqops = {
static const struct seq_operations ima_ascii_measurements_seqops = {
.start = ima_measurements_start,
.next = ima_measurements_next,
.stop = ima_measurements_stop,
Expand Down
Loading

0 comments on commit 88e9d34

Please sign in to comment.