simplify procfs code for seq_file instances V2
Subsystems (99)
PATCH 37/40 proc: don't detour through seq->private to get the inode
In reply to Christoph Hellwig--- fs/proc/array.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
fs/proc/array.c +4 -14
@@ -677,7 +677,7 @@ get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)static int children_seq_show (struct seq_file *seq,void *v) { -struct inode *inode = seq->private; +struct inode *inode =file_inode (seq->file);pid_t pid; pid =pid_nr_ns (v, inode->i_sb->s_fs_info);
@@ -688,14 +688,14 @@ static int children_seq_show(struct seq_file *seq, void *v)static void *children_seq_start (struct seq_file *seq,loff_t *pos) { -return get_children_pid (seq->private,NULL , *pos); +return get_children_pid (file_inode (seq->file),NULL , *pos); }static void *children_seq_next (struct seq_file *seq,void *v,loff_t *pos) {struct pid *pid; - pid =get_children_pid (seq->private, v, *pos +1 ); + pid =get_children_pid (file_inode (seq->file), v, *pos +1 );put_pid (v); ++*pos;
@@ -716,17 +716,7 @@ static const struct seq_operations children_seq_ops = {static int children_seq_open (struct inode *inode,struct file *file) { -struct seq_file *m; -int ret; - - ret =seq_open (file, &children_seq_ops); -if (ret) -return ret; - - m = file->private_data; - m->private = inode; - -return ret; +return seq_open (file, &children_seq_ops); }const struct file_operations proc_tid_children_operations = {
Signature · 1 line
2.17.0
PATCH 38/40 ide: remove ide_driver_proc_write
In reply to Christoph HellwigThe driver proc file hasn't been writeable for a long time, so this is just dead code.
--- drivers/ide/ide-proc.c | 46 ------------------------------------------ 1 file changed, 46 deletions(-)
drivers/ide/ide-proc.c +0 -46
@@ -528,58 +528,12 @@ static int ide_driver_proc_open(struct inode *inode, struct file *file)return single_open (file, ide_driver_proc_show,PDE_DATA (inode)); } -static int ide_replace_subdriver (ide_drive_t *drive,const char *driver) -{ -struct device *dev = &drive->gendev; -int ret =1 ; -int err; - -device_release_driver (dev); -/* FIXME: device can still be in use by previous driver */ -strlcpy (drive->driver_req, driver,sizeof (drive->driver_req)); - err =device_attach (dev); -if (err <0 ) -printk (KERN_WARNING "IDE: %s: device_attach error: %d\n" , - __func__, err); - drive->driver_req[0 ] =0 ; -if (dev->driver ==NULL ) { - err =device_attach (dev); -if (err <0 ) -printk (KERN_WARNING -"IDE: %s: device_attach(2) error: %d\n" , - __func__, err); - } -if (dev->driver && !strcmp (dev->driver->name, driver)) - ret =0 ; - -return ret; -} - -static ssize_t ide_driver_proc_write (struct file *file,const char __user *buffer, -size_t count,loff_t *pos) -{ -ide_drive_t *drive =PDE_DATA (file_inode (file)); -char name[32 ]; - -if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; -if (count >31 ) - count =31 ; -if (copy_from_user (name, buffer, count)) -return -EFAULT ; - name[count] ='\0' ; -if (ide_replace_subdriver (drive, name)) -return -EINVAL ; -return count; -} -static const struct file_operations ide_driver_proc_fops = { .owner =THIS_MODULE , .open = ide_driver_proc_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, - .write = ide_driver_proc_write, };static int ide_media_proc_show (struct seq_file *m,void *v)
Signature · 1 line
2.17.0
Re: [PATCH 38/40] ide: remove ide_driver_proc_write
Quoted 2 lines · Christoph Hellwig
The driver proc file hasn't been writeable for a long time, so this is just dead code.
It is possible to chmod this file to get at the write method. Not that I think anyone does.
It looks like this code was merged in 2.3.99-pre1 with permissions S_IFREG|S_IRUGO so I don't think the write support was ever finished.
That cap_capable in the write method looks down right scary/buggy.
Eric
Quoted 69 lines
Signed-off-by Christoph Hellwig <[email protected]>--- drivers/ide/ide-proc.c | 46 ------------------------------------------ 1 file changed, 46 deletions(-)drivers/ide/ide-proc.c +0
-46@@ -528,58 +528,12 @@ static int ide_driver_proc_open(struct inode *inode, struct file *file)return single_open (file, ide_driver_proc_show,PDE_DATA (inode)); } -static int ide_replace_subdriver (ide_drive_t *drive,const char *driver) -{ -struct device *dev = &drive->gendev; -int ret =1 ; -int err; - -device_release_driver (dev); -/* FIXME: device can still be in use by previous driver */ -strlcpy (drive->driver_req, driver,sizeof (drive->driver_req)); - err =device_attach (dev); -if (err <0 ) -printk (KERN_WARNING "IDE: %s: device_attach error: %d\n" , - __func__, err); - drive->driver_req[0 ] =0 ; -if (dev->driver ==NULL ) { - err =device_attach (dev); -if (err <0 ) -printk (KERN_WARNING -"IDE: %s: device_attach(2) error: %d\n" , - __func__, err); - } -if (dev->driver && !strcmp (dev->driver->name, driver)) - ret =0 ; - -return ret; -} - -static ssize_t ide_driver_proc_write (struct file *file,const char __user *buffer, -size_t count,loff_t *pos) -{ -ide_drive_t *drive =PDE_DATA (file_inode (file)); -char name[32 ]; - -if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; -if (count >31 ) - count =31 ; -if (copy_from_user (name, buffer, count)) -return -EFAULT ; - name[count] ='\0' ; -if (ide_replace_subdriver (drive, name)) -return -EINVAL ; -return count; -} -static const struct file_operations ide_driver_proc_fops = { .owner =THIS_MODULE , .open = ide_driver_proc_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, - .write = ide_driver_proc_write, };static int ide_media_proc_show (struct seq_file *m,void *v)
PATCH 39/40 ide: replace ->proc_fops with ->proc_show
In reply to Christoph HellwigJust set up the show callback in the tty_operations, and use proc_create_single_data to create the file without additional boilerplace code.
--- drivers/ide/ide-cd.c | 15 +--- drivers/ide/ide-disk_proc.c | 62 ++-------------- drivers/ide/ide-floppy_proc.c | 17 +---- drivers/ide/ide-proc.c | 136 +++++----------------------------- drivers/ide/ide-tape.c | 17 +---- include/linux/ide.h | 6 +- 6 files changed, 31 insertions(+), 222 deletions(-)
drivers/ide/ide-cd.c +1 -14
@@ -1426,21 +1426,8 @@ static int idecd_capacity_proc_show(struct seq_file *m, void *v)return 0 ; } -static int idecd_capacity_proc_open (struct inode *inode,struct file *file) -{ -return single_open (file, idecd_capacity_proc_show,PDE_DATA (inode)); -} - -static const struct file_operations idecd_capacity_proc_fops = { - .owner =THIS_MODULE , - .open = idecd_capacity_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; -static ide_proc_entry_t idecd_proc[] = { - {"capacity" ,S_IFREG |S_IRUGO , &idecd_capacity_proc_fops }, + {"capacity" ,S_IFREG |S_IRUGO , idecd_capacity_proc_show }, {} };
drivers/ide/ide-disk_proc.c +5 -57
86 lines not on this page · raw message
drivers/ide/ide-floppy_proc.c +2 -15
@@ -14,22 +14,9 @@ static int idefloppy_capacity_proc_show(struct seq_file *m, void *v)return 0 ; } -static int idefloppy_capacity_proc_open (struct inode *inode,struct file *file) -{ -return single_open (file, idefloppy_capacity_proc_show,PDE_DATA (inode)); -} - -static const struct file_operations idefloppy_capacity_proc_fops = { - .owner =THIS_MODULE , - .open = idefloppy_capacity_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; -ide_proc_entry_t ide_floppy_proc[] = { - {"capacity" ,S_IFREG |S_IRUGO , &idefloppy_capacity_proc_fops }, - {"geometry" ,S_IFREG |S_IRUGO , &ide_geometry_proc_fops }, + {"capacity" ,S_IFREG |S_IRUGO , idefloppy_capacity_proc_show }, + {"geometry" ,S_IFREG |S_IRUGO , ide_geometry_proc_show }, {} };
drivers/ide/ide-proc.c +18 -118
220 lines not on this page · raw message
drivers/ide/ide-tape.c +2 -15
@@ -1847,22 +1847,9 @@ static int idetape_name_proc_show(struct seq_file *m, void *v)return 0 ; } -static int idetape_name_proc_open (struct inode *inode,struct file *file) -{ -return single_open (file, idetape_name_proc_show,PDE_DATA (inode)); -} - -static const struct file_operations idetape_name_proc_fops = { - .owner =THIS_MODULE , - .open = idetape_name_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; -static ide_proc_entry_t idetape_proc[] = { - {"capacity" ,S_IFREG |S_IRUGO , &ide_capacity_proc_fops }, - {"name" ,S_IFREG |S_IRUGO , &idetape_name_proc_fops }, + {"capacity" ,S_IFREG |S_IRUGO , ide_capacity_proc_show }, + {"name" ,S_IFREG |S_IRUGO , idetape_name_proc_show }, {} };
include/linux/ide.h +3 -3
@@ -961,7 +961,7 @@ __IDE_PROC_DEVSET(_name, _min, _max, NULL, NULL)typedef struct {const char *name;umode_t mode; -const struct file_operations *proc_fops; +int (*show)(struct seq_file *,void *); }ide_proc_entry_t ;void proc_ide_create (void );
@@ -973,8 +973,8 @@ void ide_proc_unregister_port(ide_hwif_t *);void ide_proc_register_driver (ide_drive_t *,struct ide_driver *);void ide_proc_unregister_driver (ide_drive_t *,struct ide_driver *); -extern const struct file_operations ide_capacity_proc_fops; -extern const struct file_operations ide_geometry_proc_fops; +int ide_capacity_proc_show (struct seq_file *m,void *v); +int ide_geometry_proc_show (struct seq_file *m,void *v);#else static inline void proc_ide_create (void ) { ; }static inline void proc_ide_destroy (void ) { ; }
Signature · 1 line
2.17.0
PATCH 40/40 tty: replace ->proc_fops with ->proc_show
In reply to Christoph HellwigJust set up the show callback in the tty_operations, and use proc_create_single_data to create the file without additional boilerplace code.
--- arch/ia64/hp/sim/simserial.c | 15 +-------------- arch/xtensa/platforms/iss/console.c | 15 +-------------- drivers/char/pcmcia/synclink_cs.c | 15 +-------------- drivers/mmc/core/sdio_uart.c | 15 +-------------- drivers/staging/fwserial/fwserial.c | 15 +-------------- drivers/tty/amiserial.c | 15 +-------------- drivers/tty/cyclades.c | 15 +-------------- drivers/tty/serial/serial_core.c | 15 +-------------- drivers/tty/synclink.c | 15 +-------------- drivers/tty/synclink_gt.c | 15 +-------------- drivers/tty/synclinkmp.c | 15 +-------------- drivers/usb/serial/usb-serial.c | 15 +-------------- fs/proc/proc_tty.c | 6 +++--- include/linux/tty_driver.h | 2 +- 14 files changed, 16 insertions(+), 172 deletions(-)
arch/ia64/hp/sim/simserial.c +1 -14
@@ -435,19 +435,6 @@ static int rs_proc_show(struct seq_file *m, void *v)return 0 ; } -static int rs_proc_open (struct inode *inode,struct file *file) -{ -return single_open (file, rs_proc_show,NULL ); -} - -static const struct file_operations rs_proc_fops = { - .owner =THIS_MODULE , - .open = rs_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; -static const struct tty_operations hp_ops = { .open = rs_open, .close = rs_close,
@@ -462,7 +449,7 @@ static const struct tty_operations hp_ops = { .unthrottle = rs_unthrottle, .send_xchar = rs_send_xchar, .hangup = rs_hangup, - .proc_fops = &rs_proc_fops, + .proc_show = rs_proc_show, };static const struct tty_port_operations hp_port_ops = {
arch/xtensa/platforms/iss/console.c +1 -14
@@ -153,19 +153,6 @@ static int rs_proc_show(struct seq_file *m, void *v)return 0 ; } -static int rs_proc_open (struct inode *inode,struct file *file) -{ -return single_open (file, rs_proc_show,NULL ); -} - -static const struct file_operations rs_proc_fops = { - .owner =THIS_MODULE , - .open = rs_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; -static const struct tty_operations serial_ops = { .open = rs_open, .close = rs_close,
@@ -176,7 +163,7 @@ static const struct tty_operations serial_ops = { .chars_in_buffer = rs_chars_in_buffer, .hangup = rs_hangup, .wait_until_sent = rs_wait_until_sent, - .proc_fops = &rs_proc_fops, + .proc_show = rs_proc_show, };int __init rs_init (void )
drivers/char/pcmcia/synclink_cs.c +1 -14
@@ -2616,19 +2616,6 @@ static int mgslpc_proc_show(struct seq_file *m, void *v)return 0 ; } -static int mgslpc_proc_open (struct inode *inode,struct file *file) -{ -return single_open (file, mgslpc_proc_show,NULL ); -} - -static const struct file_operations mgslpc_proc_fops = { - .owner =THIS_MODULE , - .open = mgslpc_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; -static int rx_alloc_buffers (MGSLPC_INFO *info) {/* each buffer has header and data */
@@ -2815,7 +2802,7 @@ static const struct tty_operations mgslpc_ops = { .tiocmget = tiocmget, .tiocmset = tiocmset, .get_icount = mgslpc_get_icount, - .proc_fops = &mgslpc_proc_fops, + .proc_show = mgslpc_proc_show, };static int __init synclink_cs_init (void )
drivers/mmc/core/sdio_uart.c +1 -14
@@ -1008,19 +1008,6 @@ static int sdio_uart_proc_show(struct seq_file *m, void *v)return 0 ; } -static int sdio_uart_proc_open (struct inode *inode,struct file *file) -{ -return single_open (file, sdio_uart_proc_show,NULL ); -} - -static const struct file_operations sdio_uart_proc_fops = { - .owner =THIS_MODULE , - .open = sdio_uart_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; -static const struct tty_port_operations sdio_uart_port_ops = { .dtr_rts = uart_dtr_rts, .carrier_raised = uart_carrier_raised,
@@ -1045,7 +1032,7 @@ static const struct tty_operations sdio_uart_ops = { .tiocmset = sdio_uart_tiocmset, .install = sdio_uart_install, .cleanup = sdio_uart_cleanup, - .proc_fops = &sdio_uart_proc_fops, + .proc_show = sdio_uart_proc_show, };static struct tty_driver *sdio_uart_tty_driver;
drivers/staging/fwserial/fwserial.c +1 -14
@@ -1506,11 +1506,6 @@ static int fwtty_debugfs_peers_show(struct seq_file *m, void *v)return 0 ; } -static int fwtty_proc_open (struct inode *inode,struct file *fp) -{ -return single_open (fp, fwtty_proc_show,NULL ); -} -static int fwtty_stats_open (struct inode *inode,struct file *fp) {return single_open (fp, fwtty_debugfs_stats_show, inode->i_private);
@@ -1537,14 +1532,6 @@ static const struct file_operations fwtty_peers_fops = { .release = single_release, }; -static const struct file_operations fwtty_proc_fops = { - .owner =THIS_MODULE , - .open = fwtty_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; -static const struct tty_port_operations fwtty_port_ops = { .dtr_rts = fwtty_port_dtr_rts, .carrier_raised = fwtty_port_carrier_raised,
@@ -1570,7 +1557,7 @@ static const struct tty_operations fwtty_ops = { .tiocmget = fwtty_tiocmget, .tiocmset = fwtty_tiocmset, .get_icount = fwtty_get_icount, - .proc_fops = &fwtty_proc_fops, + .proc_show = fwtty_proc_show, };static const struct tty_operations fwloop_ops = {
drivers/tty/amiserial.c +1 -14
@@ -1566,19 +1566,6 @@ static int rs_proc_show(struct seq_file *m, void *v)return 0 ; } -static int rs_proc_open (struct inode *inode,struct file *file) -{ -return single_open (file, rs_proc_show,NULL ); -} - -static const struct file_operations rs_proc_fops = { - .owner =THIS_MODULE , - .open = rs_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; -/* * --------------------------------------------------------------------- * rs_init() and friends
@@ -1620,7 +1607,7 @@ static const struct tty_operations serial_ops = { .tiocmget = rs_tiocmget, .tiocmset = rs_tiocmset, .get_icount = rs_get_icount, - .proc_fops = &rs_proc_fops, + .proc_show = rs_proc_show, };static int amiga_carrier_raised (struct tty_port *port)
drivers/tty/cyclades.c +1 -14
@@ -3972,19 +3972,6 @@ static int cyclades_proc_show(struct seq_file *m, void *v)return 0 ; } -static int cyclades_proc_open (struct inode *inode,struct file *file) -{ -return single_open (file, cyclades_proc_show,NULL ); -} - -static const struct file_operations cyclades_proc_fops = { - .owner =THIS_MODULE , - .open = cyclades_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; -/* The serial driver boot-time initialization code! Hardware I/O ports are mapped to character special devices on a first found, first allocated manner. That is, this code searches
@@ -4024,7 +4011,7 @@ static const struct tty_operations cy_ops = { .tiocmget = cy_tiocmget, .tiocmset = cy_tiocmset, .get_icount = cy_get_icount, - .proc_fops = &cyclades_proc_fops, + .proc_show = cyclades_proc_show, };static int __init cy_init (void )
drivers/tty/serial/serial_core.c +1 -14
@@ -1829,19 +1829,6 @@ static int uart_proc_show(struct seq_file *m, void *v)uart_line_info (m, drv, i); return 0; } - -static int uart_proc_open (struct inode *inode,struct file *file) -{ -return single_open (file, uart_proc_show,PDE_DATA (inode)); -} - -static const struct file_operations uart_proc_fops = { - .owner =THIS_MODULE , - .open = uart_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -};#endif #if defined(CONFIG_SERIAL_CORE_CONSOLE ) || defined(CONFIG_CONSOLE_POLL )
@@ -2415,7 +2402,7 @@ static const struct tty_operations uart_ops = { .break_ctl = uart_break_ctl, .wait_until_sent= uart_wait_until_sent, #ifdef CONFIG_PROC_FS - .proc_fops = &uart_proc_fops, + .proc_show = uart_proc_show, #endif .tiocmget = uart_tiocmget, .tiocmset = uart_tiocmset,
drivers/tty/synclink.c +1 -14
@@ -3534,19 +3534,6 @@ static int mgsl_proc_show(struct seq_file *m, void *v)return 0 ; } -static int mgsl_proc_open (struct inode *inode,struct file *file) -{ -return single_open (file, mgsl_proc_show,NULL ); -} - -static const struct file_operations mgsl_proc_fops = { - .owner =THIS_MODULE , - .open = mgsl_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; -/* mgsl_allocate_dma_buffers() * * Allocate and format DMA buffers (ISA adapter)
@@ -4298,7 +4285,7 @@ static const struct tty_operations mgsl_ops = { .tiocmget = tiocmget, .tiocmset = tiocmset, .get_icount = msgl_get_icount, - .proc_fops = &mgsl_proc_fops, + .proc_show = mgsl_proc_show, };/*
drivers/tty/synclink_gt.c +1 -14
@@ -1316,19 +1316,6 @@ static int synclink_gt_proc_show(struct seq_file *m, void *v)return 0 ; } -static int synclink_gt_proc_open (struct inode *inode,struct file *file) -{ -return single_open (file, synclink_gt_proc_show,NULL ); -} - -static const struct file_operations synclink_gt_proc_fops = { - .owner =THIS_MODULE , - .open = synclink_gt_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; -/* * return count of bytes in transmit buffer */
@@ -3721,7 +3708,7 @@ static const struct tty_operations ops = { .tiocmget = tiocmget, .tiocmset = tiocmset, .get_icount = get_icount, - .proc_fops = &synclink_gt_proc_fops, + .proc_show = synclink_gt_proc_show, };static void slgt_cleanup (void )
drivers/tty/synclinkmp.c +1 -14
@@ -1421,19 +1421,6 @@ static int synclinkmp_proc_show(struct seq_file *m, void *v)return 0 ; } -static int synclinkmp_proc_open (struct inode *inode,struct file *file) -{ -return single_open (file, synclinkmp_proc_show,NULL ); -} - -static const struct file_operations synclinkmp_proc_fops = { - .owner =THIS_MODULE , - .open = synclinkmp_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; -/* Return the count of bytes in transmit buffer */ static int chars_in_buffer (struct tty_struct *tty)
@@ -3899,7 +3886,7 @@ static const struct tty_operations ops = { .tiocmget = tiocmget, .tiocmset = tiocmset, .get_icount = get_icount, - .proc_fops = &synclinkmp_proc_fops, + .proc_show = synclinkmp_proc_show, };
drivers/usb/serial/usb-serial.c +1 -14
@@ -476,19 +476,6 @@ static int serial_proc_show(struct seq_file *m, void *v)return 0 ; } -static int serial_proc_open (struct inode *inode,struct file *file) -{ -return single_open (file, serial_proc_show,NULL ); -} - -static const struct file_operations serial_proc_fops = { - .owner =THIS_MODULE , - .open = serial_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; -static int serial_tiocmget (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data;
@@ -1192,7 +1179,7 @@ static const struct tty_operations serial_ops = { .get_icount = serial_get_icount, .cleanup = serial_cleanup, .install = serial_install, - .proc_fops = &serial_proc_fops, + .proc_show = serial_proc_show, };
fs/proc/proc_tty.c +3 -3
@@ -135,11 +135,11 @@ void proc_tty_register_driver(struct tty_driver *driver)struct proc_dir_entry *ent;if (!driver->driver_name || driver->proc_entry || - !driver->ops->proc_fops) + !driver->ops->proc_show)return ; - ent =proc_create_data (driver->driver_name,0 , proc_tty_driver, - driver->ops->proc_fops, driver); + ent =proc_create_single_data (driver->driver_name,0 , proc_tty_driver, + driver->ops->proc_show, driver); driver->proc_entry = ent; }
include/linux/tty_driver.h +1 -1
@@ -293,7 +293,7 @@ struct tty_operations {int (*poll_get_char)(struct tty_driver *driver,int line);void (*poll_put_char)(struct tty_driver *driver,int line,char ch);#endif -const struct file_operations *proc_fops; +int (*proc_show)(struct seq_file *,void *); } __randomize_layout;struct tty_driver {
Signature · 1 line
2.17.0
David Howells
maintainerNote that your kernel hits the:
inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage.
swapper/0/0 [HC1[1]:SC0[0]:HE0:SE1] takes:
(ptrval) (fs_reclaim){?.+.}, at: fs_reclaim_acquire+0x12/0x35
{HARDIRQ-ON-W} state was registered at:
fs_reclaim_acquire+0x32/0x35
kmem_cache_alloc_node_trace+0x49/0x2cf
alloc_worker+0x1d/0x49
init_rescuer.part.7+0x19/0x8f
workqueue_init+0xc0/0x1fe
kernel_init_freeable+0xdc/0x433
kernel_init+0xa/0xf5
ret_from_fork+0x24/0x30bug, as described here:
https://groups.google.com/forum/#!msg/syzkaller-bugs/sJC3Y3hOM08/aO3z9JXoAgAJ
David
Quoted 4 lines · Christoph Hellwig
Changes since V1:
- open codeproc_create_datato avoid setting not fully initialized entries live
- use unsigned int forstate_size
Need this to maintain sizeof(struct proc_dir_entry):
Otherwise ACK fs/proc/ part.
fs/proc/internal.h +3 -3
@@ -48,8 +48,8 @@ struct proc_dir_entry {const struct seq_operations *seq_ops;int (*single_show)(struct seq_file *,void *); }; -unsigned int state_size;void *data; +unsigned int state_size;unsigned int low_ino;nlink_t nlink;kuid_t uid;
@@ -62,9 +62,9 @@ struct proc_dir_entry {umode_t mode;u8 namelen;#ifdef CONFIG_64BIT -#define SIZEOF_PDE_INLINE_NAME (192-139) +#define SIZEOF_PDE_INLINE_NAME (192-155)#else -#define SIZEOF_PDE_INLINE_NAME (128-87) +#define SIZEOF_PDE_INLINE_NAME (128-95)#endif char inline_name[SIZEOF_PDE_INLINE_NAME ]; } __randomize_layout;
fs/proc/proc_net.c +1 -1
@@ -40,7 +40,7 @@ static struct net *get_proc_net(const struct inode *inode)static int seq_open_net (struct inode *inode,struct file *file) { -size_t state_size =PDE (inode)->state_size; +unsigned int state_size =PDE (inode)->state_size;struct seq_net_private *p;struct net *net;
Al Viro
maintainerfs/proc/internal.h struct proc_dir_entry { · line 55
Quoted 11 lines · Alexey Dobriyan
+++
b/fs/proc/internal.hfs/proc/internal.h +1
-1@@ -48,8 +48,8 @@ struct proc_dir_entry {const struct seq_operations *seq_ops;int (*single_show)(struct seq_file *,void *); }; -unsigned int state_size;void *data; +unsigned int state_size;unsigned int low_ino;nlink_t nlink;kuid_t uid;
Makes sense
Quoted 12 lines
fs/proc/internal.h +2
-2@@ -62,9 +62,9 @@ struct proc_dir_entry {umode_t mode;u8 namelen;#ifdef CONFIG_64BIT -#define SIZEOF_PDE_INLINE_NAME (192-139) +#define SIZEOF_PDE_INLINE_NAME (192-155)#else -#define SIZEOF_PDE_INLINE_NAME (128-87) +#define SIZEOF_PDE_INLINE_NAME (128-95)#endif char inline_name[SIZEOF_PDE_INLINE_NAME ];
Quoted 1 line
}
__randomize_layout;
*UGH*
Both to the original state and that kind of "adjustments". Incidentally, with __bugger_layout in there these expressions are simply wrong.
If nothing else, I would suggest turning the last one into
char inline_name[];
in hope that layout won't get... randomized that much and used
#ifdef CONFIG_64BIT
#define PDE_SIZE 192
#else
#define PDE_SIZE 128
#endif
union __proc_dir_entry {
char pad[PDE_SIZE];
struct proc_dir_entry real;
};#define SIZEOF_PDE_INLINE_NAME (PDE_SIZE - offsetof(struct proc_dir_entry, inline_name))
for constants, adjusted sizeof and sizeof_field when creating proc_dir_entry_cache and turned proc_root into
union __proc_dir_entry __proc_root = { .real = {
.low_ino = PROC_ROOT_INO,
.namelen = 5,
.mode = S_IFDIR | S_IRUGO | S_IXUGO,
.nlink = 2,
.refcnt = REFCOUNT_INIT(1),
.proc_iops = &proc_root_inode_operations,
.proc_fops = &proc_root_operations,
.parent = &__proc_root.real,
.subdir = RB_ROOT,
.name = __proc_root.real.inline_name,
.inline_name = "/proc",}};
#define proc_root __proc_root.real
(or actually used __proc_root.real in all of a 6 places where it remains).
fs/proc/proc_net.c static struct net *get_proc_net(const struct inode *inode) · line 45
Quoted 12 lines
fs/proc/proc_net.c +1
-1@@ -40,7 +40,7 @@ static struct net *get_proc_net(const struct inode *inode)static int seq_open_net (struct inode *inode,struct file *file) { -size_t state_size =PDE (inode)->state_size; +unsigned int state_size =PDE (inode)->state_size;struct seq_net_private *p;struct net *net;
<shakes head>
You and your "size_t is evil" crusade...
Quoted 12 lines · Al Viro
Quoted 9 lines · Alexey Dobriyan
fs/proc/internal.h +2
-2@@ -62,9 +62,9 @@ struct proc_dir_entry {umode_t mode;u8 namelen;#ifdef CONFIG_64BIT -#define SIZEOF_PDE_INLINE_NAME (192-139) +#define SIZEOF_PDE_INLINE_NAME (192-155)#else -#define SIZEOF_PDE_INLINE_NAME (128-87) +#define SIZEOF_PDE_INLINE_NAME (128-95)
Quoted 5 lines
fs/proc/internal.h struct proc_dir_entry { · line 70
Quoted 3 lines
fs/proc/internal.h +0
-0#endif char inline_name[SIZEOF_PDE_INLINE_NAME ]; } __randomize_layout;*UGH*
I agree. Maintaining these numbers is a pain point. Who knew people were going to start adding fields right away.
Quoted 3 lines
Both to the original state and that kind of "adjustments". Incidentally, with
__bugger_layoutin there these expressions are simply wrong.
Struct randomization is exempt from maintaining sizeof as they are already screwing cachelines and everything. But if patch works with lockdep and randomization -- even better.
Quoted 35 lines
If nothing else, I would suggest turning the last one into
char inline_name[];in hope that layout won't get... randomized that much and used
#ifdef
CONFIG_64BIT
#definePDE_SIZE192
#else
#definePDE_SIZE128
#endifunion __proc_dir_entry { char pad[PDE_SIZE]; struct proc_dir_entry real; };#define
SIZEOF_PDE_INLINE_NAME(PDE_SIZE-offsetof(struct proc_dir_entry, inline_name))for constants, adjusted sizeof and
sizeof_fieldwhen creatingproc_dir_entry_cacheand turnedproc_rootintounion
__proc_dir_entry__proc_root= { .real = {.low_ino = PROC_ROOT_INO, .namelen = 5, .mode = S_IFDIR | S_IRUGO | S_IXUGO, .nlink = 2, .refcnt = REFCOUNT_INIT(1), .proc_iops = &proc_root_inode_operations, .proc_fops = &proc_root_operations, .parent = &__proc_root.real, .subdir = RB_ROOT, .name = __proc_root.real.inline_name, .inline_name = "/proc",}};
Quoted 8 lines
#define
proc_root__proc_root.real
(or actually used __proc_root.real in all of a 6 places where it remains).fs/proc/proc_net.c static struct net *get_proc_net(const struct inode *inode) · line 43
Quoted 2 lines
fs/proc/proc_net.c +1
-1-size_t state_size =PDE (inode)->state_size; +unsigned int state_size =PDE (inode)->state_size;<shakes head>
You and your "size_tis evil" crusade...
[nods]
unsigned long flags; /* error bits */
unsigned long i_state;
unsigned long s_blocksize;
unsigned long s_flags;
unsigned long s_iflags; /* internal SB_I_* flags */Quoted 7 lines · Alexey Dobriyan
Quoted 4 lines · Christoph Hellwig
Changes since V1:
- open codeproc_create_datato avoid setting not fully initialized entries live
- use unsigned int forstate_sizeNeed this to maintain
sizeof(struct proc_dir_entry):
I'll fold your changes into the relevant patches.
Quoted 1 line
Otherwise ACK
fs/proc/part.
I'll take this as a formal ACK-ed by for all patches touching procfs. If I was wrong please scream.