All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Frans Pop <elendil@planet.nl>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"adobriyan@gmail.com" <adobriyan@gmail.com>,
	"helight.xu@gmail.com" <helight.xu@gmail.com>,
	"viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>
Subject: [PATCH v2] proc: Report file name on detected read_proc overflow
Date: Thu, 01 Apr 2010 18:16:22 +0200	[thread overview]
Message-ID: <4BB4C6D6.6020602@siemens.com> (raw)
In-Reply-To: <201004011641.58462.elendil@planet.nl>

This can help identifying the buggy read_proc handler.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 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)


  reply	other threads:[~2010-04-01 16:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-01 13:09 [PATCH] proc: Report file name on detected read_proc overflow Jan Kiszka
2010-04-01 14:41 ` Frans Pop
2010-04-01 16:16   ` Jan Kiszka [this message]
2010-04-02  6:28 ` Alexey Dobriyan
2010-04-06 16:48   ` Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BB4C6D6.6020602@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=elendil@planet.nl \
    --cc=helight.xu@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.