ubifs: fixes for FS_IOC_GETFLAGS and FS_IOC_SETFLAGS
Subsystems (5)
Eric Biggers
maintainercover ubifs: fixes for FS_IOC_GETFLAGS and FS_IOC_SETFLAGS
On ubifs, fix FS_IOC_SETFLAGS to not clear the encrypt flag, and update FS_IOC_GETFLAGS to return the encrypt flag like ext4 and f2fs do.
Eric Biggers (2):
ubifs: fix FS_IOC_SETFLAGS unexpectedly clearing encrypt flag
ubifs: add support for FS_ENCRYPT_FL
fs/ubifs/ioctl.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
Signature · 1 line
2.24.0.393.g34dc348eaf-goog
Eric Biggers
maintainerPATCH 1/2 ubifs: fix FS_IOC_SETFLAGS unexpectedly clearing encrypt flag
From: Eric Biggers <[email protected]>
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--- fs/ubifs/ioctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ubifs/ioctl.c +2 -1
@@ -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;
Signature · 1 line
2.24.0.393.g34dc348eaf-goog
Sasha Levin
maintainerRe: [PATCH 1/2] ubifs: fix FS_IOC_SETFLAGS unexpectedly clearing encrypt flag
Hi,
[This is an automated email]
This commit has been processed because it contains a "Fixes:" tag, fixing commit: d475a507457b ("ubifs: Add skeleton for fscrypto").
The bot has tested the following trees: v5.4.2, v5.3.15, v4.19.88, v4.14.158.
v5.4.2: Build OK!
v5.3.15: Build OK!
v4.19.88: Build failed! Errors:
fs/ubifs/ioctl.c:130:28: error: ‘UBIFS_SUPPORTED_IOCTL_FLAGS’ undeclared (first use in this function)
v4.14.158: Build failed! Errors:
fs/ubifs/ioctl.c:127:28: error: ‘UBIFS_SUPPORTED_IOCTL_FLAGS’ undeclared (first use in this function)
NOTE: The patch will not be queued to stable trees until it is upstream.
How should we proceed with this patch?
Signature · 2 lines
Thanks, Sasha
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Eric Biggers
maintainerRe: [PATCH 1/2] ubifs: fix FS_IOC_SETFLAGS unexpectedly clearing encrypt flag
Quoted 14 lines · Sasha Levin
Hi,
[This is an automated email]
This commit has been processed because it contains a "Fixes:" tag, fixing commit:
d475a507457b("ubifs: Add skeleton for fscrypto").The bot has tested the following trees: v5.4.2, v5.3.15, v4.19.88, v4.14.158.
v5.4.2: Build OK!
v5.3.15: Build OK!
v4.19.88: Build failed! Errors:
fs/ubifs/ioctl.c:130:28: error: ‘UBIFS_SUPPORTED_IOCTL_FLAGS’ undeclared (first use in this function)
Quoted 8 lines
v4.14.158: Build failed! Errors:
fs/ubifs/ioctl.c:127:28: error: ‘UBIFS_SUPPORTED_IOCTL_FLAGS’ undeclared (first use in this function)NOTE: The patch will not be queued to stable trees until it is upstream.
How should we proceed with this patch?
4.19 and 4.14 will build if you apply commit 2fe8b2d5578d ("ubifs: Reject unsupported ioctl flags explicitly") first. That was a bug fix too, so I recommend applying it.
- Eric
Eric Biggers
maintainerPATCH 2/2 ubifs: add support for FS_ENCRYPT_FL
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Make the FS_IOC_GETFLAGS ioctl on ubifs return the FS_ENCRYPT_FL flag on encrypted files, like ext4 and f2fs do.
Also make this flag be ignored by FS_IOC_SETFLAGS, like ext4 and f2fs do, since it's a recognized flag but is not directly settable.
--- fs/ubifs/ioctl.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
fs/ubifs/ioctl.c +10 -3
@@ -17,10 +17,14 @@#include "ubifs.h" /* Need to be kept consistent with checked flags in ioctl2ubifs() */ -#define UBIFS_SUPPORTED_IOCTL_FLAGS \ +#define UBIFS_SETTABLE_IOCTL_FLAGS \ (FS_COMPR_FL | FS_SYNC_FL | FS_APPEND_FL | \ FS_IMMUTABLE_FL | FS_DIRSYNC_FL) +/* Need to be kept consistent with checked flags in ubifs2ioctl() */ +#define UBIFS_GETTABLE_IOCTL_FLAGS \ + (UBIFS_SETTABLE_IOCTL_FLAGS | FS_ENCRYPT_FL) +/** * ubifs_set_inode_flags - set VFS inode flags. * @inode: VFS inode to set flags for
@@ -91,6 +95,8 @@ static int ubifs2ioctl(int ubifs_flags) ioctl_flags |=FS_IMMUTABLE_FL ;if (ubifs_flags &UBIFS_DIRSYNC_FL ) ioctl_flags |=FS_DIRSYNC_FL ; +if (ubifs_flags &UBIFS_CRYPT_FL ) + ioctl_flags |=FS_ENCRYPT_FL ;return ioctl_flags; }
@@ -113,7 +119,7 @@ static int setflags(struct inode *inode, int flags)if (err) goto out_unlock; - ui->flags &= ~ioctl2ubifs (UBIFS_SUPPORTED_IOCTL_FLAGS ); + ui->flags &= ~ioctl2ubifs (UBIFS_SETTABLE_IOCTL_FLAGS ); ui->flags |=ioctl2ubifs (flags);ubifs_set_inode_flags (inode); inode->i_ctime =current_time (inode);
@@ -156,8 +162,9 @@ long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)if (get_user (flags, (int __user *) arg))return -EFAULT ; -if (flags & ~UBIFS_SUPPORTED_IOCTL_FLAGS ) +if (flags & ~UBIFS_GETTABLE_IOCTL_FLAGS )return -EOPNOTSUPP ; + flags &=UBIFS_SETTABLE_IOCTL_FLAGS ;if (!S_ISDIR (inode->i_mode)) flags &= ~FS_DIRSYNC_FL ;
Signature · 1 line
2.24.0.393.g34dc348eaf-goog
Eric Biggers
maintainerQuoted 10 lines · Eric Biggers
On ubifs, fix
FS_IOC_SETFLAGSto not clear the encrypt flag, and updateFS_IOC_GETFLAGSto return the encrypt flag like ext4 and f2fs do.Eric Biggers (2):
ubifs: fixFS_IOC_SETFLAGSunexpectedly clearing encrypt flag
ubifs: add support forFS_ENCRYPT_FLfs/ubifs/ioctl.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
Richard, can you consider applying this series to the UBIFS tree for 5.6?
- Eric
Eric Biggers
maintainerQuoted 9 lines · Eric Biggers
On ubifs, fix
FS_IOC_SETFLAGSto not clear the encrypt flag, and updateFS_IOC_GETFLAGSto return the encrypt flag like ext4 and f2fs do.Eric Biggers (2):
ubifs: fixFS_IOC_SETFLAGSunexpectedly clearing encrypt flag
ubifs: add support forFS_ENCRYPT_FLfs/ubifs/ioctl.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
Richard, have you had a chance to review these? I'm intending that these be taken through the UBIFS tree too.
- Eric
Richard Weinberger
maintainer----- Ursprüngliche Mail -----
Quoted 15 lines
Von: "Eric Biggers" <[email protected]>
An: "richard" <[email protected]>
CC: "linux-mtd" <[email protected]>, "linux-fscrypt" <[email protected]>, "linux-fsdevel" <[email protected]>
Gesendet: Dienstag, 14. Januar 2020 23:00:17
Betreff: Re: [PATCH 0/2] ubifs: fixes forFS_IOC_GETFLAGSandFS_IOC_SETFLAGSQuoted 7 lines · Eric Biggers
On ubifs, fix
FS_IOC_SETFLAGSto not clear the encrypt flag, and updateFS_IOC_GETFLAGSto return the encrypt flag like ext4 and f2fs do.Eric Biggers (2):
ubifs: fixFS_IOC_SETFLAGSunexpectedly clearing encrypt flag
ubifs: add support forFS_ENCRYPT_FL
Quoted 5 lines
Quoted 2 lines
fs/ubifs/ioctl.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)Richard, have you had a chance to review these? I'm intending that these be taken through the UBIFS tree too.
It is in my review queue. Didn't I update the patch state in patchwork (me double checks)?
Thanks,
//richard
Quoted 22 lines · Richard Weinberger
----- Ursprüngliche Mail -----
Quoted 20 lines
Von: "Eric Biggers" <[email protected]>
An: "richard" <[email protected]>
CC: "linux-mtd" <[email protected]>, "linux-fscrypt" <[email protected]>, "linux-fsdevel" <[email protected]>
Gesendet: Dienstag, 14. Januar 2020 23:00:17
Betreff: Re: [PATCH 0/2] ubifs: fixes forFS_IOC_GETFLAGSandFS_IOC_SETFLAGSQuoted 9 lines · Eric Biggers
On ubifs, fix
FS_IOC_SETFLAGSto not clear the encrypt flag, and updateFS_IOC_GETFLAGSto return the encrypt flag like ext4 and f2fs do.Eric Biggers (2):
ubifs: fixFS_IOC_SETFLAGSunexpectedly clearing encrypt flag
ubifs: add support forFS_ENCRYPT_FLfs/ubifs/ioctl.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)Richard, have you had a chance to review these? I'm intending that these be taken through the UBIFS tree too.
Both applied. Thanks a lot for addressing this, Eric.
Signature · 6 lines
Thanks, //richard ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/