Skip to contentSkip to conversation

ext4: disallow files with EXT4_JOURNAL_DATA_FL from EXT4_IOC_SWAP_BOOT

PATCH In review Theodore Ts'o 2 participants 2 messages Feb 11, 2019 – Feb 12, 2019 ext4 file system

lore
Share & tools
lore

Theodore Ts'o

author maintainer
#0 lore raw

PATCH 1/1 ext4: disallow files with EXT4_JOURNAL_DATA_FL from EXT4_IOC_SWAP_BOOT

A malicious/clueless root user can use EXT4_IOC_SWAP_BOOT to force a corner casew which can lead to the file system getting corrupted. There's no usefulness to allowing this, so just prohibit this case.

---
 fs/ext4/ioctl.c | 1 +
 1 file changed, 1 insertion(+)
fs/ext4/ioctl.c +1 -0
index 2e76fb55d94a..eb8ca8d80885 100644
@@ -132,6 +132,7 @@ static long swap_inode_boot_loader(struct super_block *sb,
 
 	if (inode->i_nlink != 1 || !S_ISREG(inode->i_mode) ||
 	    IS_SWAPFILE(inode) || IS_ENCRYPTED(inode) ||
+	    (EXT4_I(inode)->i_flags & EXT4_JOURNAL_DATA_FL) ||
 	    ext4_has_inline_data(inode)) {
 		err = -EINVAL;
 		goto journal_err_out;
Signature · 1 line
2.19.1
Reviewed-by on v1 1/1
#1 lore raw

Theodore Ts'o wrote on 2019/2/11 14:15:

Quoted 22 lines

A malicious/clueless root user can use EXT4_IOC_SWAP_BOOT to force a corner casew which can lead to the file system getting corrupted. There's no usefulness to allowing this, so just prohibit this case.

---
  fs/ext4/ioctl.c | 1 +
  1 file changed, 1 insertion(+)
fs/ext4/ioctl.c +1 -0
index 2e76fb55d94a..eb8ca8d80885 100644
@@ -132,6 +132,7 @@ static long swap_inode_boot_loader(struct super_block *sb,
 
  	if (inode->i_nlink != 1 || !S_ISREG(inode->i_mode) ||
  	    IS_SWAPFILE(inode) || IS_ENCRYPTED(inode) ||
+	    (EXT4_I(inode)->i_flags & EXT4_JOURNAL_DATA_FL) ||
  	    ext4_has_inline_data(inode)) {
  		err = -EINVAL;
  		goto journal_err_out;