From: Dan Williams <dan.j.williams@intel.com>
To: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>,
aleksey.obitotskiy@intel.com, "Baldysiak,
Pawel" <pawel.baldysiak@intel.com>,
Artur Paszkiewicz <artur.paszkiewicz@intel.com>,
maksymilian.kunt@intel.com, Al Viro <viro@zeniv.linux.org.uk>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] seq_file: don't set read position for invalid iterator
Date: Fri, 23 Sep 2016 08:54:12 -0700 [thread overview]
Message-ID: <CAA9_cme1nw9VixkC7jJD0uzprmPC57VBgYgRN6RArdiyTofXMQ@mail.gmail.com> (raw)
In-Reply-To: <1471943977-17822-1-git-send-email-tomasz.majchrzak@intel.com>
[ adding Al ]
On Tue, Aug 23, 2016 at 2:19 AM, Tomasz Majchrzak
<tomasz.majchrzak@intel.com> wrote:
> If kernfs file is empty on a first read, successive read operations
> using the same file descriptor will return no data, even when data is
> available. Default kernfs 'seq_next' implementation advances iterator
> position even when next object is not there. Kernfs 'seq_start' for
> following requests will not return iterator as position is already on
> the second object.
>
> Don't set read position if valid iterator has not been returned.
Can you say a bit about how you found this? So we have an idea about
userspace tooling is broken by this bug.
>
> Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
I would add "Cc: <stable@vger.kernel.org>" to the next version of this patch.
> fs/seq_file.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/seq_file.c b/fs/seq_file.c
> index 19f532e..893db43 100644
> --- a/fs/seq_file.c
> +++ b/fs/seq_file.c
> @@ -242,7 +242,8 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
> m->count = 0;
> if (unlikely(!m->count)) {
> p = m->op->next(m, p, &pos);
> - m->index = pos;
> + if (p && !IS_ERR(p))
Lets change this to use the IS_ERR_OR_NULL() helper, and do the same
with the earlier if (!p || IS_ERR()) a few lines up in the loop.
Other than that, this looks good to me.
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
prev parent reply other threads:[~2016-09-23 15:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-23 9:19 [PATCH] seq_file: don't set read position for invalid iterator Tomasz Majchrzak
2016-09-23 15:54 ` Dan Williams [this message]
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=CAA9_cme1nw9VixkC7jJD0uzprmPC57VBgYgRN6RArdiyTofXMQ@mail.gmail.com \
--to=dan.j.williams@intel.com \
--cc=aleksey.obitotskiy@intel.com \
--cc=artur.paszkiewicz@intel.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maksymilian.kunt@intel.com \
--cc=pawel.baldysiak@intel.com \
--cc=tomasz.majchrzak@intel.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).