From: "Theodore Ts'o" <tytso@mit.edu>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Subject: [PATCH 07/23] ext4: pass missing ioctls through ext4_compat_ioctl
Date: Wed, 11 Nov 2026 23:46:56 -0500 [thread overview]
Message-ID: <20261112044712.1577296-8-tytso@mit.edu> (raw)
In-Reply-To: <20261112044712.1577296-1-tytso@mit.edu>
ext4_compat_ioctl() only forwards an explicit allow-list of commands
to ext4_ioctl() and returns -ENOIOCTLCMD for everything else. Several
commands were never added to that list:
EXT4_IOC_MIGRATE
EXT4_IOC_ALLOC_DA_BLKS
EXT4_IOC_SWAP_BOOT
EXT4_IOC_GET_TUNE_SB_PARAM
EXT4_IOC_SET_TUNE_SB_PARAM
As a result, 32-bit userspace running on a 64-bit kernel (for example
a 32-bit tune2fs or e4defrag) gets -ENOTTY for these ioctls, even
though they work for native 64-bit callers.
None of these commands needs any translation: MIGRATE, ALLOC_DA_BLKS
and SWAP_BOOT are _IO() commands that ignore their argument, and
struct ext4_tune_sb_params consists only of fixed-size __u8/__u16/
__u32/__u64 members whose layout is identical for 32-bit and 64-bit
ABIs (its __u64 members are naturally aligned at offsets 16, 24 and
32, and the structure size is 232 bytes on both). The ioctl numbers
therefore encode the same size, and the commands can simply be passed
through to ext4_ioctl() with compat_ptr() applied to the argument.
Add the missing commands to the pass-through list and extend the
ioctl dispatch KUnit test to check that the compat handler forwards
them (when CONFIG_COMPAT is enabled).
Fixes: c14c6fd5c56a ("ext4: Add EXT4_IOC_MIGRATE ioctl")
Fixes: ccd2506bd431 ("ext4: add EXT4_IOC_ALLOC_DA_BLKS ioctl")
Fixes: 393d1d1d7693 ("ext4: implementation of a new ioctl called EXT4_IOC_SWAP_BOOT")
Fixes: 04a91570ac67 ("ext4: implemet new ioctls to set and get superblock parameters")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
fs/ext4/ioctl-test.c | 19 +++++++++++++++++++
fs/ext4/ioctl.c | 5 +++++
2 files changed, 24 insertions(+)
diff --git a/fs/ext4/ioctl-test.c b/fs/ext4/ioctl-test.c
index 831b7e032fad..8afeccc755f6 100644
--- a/fs/ext4/ioctl-test.c
+++ b/fs/ext4/ioctl-test.c
@@ -1423,6 +1423,25 @@ static void test_force_shutdown_and_ioctl_dispatch(struct kunit *test)
-EBADF);
KUNIT_EXPECT_EQ(test, ext4_ioctl(&filp, EXT4_IOC_SWAP_BOOT, 0),
-EBADF);
+#ifdef CONFIG_COMPAT
+ /*
+ * Architecture-neutral commands must be passed through by
+ * the compat handler instead of failing with -ENOIOCTLCMD.
+ */
+ KUNIT_EXPECT_EQ(test,
+ ext4_compat_ioctl(&filp, EXT4_IOC_SWAP_BOOT, 0),
+ -EBADF);
+ KUNIT_EXPECT_EQ(test,
+ ext4_compat_ioctl(&filp,
+ EXT4_IOC_GET_TUNE_SB_PARAM,
+ 0),
+ -EFAULT);
+ KUNIT_EXPECT_EQ(test,
+ ext4_compat_ioctl(&filp,
+ EXT4_IOC_SET_TUNE_SB_PARAM,
+ 0),
+ -EFAULT);
+#endif
filp.f_mode = FMODE_READ | FMODE_WRITE;
/* EXT4_IOC_CLEAR_ES_CACHE empties inode extent status tree */
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 9e2bde83a033..d6f47ff00e61 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -2064,6 +2064,11 @@ long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
case FS_IOC_SETFSLABEL:
case EXT4_IOC_GETFSUUID:
case EXT4_IOC_SETFSUUID:
+ case EXT4_IOC_GET_TUNE_SB_PARAM:
+ case EXT4_IOC_SET_TUNE_SB_PARAM:
+ case EXT4_IOC_MIGRATE:
+ case EXT4_IOC_ALLOC_DA_BLKS:
+ case EXT4_IOC_SWAP_BOOT:
break;
default:
return -ENOIOCTLCMD;
--
2.56.0.542.g3ef89b7020-goog
next prev parent reply other threads:[~2026-11-12 4:47 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 4:46 [PATCH 00/23] ext4: lots of misc bug fixes Theodore Ts'o
2026-11-12 4:46 ` [PATCH 01/23] ext4: only update s_mount_opts when EXT4_TUNE_FL_MOUNT_OPTS is set Theodore Ts'o
2026-11-12 4:46 ` [PATCH 02/23] ext4: return -EFSBADCRC when skipping a corrupt backup superblock Theodore Ts'o
2026-11-12 4:46 ` [PATCH 03/23] ext4: don't allow enabling casefold via EXT4_IOC_SET_TUNE_SB_PARAM Theodore Ts'o
2026-11-12 4:46 ` [PATCH 04/23] ext4: persist the htree hash seed when enabling dir_index online Theodore Ts'o
2026-11-12 4:46 ` [PATCH 05/23] ext4: enforce feature prerequisites when tuning a mounted fs Theodore Ts'o
2026-11-12 4:46 ` [PATCH 06/23] ext4: handle s_lastcheck_hi in the get/set tune superblock ioctls Theodore Ts'o
2026-11-12 4:46 ` Theodore Ts'o [this message]
2026-11-12 4:46 ` [PATCH 08/23] ext4: fix inverted err_report_sec check in ext4_update_super() Theodore Ts'o
2026-11-12 4:46 ` [PATCH 09/23] ext4: fix err_report_sec_store() timer and value handling Theodore Ts'o
2026-11-12 4:46 ` [PATCH 10/23] ext4: fix inode table accounting in count_overhead() Theodore Ts'o
2026-11-12 4:47 ` [PATCH 11/23] ext4: handle flex groups straddling s_first_meta_bg in online resize Theodore Ts'o
2026-11-12 4:47 ` [PATCH 12/23] ext4: reject EXT4_IOC_GROUP_ADD inputs larger than a block group Theodore Ts'o
2026-11-12 4:47 ` [PATCH 13/23] ext4: propagate ext4_alloc_group_tables() errors from ext4_resize_fs() Theodore Ts'o
2026-11-12 4:47 ` [PATCH 14/23] ext4: reject online shrink before probing the device size Theodore Ts'o
2026-11-12 4:47 ` [PATCH 15/23] ext4: cap migrated extents at EXT_INIT_MAX_LEN Theodore Ts'o
2026-11-12 4:47 ` [PATCH 16/23] ext4: don't treat a handle restart as an error in finish_range() Theodore Ts'o
2026-11-12 4:47 ` [PATCH 17/23] ext4: don't clobber the migration result in ext4_ext_migrate() Theodore Ts'o
2026-11-12 4:47 ` [PATCH 18/23] ext4: fix EOF clamping of the range in mext_check_adjust_range() Theodore Ts'o
2026-11-12 4:47 ` [PATCH 19/23] ext4: bound the MMP update and check intervals Theodore Ts'o
2026-11-12 4:47 ` [PATCH 20/23] ext4: fix MMP claim of a cleanly unmounted filesystem Theodore Ts'o
2026-11-12 4:47 ` [PATCH 21/23] ext4: fix device comparison overflow in ext4_getfsmap_dev_compare() Theodore Ts'o
2026-11-12 4:47 ` [PATCH 22/23] ext4: don't allocate over indirect branches that failed to load Theodore Ts'o
2026-11-12 4:47 ` [PATCH 23/23] ext4: don't stop EXT4_IOC_GET_ES_CACHE at uncached ranges Theodore Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261112044712.1577296-8-tytso@mit.edu \
--to=tytso@mit.edu \
--cc=linux-ext4@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox