posix: Fix error checks when copying user strings
PATCH 1/1 posix: Fix error checks when copying user strings
Do not return -EFAULT when the passed string has zero-length. Instead, return -EINVAL when trying to create objects with empty names.
Signed-off-by Jan Kiszka <[email protected]>
---
ksrc/skins/posix/syscall.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-)
ksrc/skins/posix/syscall.c +10 -4
@@ -600,6 +600,8 @@ static int __sem_open(struct pt_regs *regs)if (len >=sizeof (name))return -ENAMETOOLONG ; +if (len ==0 ) +return -EINVAL ; oflags =__xn_reg_arg3 (regs);
@@ -1663,11 +1665,13 @@ static int __mq_open(struct pt_regs *regs) len =__xn_safe_strncpy_from_user (name, (const char __user *)__xn_reg_arg1 (regs),sizeof (name)); -if (len <=0 ) +if (len <0 )return -EFAULT ;if (len >=sizeof (name))return -ENAMETOOLONG ; +if (len ==0 ) +return -EINVAL ; oflags =__xn_reg_arg2 (regs); mode =__xn_reg_arg3 (regs);
@@ -1736,7 +1740,7 @@ static int __mq_unlink(struct pt_regs *regs) len =__xn_safe_strncpy_from_user (name, (const char __user *)__xn_reg_arg1 (regs),sizeof (name)); -if (len <=0 ) +if (len <0 )return -EFAULT ;if (len >=sizeof (name))
@@ -2440,11 +2444,13 @@ static int __shm_open(struct pt_regs *regs) len =__xn_safe_strncpy_from_user (name, (const char __user *)__xn_reg_arg1 (regs),sizeof (name)); -if (len <=0 ) +if (len <0 )return -EFAULT ;if (len >=sizeof (name))return -ENAMETOOLONG ; +if (len ==0 ) +return -EINVAL ; oflag = (int )__xn_reg_arg2 (regs); mode = (mode_t )__xn_reg_arg3 (regs);
@@ -2487,7 +2493,7 @@ static int __shm_unlink(struct pt_regs *regs) len =__xn_safe_strncpy_from_user (name, (const char __user *)__xn_reg_arg1 (regs),sizeof (name)); -if (len <=0 ) +if (len <0 )return -EFAULT ;if (len >=sizeof (name))
Quoted 2 lines · Jan Kiszka
Do not return
-EFAULTwhen the passed string has zero-length. Instead, return-EINVALwhen trying to create objects with empty names.
Ok. You can commit this.
Signature · 1 line
Gilles.