syscall: fixed mincore(2) not failing with ENOMEM
PATCH 1/1 syscall: fixed mincore(2) not failing with ENOMEM
From: "Franklin \"Snaipe\" Mathieu" <[email protected]>
The current implementation of the mincore(2) syscall sets errno to EFAULT when the region identified by the first two parameters is invalid.
This goes against the man page specification, where mincore(2) should only fail with EFAULT when the third parameter is an invalid address; and fail with ENOMEM when the checked region does not point to mapped memory.
--- linux-user/syscall.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
linux-user/syscall.c +8 -3
@@ -11061,11 +11061,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,case TARGET_NR_mincore: {void *a; + ret = -TARGET_ENOMEM ; + a =lock_user (VERIFY_READ , arg1, arg2,0 ); +if (!a) { + goto fail; + } ret = -TARGET_EFAULT ; -if (!(a =lock_user (VERIFY_READ , arg1,arg2,0 ))) - goto efault; -if (!(p =lock_user_string (arg3))) + p = lock_user_string(arg3) +if (!p) { goto mincore_fail; + } ret =get_errno (mincore (a, arg2, p));unlock_user (p, arg3, ret); mincore_fail:
Signature · 1 line
2.11.0
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 11071
Quoted 2 lines · Franklin Snaipe Mathieu
linux-user/syscall.c +2
-0+ p = lock_user_string(arg3) +if (!p) {
Please compile test at least, even if it is a trivial patch.
Fam
2017-02-17 0:50 GMT+00:00 Fam Zheng <[email protected]>:
Quoted 6 lines · Franklin Snaipe Mathieu
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 11071
Quoted 2 lines
linux-user/syscall.c +2
-0+ p = lock_user_string(arg3) +if (!p) {Please compile test at least, even if it is a trivial patch.
Whoops, sorry, I forgot to re-compile after fixing the checkpatch issues.
Signature · 2 lines
Franklin "Snaipe" Mathieu 🝰 https://diacritic.io
PATCH 1/1 syscall: fixed mincore(2) not failing with ENOMEM
In reply to Franklin Snaipe MathieuFrom: "Franklin \"Snaipe\" Mathieu" <[email protected]>
The current implementation of the mincore(2) syscall sets errno to EFAULT when the region identified by the first two parameters is invalid.
This goes against the man page specification, where mincore(2) should only fail with EFAULT when the third parameter is an invalid address; and fail with ENOMEM when the checked region does not point to mapped memory.
--- linux-user/syscall.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
linux-user/syscall.c +8 -3
@@ -11061,11 +11061,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,case TARGET_NR_mincore: {void *a; + ret = -TARGET_ENOMEM ; + a =lock_user (VERIFY_READ , arg1, arg2,0 ); +if (!a) { + goto fail; + } ret = -TARGET_EFAULT ; -if (!(a =lock_user (VERIFY_READ , arg1,arg2,0 ))) - goto efault; -if (!(p =lock_user_string (arg3))) + p =lock_user_string (arg3); +if (!p) { goto mincore_fail; + } ret =get_errno (mincore (a, arg2, p));unlock_user (p, arg3, ret); mincore_fail:
Signature · 1 line
2.11.0
PATCH v2 1/1 syscall: fixed mincore(2) not failing with ENOMEM
From: "Franklin \"Snaipe\" Mathieu" <[email protected]>
The current implementation of the mincore(2) syscall sets errno to EFAULT when the region identified by the first two parameters is invalid.
This goes against the man page specification, where mincore(2) should only fail with EFAULT when the third parameter is an invalid address; and fail with ENOMEM when the checked region does not point to mapped memory.
--- linux-user/syscall.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
linux-user/syscall.c +8 -3
@@ -11061,11 +11061,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,case TARGET_NR_mincore: {void *a; + ret = -TARGET_ENOMEM ; + a =lock_user (VERIFY_READ , arg1, arg2,0 ); +if (!a) { + goto fail; + } ret = -TARGET_EFAULT ; -if (!(a =lock_user (VERIFY_READ , arg1,arg2,0 ))) - goto efault; -if (!(p =lock_user_string (arg3))) + p =lock_user_string (arg3); +if (!p) { goto mincore_fail; + } ret =get_errno (mincore (a, arg2, p));unlock_user (p, arg3, ret); mincore_fail:
Signature · 1 line
2.11.0
Quoted 33 lines · Franklin Snaipe Mathieu
From: "Franklin \"Snaipe\" Mathieu" <[email protected]>
The current implementation of the mincore(2) syscall sets errno to EFAULT when the region identified by the first two parameters is invalid.
This goes against the man page specification, where mincore(2) should only fail with EFAULT when the third parameter is an invalid address; and fail with ENOMEM when the checked region does not point to mapped memory.
Signed-off-by Franklin "Snaipe" Mathieu <[email protected]>Cc Riku Voipio <[email protected]>Cc Aurelien Jarno <[email protected]>--- linux-user/syscall.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)linux-user/syscall.c +5
-0@@ -11061,11 +11061,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,case TARGET_NR_mincore: {void *a; + ret = -TARGET_ENOMEM ; + a =lock_user (VERIFY_READ , arg1, arg2,0 ); +if (!a) { + goto fail; + } ret = -TARGET_EFAULT ;
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 11076
Quoted 10 lines
linux-user/syscall.c +3
-3-if (!(a =lock_user (VERIFY_READ , arg1,arg2,0 ))) - goto efault; -if (!(p =lock_user_string (arg3))) + p =lock_user_string (arg3); +if (!p) { goto mincore_fail; + } ret =get_errno (mincore (a, arg2, p));unlock_user (p, arg3, ret); mincore_fail:
Ignore this patch, this was sent again by mistake.
2017-02-17 8:57 GMT+00:00 Franklin Snaipe Mathieu <[email protected]>:
Quoted 45 lines
From: "Franklin \"Snaipe\" Mathieu" <[email protected]>
The current implementation of the mincore(2) syscall sets errno to EFAULT when the region identified by the first two parameters is invalid.
This goes against the man page specification, where mincore(2) should only fail with EFAULT when the third parameter is an invalid address; and fail with ENOMEM when the checked region does not point to mapped memory.
Signed-off-by Franklin "Snaipe" Mathieu <[email protected]>Cc Riku Voipio <[email protected]>Cc Aurelien Jarno <[email protected]>--- linux-user/syscall.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)linux-user/syscall.c +8
-4@@ -11061,11 +11061,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,case TARGET_NR_mincore: {void *a; + ret = -TARGET_ENOMEM ; + a =lock_user (VERIFY_READ , arg1, arg2,0 ); +if (!a) { + goto fail; + } ret = -TARGET_EFAULT ; -if (!(a =lock_user (VERIFY_READ , arg1,arg2,0 ))) - goto efault; -if (!(p =lock_user_string (arg3))) + p =lock_user_string (arg3); +if (!p) { goto mincore_fail; + } ret =get_errno (mincore (a, arg2, p));unlock_user (p, arg3, ret); mincore_fail: --2.11.0
Signature · 2 lines
Franklin "Snaipe" Mathieu 🝰 https://diacritic.io
Quoted 1 line · Franklin "Snaipe" Mathieu
Ignore this patch, this was sent again by mistake.
Hi Franklin, thanks for the re-submission. Next time please send consecutive versions as top-level threads instead of replies to previous versions, with proper 'v2", "v3" tags in the subject.
Fam
Michael Tokarev
AppliedQuoted 10 lines · Franklin Snaipe Mathieu
From: "Franklin \"Snaipe\" Mathieu" <[email protected]>
The current implementation of the mincore(2) syscall sets errno to EFAULT when the region identified by the first two parameters is invalid.
This goes against the man page specification, where mincore(2) should only fail with EFAULT when the third parameter is an invalid address; and fail with ENOMEM when the checked region does not point to mapped memory.
Applied to -trivial, thanks!
/mjt