proc: Report file name on detected read_proc overflow
PATCH 1/1 proc: Report file name on detected read_proc overflow
This can help identifying the buggy read_proc handler.
--- fs/proc/generic.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-)
fs/proc/generic.c +9 -3
@@ -132,7 +132,9 @@ __proc_file_read(struct file *file, char __user *buf, size_t nbytes,if (start ==NULL ) {if (n >PAGE_SIZE ) {printk (KERN_ERR -"proc_file_read: Apparent buffer overflow!\n" ); +"proc_file_read: Apparent buffer " +"overflow reading \"%s\"!\n" , + file->f_path.dentry->d_name.name); n =PAGE_SIZE ; } n -= *ppos;
@@ -144,7 +146,9 @@ __proc_file_read(struct file *file, char __user *buf, size_t nbytes, }else if (start < page) {if (n >PAGE_SIZE ) {printk (KERN_ERR -"proc_file_read: Apparent buffer overflow!\n" ); +"proc_file_read: Apparent buffer " +"overflow reading \"%s\"!\n" , + file->f_path.dentry->d_name.name); n =PAGE_SIZE ; }if (n > count) {
@@ -159,7 +163,9 @@ __proc_file_read(struct file *file, char __user *buf, size_t nbytes,unsigned long startoff = (unsigned long )(start - page);if (n > (PAGE_SIZE - startoff)) {printk (KERN_ERR -"proc_file_read: Apparent buffer overflow!\n" ); +"proc_file_read: Apparent buffer " +"overflow reading \"%s\"!\n" , + file->f_path.dentry->d_name.name); n =PAGE_SIZE - startoff; }if (n > count)
fs/proc/generic.c __proc_file_read(struct file *file, char __user *buf, size_t nbytes, · line 137
Quoted 4 lines · Jan Kiszka
fs/proc/generic.c +3
-1- "proc_file_read: Apparent buffer overflow!\n"); +"proc_file_read: Apparent buffer " +"overflow reading \"%s\"!\n" , + file->f_path.dentry->d_name.name);
I think it would be good to keep "overflow" on the first line as that may be what people will grep the source for. And maybe use single quotes around the file name. So:
+ "proc_file_read: Apparent buffer overflow " + "reading '%s'!\n", + file->f_path.dentry->d_name.name);
Cheers,
FJP
PATCH v2 1/1 proc: Report file name on detected read_proc overflow
This can help identifying the buggy read_proc handler.
--- fs/proc/generic.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-)
changes in v2:
- keep "Apparent buffer overflow" in the same source code line
- quote the file name with ''
(Thanks, Frans!)
fs/proc/generic.c +9 -3
@@ -132,7 +132,9 @@ __proc_file_read(struct file *file, char __user *buf, size_t nbytes,if (start ==NULL ) {if (n >PAGE_SIZE ) {printk (KERN_ERR -"proc_file_read: Apparent buffer overflow!\n" ); +"proc_file_read: Apparent buffer overflow" +" reading '%s'!\n" , + file->f_path.dentry->d_name.name); n =PAGE_SIZE ; } n -= *ppos;
@@ -144,7 +146,9 @@ __proc_file_read(struct file *file, char __user *buf, size_t nbytes, }else if (start < page) {if (n >PAGE_SIZE ) {printk (KERN_ERR -"proc_file_read: Apparent buffer overflow!\n" ); +"proc_file_read: Apparent buffer overflow" +" reading '%s'!\n" , + file->f_path.dentry->d_name.name); n =PAGE_SIZE ; }if (n > count) {
@@ -159,7 +163,9 @@ __proc_file_read(struct file *file, char __user *buf, size_t nbytes,unsigned long startoff = (unsigned long )(start - page);if (n > (PAGE_SIZE - startoff)) {printk (KERN_ERR -"proc_file_read: Apparent buffer overflow!\n" ); +"proc_file_read: Apparent buffer overflow" +" reading '%s'!\n" , + file->f_path.dentry->d_name.name); n =PAGE_SIZE - startoff; }if (n > count)
Quoted 1 line · Jan Kiszka
This can help identifying the buggy
read_prochandler.
->read_proc is going to be removed, so there is no point.
Quoted 4 lines
- "proc_file_read: Apparent buffer overflow!\n");
+ "proc_file_read: Apparent buffer "
+ "overflow reading \"%s\"!\n",
+ file->f_path.dentry->d_name.name);
Quoted 4 lines · Alexey Dobriyan
Quoted 1 line · Jan Kiszka
This can help identifying the buggy
read_prochandler.->read_proc is going to be removed, so there is no point.
OK. What is the planned kernel release or date?
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux