This can help identifying the buggy read_proc handler.
Signed-off-by: Jan Kiszka <[email protected]>
---
fs/proc/generic.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 08f4d71..cc7e671 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -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)
Jan Kiszka wrote:
> - "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
This can help identifying the buggy read_proc handler.
Signed-off-by: Jan Kiszka <[email protected]>
---
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!)
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 08f4d71..ce14eca 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -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)
On Thu, Apr 1, 2010 at 4:09 PM, Jan Kiszka <[email protected]> wrote:
> This can help identifying the buggy read_proc handler.
->read_proc is going to be removed, so there is no point.
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?"proc_file_read: Apparent buffer overflow!\n");
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?"proc_file_read: Apparent buffer "
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?"overflow reading \"%s\"!\n",
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?file->f_path.dentry->d_name.name);
Alexey Dobriyan wrote:
> On Thu, Apr 1, 2010 at 4:09 PM, Jan Kiszka <[email protected]> wrote:
>> This can help identifying the buggy read_proc handler.
>
> ->read_proc is going to be removed, so there is no point.
OK. What is the planned kernel release or date?
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux