Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

autofs: fix thinko in validate_dev_ioctl()

I was so sure the per-dentry expire timeout patch worked ok but my
testing was flawed.

In validate_dev_ioctl() the check for ioctl AUTOFS_DEV_IOCTL_TIMEOUT_CMD
should use the ioctl number not the passed in ioctl command.

Fixes: 433f9d76a010 ("autofs: add per dentry expire timeout")
Cc: <stable@vger.kernel.org> # mainline only
Signed-off-by: Ian Kent <raven@themaw.net>
Link: https://lore.kernel.org/r/20241027224732.5507-1-raven@themaw.net
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Ian Kent and committed by
Christian Brauner
f1991000 e65a0dc1

+2 -3
+2 -3
fs/autofs/dev-ioctl.c
··· 110 110 */ 111 111 static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param) 112 112 { 113 + unsigned int inr = _IOC_NR(cmd); 113 114 int err; 114 115 115 116 err = check_dev_ioctl_version(cmd, param); ··· 134 133 * check_name() return for AUTOFS_DEV_IOCTL_TIMEOUT_CMD. 135 134 */ 136 135 err = check_name(param->path); 137 - if (cmd == AUTOFS_DEV_IOCTL_TIMEOUT_CMD) 136 + if (inr == AUTOFS_DEV_IOCTL_TIMEOUT_CMD) 138 137 err = err ? 0 : -EINVAL; 139 138 if (err) { 140 139 pr_warn("invalid path supplied for cmd(0x%08x)\n", ··· 142 141 goto out; 143 142 } 144 143 } else { 145 - unsigned int inr = _IOC_NR(cmd); 146 - 147 144 if (inr == AUTOFS_DEV_IOCTL_OPENMOUNT_CMD || 148 145 inr == AUTOFS_DEV_IOCTL_REQUESTER_CMD || 149 146 inr == AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD) {