WSL2-Linux-Kernel/fs/ext2
Andreas Gruenbacher b8a7a3a667 posix_acl: Inode acl caching fixes
When get_acl() is called for an inode whose ACL is not cached yet, the
get_acl inode operation is called to fetch the ACL from the filesystem.
The inode operation is responsible for updating the cached acl with
set_cached_acl().  This is done without locking at the VFS level, so
another task can call set_cached_acl() or forget_cached_acl() before the
get_acl inode operation gets to calling set_cached_acl(), and then
get_acl's call to set_cached_acl() results in caching an outdate ACL.

Prevent this from happening by setting the cached ACL pointer to a
task-specific sentinel value before calling the get_acl inode operation.
Move the responsibility for updating the cached ACL from the get_acl
inode operations to get_acl().  There, only set the cached ACL if the
sentinel value hasn't changed.

The sentinel values are chosen to have odd values.  Likewise, the value
of ACL_NOT_CACHED is odd.  In contrast, ACL object pointers always have
an even value (ACLs are aligned in memory).  This allows to distinguish
uncached ACLs values from ACL objects.

In addition, switch from guarding inode->i_acl and inode->i_default_acl
upates by the inode->i_lock spinlock to using xchg() and cmpxchg().

Filesystems that do not want ACLs returned from their get_acl inode
operations to be cached must call forget_cached_acl() to prevent the VFS
from doing so.

(Patch written by Al Viro and Andreas Gruenbacher.)

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2016-03-31 00:30:15 -04:00
..
Kconfig vfs,ext2: remove CONFIG_EXT2_FS_XIP and rename CONFIG_FS_XIP to CONFIG_FS_DAX 2015-02-16 17:56:04 -08:00
Makefile ext2: remove xip.c and xip.h 2015-02-16 17:56:03 -08:00
acl.c posix_acl: Inode acl caching fixes 2016-03-31 00:30:15 -04:00
acl.h ext2/3/4: use generic posix ACL infrastructure 2014-01-25 23:58:19 -05:00
balloc.c Ext2: remove the static function release_blocks to optimize the kernel 2013-02-07 16:44:56 +01:00
dir.c pagemap.h: move dir_pages() over there 2015-06-23 18:02:00 -04:00
ext2.h mbcache2: rename to mbcache 2016-02-22 22:35:22 -05:00
file.c ext2, ext4: fix issue with missing journal entry in ext4_dax_mkwrite() 2016-02-27 14:01:16 -05:00
ialloc.c ext2: Handle error from dquot_initalize() 2015-07-23 20:59:37 +02:00
inode.c dax: move writeback calls into the filesystems 2016-02-27 10:28:52 -08:00
ioctl.c wrappers for ->i_mutex access 2016-01-22 18:04:28 -05:00
namei.c don't put symlink bodies in pagecache into highmem 2015-12-08 22:41:36 -05:00
super.c ext2: convert to mbcache2 2016-02-22 11:56:38 -05:00
symlink.c switch ->get_link() to delayed_call, kill ->put_link() 2015-12-30 13:01:03 -05:00
xattr.c mbcache: add reusable flag to cache entries 2016-02-22 22:44:04 -05:00
xattr.h mbcache2: rename to mbcache 2016-02-22 22:35:22 -05:00
xattr_security.c xattr handlers: Simplify list operation 2015-12-13 19:46:12 -05:00
xattr_trusted.c xattr handlers: Simplify list operation 2015-12-13 19:46:12 -05:00
xattr_user.c xattr handlers: Simplify list operation 2015-12-13 19:46:12 -05:00