Skip to content

Commit 02f51d4

Browse files
Tomas Bortolitorvalds
authored andcommitted
autofs: fix slab out of bounds read in getname_kernel()
The autofs subsystem does not check that the "path" parameter is present for all cases where it is required when it is passed in via the "param" struct. In particular it isn't checked for the AUTOFS_DEV_IOCTL_OPENMOUNT_CMD ioctl command. To solve it, modify validate_dev_ioctl(function to check that a path has been provided for ioctl commands that require it. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Tomas Bortoli <[email protected]> Signed-off-by: Ian Kent <[email protected]> Reported-by: [email protected] Cc: Dmitry Vyukov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent e70cc2b commit 02f51d4

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

fs/autofs/dev-ioctl.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,15 @@ static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param)
135135
cmd);
136136
goto out;
137137
}
138+
} else {
139+
unsigned int inr = _IOC_NR(cmd);
140+
141+
if (inr == AUTOFS_DEV_IOCTL_OPENMOUNT_CMD ||
142+
inr == AUTOFS_DEV_IOCTL_REQUESTER_CMD ||
143+
inr == AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD) {
144+
err = -EINVAL;
145+
goto out;
146+
}
138147
}
139148

140149
err = 0;
@@ -271,7 +280,8 @@ static int autofs_dev_ioctl_openmount(struct file *fp,
271280
dev_t devid;
272281
int err, fd;
273282

274-
/* param->path has already been checked */
283+
/* param->path has been checked in validate_dev_ioctl() */
284+
275285
if (!param->openmount.devid)
276286
return -EINVAL;
277287

@@ -433,10 +443,7 @@ static int autofs_dev_ioctl_requester(struct file *fp,
433443
dev_t devid;
434444
int err = -ENOENT;
435445

436-
if (param->size <= AUTOFS_DEV_IOCTL_SIZE) {
437-
err = -EINVAL;
438-
goto out;
439-
}
446+
/* param->path has been checked in validate_dev_ioctl() */
440447

441448
devid = sbi->sb->s_dev;
442449

@@ -521,10 +528,7 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp,
521528
unsigned int devid, magic;
522529
int err = -ENOENT;
523530

524-
if (param->size <= AUTOFS_DEV_IOCTL_SIZE) {
525-
err = -EINVAL;
526-
goto out;
527-
}
531+
/* param->path has been checked in validate_dev_ioctl() */
528532

529533
name = param->path;
530534
type = param->ismountpoint.in.type;

0 commit comments

Comments
 (0)