diff options
author | Eric Biggers <ebiggers@google.com> | 2019-12-09 14:23:24 -0800 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2020-01-16 23:35:31 +0100 |
commit | 2b57067a7778484c10892fa191997bfda29fea13 (patch) | |
tree | 84b7e2e1f6dee337e382de6c0ed4434ad545c046 /fs/ubifs/ioctl.c | |
parent | 770aa73d8965b6fe7b08b0e5a8f4cceb4cb17f12 (diff) | |
download | linux-stable-2b57067a7778484c10892fa191997bfda29fea13.tar.gz linux-stable-2b57067a7778484c10892fa191997bfda29fea13.tar.bz2 linux-stable-2b57067a7778484c10892fa191997bfda29fea13.zip |
ubifs: Fix FS_IOC_SETFLAGS unexpectedly clearing encrypt flag
UBIFS's implementation of FS_IOC_SETFLAGS fails to preserve existing
inode flags that aren't settable by FS_IOC_SETFLAGS, namely the encrypt
flag. This causes the encrypt flag to be unexpectedly cleared.
Fix it by preserving existing unsettable flags, like ext4 and f2fs do.
Test case with kvm-xfstests shell:
FSTYP=ubifs KEYCTL_PROG=keyctl
. fs/ubifs/config
. ~/xfstests/common/encrypt
dev=$(__blkdev_to_ubi_volume /dev/vdc)
ubiupdatevol -t $dev
mount $dev /mnt -t ubifs
k=$(_generate_session_encryption_key)
mkdir /mnt/edir
xfs_io -c "set_encpolicy $k" /mnt/edir
echo contents > /mnt/edir/file
chattr +i /mnt/edir/file
chattr -i /mnt/edir/file
With the bug, the following errors occur on the last command:
[ 18.081559] fscrypt (ubifs, inode 67): Inconsistent encryption context (parent directory: 65)
chattr: Operation not permitted while reading flags on /mnt/edir/file
Fixes: d475a507457b ("ubifs: Add skeleton for fscrypto")
Cc: <stable@vger.kernel.org> # v4.10+
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'fs/ubifs/ioctl.c')
-rw-r--r-- | fs/ubifs/ioctl.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c index 5dc5abca11c7..eeb1be259888 100644 --- a/fs/ubifs/ioctl.c +++ b/fs/ubifs/ioctl.c @@ -113,7 +113,8 @@ static int setflags(struct inode *inode, int flags) if (err) goto out_unlock; - ui->flags = ioctl2ubifs(flags); + ui->flags &= ~ioctl2ubifs(UBIFS_SUPPORTED_IOCTL_FLAGS); + ui->flags |= ioctl2ubifs(flags); ubifs_set_inode_flags(inode); inode->i_ctime = current_time(inode); release = ui->dirty; |