From: Arun KS <arunks.linux@gmail.com>
To: viro@zeniv.linux.org.uk, Andrew Morton <akpm@linux-foundation.org>
Cc: Matthew Wilcox <matthew@wil.cx>,
Bruce Fields <bfields@fieldses.org>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
vinayak menon <vinayakm.list@gmail.com>,
Nagachandra P <nagachandra@gmail.com>,
Vikram MP <mp.vikram@gmail.com>
Subject: Re: [PATCH] SeqFile: Fix overflow condition
Date: Mon, 19 Aug 2013 17:00:14 +0530 [thread overview]
Message-ID: <CAKZGPAPdqgJJnrWo-nzwm2CiCA4405iuB-Tco25j4JDB6qQPRg@mail.gmail.com> (raw)
In-Reply-To: <CAKZGPANS-NVTy7p69xcrgK3ggUHAtLi2ad8UgwsYdeEHbj3gMw@mail.gmail.com>
Please ignore this patch.
I ll send an updated one.
Thanks,
Arun
On Mon, Aug 19, 2013 at 12:25 PM, Arun KS <arunks.linux@gmail.com> wrote:
> From 23986a85b9efe7bc3ffc0887b8d17cdf2fbab4f2 Mon Sep 17 00:00:00 2001
> From: Arun KS <arun.ks@broadcom.com>
> Date: Mon, 19 Aug 2013 12:06:33 +0530
> Subject: SeqFile: Fix overflow condition
>
> seq_path()/seq_commit() is treating a d_path() failure as an overflow
> condition, but it isn't.
>
> Signed-off-by: Arun KS <arun.ks@broadcom.com>
> ---
> fs/seq_file.c | 6 +++---
> include/linux/seq_file.h | 11 ++++++-----
> 2 files changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/fs/seq_file.c b/fs/seq_file.c
> index 3135c25..6a33f9c 100644
> --- a/fs/seq_file.c
> +++ b/fs/seq_file.c
> @@ -463,7 +463,7 @@ int seq_path(struct seq_file *m, const struct path
> *path, const char *esc)
> {
> char *buf;
> size_t size = seq_get_buf(m, &buf);
> - int res = -1;
> + int res = -ENOBUFS;
>
> if (size) {
> char *p = d_path(path, buf, size);
> @@ -487,7 +487,7 @@ int seq_path_root(struct seq_file *m, const struct
> path *path,
> {
> char *buf;
> size_t size = seq_get_buf(m, &buf);
> - int res = -ENAMETOOLONG;
> + int res = -ENOBUFS;
>
> if (size) {
> char *p;
> @@ -516,7 +516,7 @@ int seq_dentry(struct seq_file *m, struct dentry
> *dentry, const char *esc)
> {
> char *buf;
> size_t size = seq_get_buf(m, &buf);
> - int res = -1;
> + int res = -ENOBUFS;
>
> if (size) {
> char *p = dentry_path(dentry, buf, size);
> diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
> index 4e32edc..7bfb540 100644
> --- a/include/linux/seq_file.h
> +++ b/include/linux/seq_file.h
> @@ -66,16 +66,17 @@ static inline size_t seq_get_buf(struct seq_file
> *m, char **bufp)
> * @num: the number of bytes to commit
> *
> * Commit @num bytes of data written to a buffer previously acquired
> - * by seq_buf_get. To signal an error condition, or that the data
> - * didn't fit in the available space, pass a negative @num value.
> + * by seq_buf_get. To signal an overflow condition(data didn't fit
> + * in the available space), pass -ENOBUFS and for other errors pass a
> + * negative @num value.
> */
> static inline void seq_commit(struct seq_file *m, int num)
> {
> - if (num < 0) {
> - m->count = m->size;
> - } else {
> + if (num >= 0) {
> BUG_ON(m->count + num > m->size);
> m->count += num;
> + } else if (num == -ENOBUFS)
> + m->count = m->size;
> }
> }
>
> --
> 1.8.2
next prev parent reply other threads:[~2013-08-19 11:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-19 6:55 [PATCH] SeqFile: Fix overflow condition Arun KS
2013-08-19 11:30 ` Arun KS [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-08-19 11:32 Arun KS
2013-08-19 23:05 ` Andrew Morton
2013-08-20 5:23 ` Arun KS
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=CAKZGPAPdqgJJnrWo-nzwm2CiCA4405iuB-Tco25j4JDB6qQPRg@mail.gmail.com \
--to=arunks.linux@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=bfields@fieldses.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=mp.vikram@gmail.com \
--cc=nagachandra@gmail.com \
--cc=vinayakm.list@gmail.com \
--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;
as well as URLs for NNTP newsgroup(s).