fs: Fix S_NOSEC handling
commitdf93988e8b5cd9fe6b1b73c5da668d7e0ca018a4
authorJan Kara <jack@suse.cz>
Thu, 21 May 2015 14:05:52 +0000 (21 16:05 +0200)
committerSasha Levin <sasha.levin@oracle.com>
Mon, 13 Jul 2015 12:50:03 +0000 (13 08:50 -0400)
tree67f625116dd2788127ae4dd1bf0cf5586de37ac3
parentc215cf258214858a5a6c3e63cd7ee78b92d210b2
fs: Fix S_NOSEC handling

[ Upstream commit 2426f3910069ed47c0cc58559a6d088af7920201 ]

file_remove_suid() could mistakenly set S_NOSEC inode bit when root was
modifying the file. As a result following writes to the file by ordinary
user would avoid clearing suid or sgid bits.

Fix the bug by checking actual mode bits before setting S_NOSEC.

CC: stable@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
fs/inode.c