Skip to content
Commit f7db5e76 authored by Ming Lei's avatar Ming Lei Committed by Greg Kroah-Hartman
Browse files

sysfs: fix use after free in case of concurrent read/write and readdir

The inode->i_mutex isn't hold when updating filp->f_pos
in read()/write(), so the filp->f_pos might be read as
0 or 1 in readdir() when there is concurrent read()/write()
on this same file, then may cause use after free in readdir().

The bug can be reproduced with Li Zefan's test code on the
link:

	https://patchwork.kernel.org/patch/2160771/



This patch fixes the use after free under this situation.

Cc: stable <stable@vger.kernel.org>
Reported-by: default avatarLi Zefan <lizefan@huawei.com>
Signed-off-by: default avatarMing Lei <ming.lei@canonical.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0f8b1a02
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment