From: Li Zefan <lizefan@huawei.com>
To: Ming Lei <ming.lei@canonical.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
<linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH 1/2] sysfs: fix race between readdir and lseek
Date: Thu, 21 Mar 2013 10:41:04 +0800 [thread overview]
Message-ID: <514A7340.5040409@huawei.com> (raw)
In-Reply-To: <1363793126-11510-2-git-send-email-ming.lei@canonical.com>
On 2013/3/20 23:25, Ming Lei wrote:
> While readdir() is running, lseek() may set filp->f_pos as zero,
> then may leave filp->private_data pointing to one sysfs_dirent
> object without holding its reference counter, so the sysfs_dirent
> object may be used after free in next readdir().
>
> This patch holds inode->i_mutex to avoid the problem since
> the lock is always held in readdir path.
>
In fact the same race exists between readdir() and read()/write()...
> Reported-by: Dave Jones <davej@redhat.com>
> Tested-by: Sasha Levin <levinsasha928@gmail.com>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Ming Lei <ming.lei@canonical.com>
> ---
> fs/sysfs/dir.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
next prev parent reply other threads:[~2013-03-21 2:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-20 15:25 [PATCH 0/2] sysfs: fix use after free in sysfs_readdir() Ming Lei
2013-03-20 15:25 ` [PATCH 1/2] sysfs: fix race between readdir and lseek Ming Lei
2013-03-21 2:41 ` Li Zefan [this message]
2013-03-21 3:17 ` Ming Lei
2013-03-21 3:28 ` Li Zefan
2013-03-21 4:48 ` Ming Lei
2013-03-22 5:48 ` Li Zefan
2013-03-22 9:31 ` Ming Lei
2013-03-26 7:30 ` Li Zefan
2013-03-26 8:45 ` Ming Lei
2013-03-26 14:03 ` Ming Lei
2013-03-26 15:59 ` Ming Lei
2013-03-20 15:25 ` [PATCH 2/2] sysfs: handle failure path correctly for readdir() Ming Lei
2013-03-20 16:26 ` Shuah Khan
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=514A7340.5040409@huawei.com \
--to=lizefan@huawei.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@canonical.com \
--cc=stable@vger.kernel.org \
/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.