autofs4: check dev ioctl size before allocating
Subsystems (2)
PATCH 1/1 autofs4: check dev ioctl size before allocating
There wasn't any check of the size passed from userspace before trying to allocate the memory required.
This meant that userspace might request more space than allowed, triggering an OOM.
--- fs/autofs4/dev-ioctl.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
fs/autofs4/dev-ioctl.c +3 -0
@@ -103,6 +103,9 @@ static struct autofs_dev_ioctl *copy_dev_ioctl(struct autofs_dev_ioctl __user *iif (tmp.size <sizeof (tmp))return ERR_PTR (-EINVAL ); +if (tmp.size > (PATH_MAX +sizeof (tmp))) +return ERR_PTR (-E2BIG ); +return memdup_user (in, tmp.size); }
Signature · 1 line
1.7.2.5
Ping? Anyone wants to take this?
Quoted 26 lines · Sasha Levin
There wasn't any check of the size passed from userspace before trying to allocate the memory required.
This meant that userspace might request more space than allowed, triggering an OOM.
Signed-off-by Sasha Levin <[email protected]>--- fs/autofs4/dev-ioctl.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)fs/autofs4/dev-ioctl.c +3
-0@@ -103,6 +103,9 @@ static struct autofs_dev_ioctl *copy_dev_ioctl(struct autofs_dev_ioctl __user *iif (tmp.size <sizeof (tmp))return ERR_PTR (-EINVAL ); +if (tmp.size > (PATH_MAX +sizeof (tmp))) +return ERR_PTR (-E2BIG ); +return memdup_user (in, tmp.size); }
Ian Kent
maintainerQuoted 1 line · Sasha Levin
Ping? Anyone wants to take this?
Is this causing a problem for users?
If it is I'll send it to Andrew straight away.
I do have this on my queue but don't have any other patches to send so it's just sitting there.
If it worries you I'll send it to Andrew now.
Quoted 29 lines · Sasha Levin
Quoted 26 lines
There wasn't any check of the size passed from userspace before trying to allocate the memory required.
This meant that userspace might request more space than allowed, triggering an OOM.
Signed-off-by Sasha Levin <[email protected]>--- fs/autofs4/dev-ioctl.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)fs/autofs4/dev-ioctl.c +3
-0@@ -103,6 +103,9 @@ static struct autofs_dev_ioctl *copy_dev_ioctl(struct autofs_dev_ioctl __user *iif (tmp.size <sizeof (tmp))return ERR_PTR (-EINVAL ); +if (tmp.size > (PATH_MAX +sizeof (tmp))) +return ERR_PTR (-E2BIG ); +return memdup_user (in, tmp.size); }
Quoted 10 lines · Ian Kent
Quoted 1 line · Sasha Levin
Ping? Anyone wants to take this?
Is this causing a problem for users?
If it is I'll send it to Andrew straight away.I do have this on my queue but don't have any other patches to send so it's just sitting there.
If it worries you I'll send it to Andrew now.
It's not really a pressing issue since /dev/autofs is accessible only to root. I also doubt that it causes problems for actual users.
If there are no issues with the patch, I think it's best if you could ack/sign off on it and if Andrew wants to take it now, he could. If he doesn't, it could wait for whenever.
I just don't want it getting lost somewhere and never making it upstream.
Thanks,
Sasha
Ian Kent
maintainerQuoted 12 lines · Sasha Levin
Quoted 10 lines · Ian Kent
Quoted 1 line · Sasha Levin
Ping? Anyone wants to take this?
Is this causing a problem for users?
If it is I'll send it to Andrew straight away.I do have this on my queue but don't have any other patches to send so it's just sitting there.
If it worries you I'll send it to Andrew now.
Quoted 8 lines
It's not really a pressing issue since
/dev/autofsis accessible only to root. I also doubt that it causes problems for actual users.If there are no issues with the patch, I think it's best if you could ack/sign off on it and if Andrew wants to take it now, he could. If he doesn't, it could wait for whenever.
I just don't want it getting lost somewhere and never making it upstream.
OK, but since I'm going to send it I looked at it a bit closer. Shouldn't the E2BIG be ENAMETOOLONG since it's a file path that's being passed?
I can change that and send it if you agree with the change.
Ian
Quoted 20 lines · Ian Kent
Quoted 19 lines · Sasha Levin
Quoted 10 lines · Ian Kent
Quoted 1 line · Sasha Levin
Ping? Anyone wants to take this?
Is this causing a problem for users?
If it is I'll send it to Andrew straight away.I do have this on my queue but don't have any other patches to send so it's just sitting there.
If it worries you I'll send it to Andrew now.
It's not really a pressing issue since
/dev/autofsis accessible only to root. I also doubt that it causes problems for actual users.If there are no issues with the patch, I think it's best if you could ack/sign off on it and if Andrew wants to take it now, he could. If he doesn't, it could wait for whenever.
Quoted 7 lines
Quoted 1 line
I just don't want it getting lost somewhere and never making it upstream.
OK, but since I'm going to send it I looked at it a bit closer. Shouldn't the E2BIG be ENAMETOOLONG since it's a file path that's being passed?
I can change that and send it if you agree with the change.
Looks good to me, thanks!
Thanks,
Sasha