Skip to content

Commit f09ff30

Browse files
leocstonepcmoore
authored andcommitted
safesetid: check size of policy writes
syzbot attempts to write a buffer with a large size to a sysfs entry with writes handled by handle_policy_update(), triggering a warning in kmalloc. Check the size specified for write buffers before allocating. Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=4eb7a741b3216020043a Signed-off-by: Leo Stone <[email protected]> [PM: subject tweak] Signed-off-by: Paul Moore <[email protected]>
1 parent 3b44cd0 commit f09ff30

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

security/safesetid/securityfs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ static ssize_t handle_policy_update(struct file *file,
143143
char *buf, *p, *end;
144144
int err;
145145

146+
if (len >= KMALLOC_MAX_SIZE)
147+
return -EINVAL;
148+
146149
pol = kmalloc(sizeof(struct setid_ruleset), GFP_KERNEL);
147150
if (!pol)
148151
return -ENOMEM;

0 commit comments

Comments
 (0)