From: Richard Genoud <richard.genoud@gmail.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-kernel@vger.kernel.org,
Richard Genoud <richard.genoud@gmail.com>
Subject: [PATCH] proc: return on proc_readdir error
Date: Mon, 19 Aug 2013 18:30:31 +0200 [thread overview]
Message-ID: <1376929831-18214-1-git-send-email-richard.genoud@gmail.com> (raw)
commit f0c3b5093addc8bfe9fe3a5b01acb7ec7969eafa
"[readdir] convert procfs" introduced a bug on the listing of the proc
file-system.
The return value of proc_readdir() isn't tested anymore in the
proc_root_readdir function.
This lead to an "interesting" behaviour when we are using the getdents()
system call with a buffer too small:
Instead of failing, it returns the first entries of /proc (enough to
fill the given buffer), plus the PID directories.
This is not triggered on glibc (as getdents is called with a 32KB
buffer), but on uclibc, the buffer size is only 1KB, thus some proc
entries are missing.
(described more in details here: https://lkml.org/lkml/2013/8/12/288 )
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
---
[added Linus Torvalds and Andrew Morton in CC since Al Viro seems to be
on holidays and it's starting to getting late in the -rc cycles]
fs/proc/root.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/proc/root.c b/fs/proc/root.c
index 229e366..e0a790d 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -205,7 +205,9 @@ static struct dentry *proc_root_lookup(struct inode * dir, struct dentry * dentr
static int proc_root_readdir(struct file *file, struct dir_context *ctx)
{
if (ctx->pos < FIRST_PROCESS_ENTRY) {
- proc_readdir(file, ctx);
+ int error = proc_readdir(file, ctx);
+ if (unlikely(error <= 0))
+ return error;
ctx->pos = FIRST_PROCESS_ENTRY;
}
--
1.7.10.4
next reply other threads:[~2013-08-19 16:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-19 16:30 Richard Genoud [this message]
2013-08-19 16:48 ` Linus Torvalds
2013-08-19 20:33 ` Marc Dionne
2013-08-19 23:49 ` Linus Torvalds
2013-08-20 0:30 ` Marc Dionne
2013-08-20 6:25 ` Richard Genoud
2013-08-23 11:39 ` Geert Uytterhoeven
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=1376929831-18214-1-git-send-email-richard.genoud@gmail.com \
--to=richard.genoud@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®