Fix stack smashing when handling PR_GET_PDEATHSIG
PATCH v2 1/1 Fix stack smashing when handling PR_GET_PDEATHSIG
The bug was triggered by the following code on aarch64-linux-user:
#include <signal.h>
#include <sys/prctl.h>
int main(void)
{
int PDeathSig = 0;
if (prctl(PR_GET_PDEATHSIG, &PDeathSig) == 0 && PDeathSig == SIGKILL)
prctl(PR_GET_PDEATHSIG, 0);
return (PDeathSig == SIGKILL);
}
---
I fixed the incorrect subject line. PR_GETDEATHSIG should be PR_GET_PDEATHSIG. Is there a test folder where I can include the code that triggered the bug? Also, I thought "int" can be 2 bytes on some machines.
linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/syscall.c +1 -1
@@ -10256,7 +10256,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,int deathsig; ret =get_errno (prctl (arg1, &deathsig, arg3, arg4, arg5));if (!is_error (ret) && arg2 - &&put_user_ual (deathsig, arg2)) { + &&put_user_s32 (deathsig, arg2)) {return -TARGET_EFAULT ; }return ret;
Signature · 1 line
2.17.1
Le 07/05/2020 à 15:03, Stephen Long a écrit :
Quoted 13 lines
The bug was triggered by the following code on aarch64-linux-user:
#include <
signal.h>
#include <sys/prctl.h>int main(void)
{
int PDeathSig = 0;
if (prctl(PR_GET_PDEATHSIG, &PDeathSig)== 0 && PDeathSig == SIGKILL)prctl(PR_GET_PDEATHSIG, 0);return (PDeathSig == SIGKILL);
}
Quoted 6 lines
Signed-off-by Stephen Long <[email protected]>Signed-off-by Ana Pazos <[email protected]>---
I fixed the incorrect subject line.
PR_GETDEATHSIGshould bePR_GET_PDEATHSIG. Is there a test folder where I can include the code that triggered the bug?
Perhaps Alex Bennée knows?
Quoted 1 line
Also, I thought "int" can be 2 bytes on some machines.
According to my K&R, 4th edition, it could be on 16bit systems, like PDP-11, but we don't support them ;)
Quoted 18 lines
linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)linux-user/syscall.c +1
-1@@ -10256,7 +10256,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,int deathsig; ret =get_errno (prctl (arg1, &deathsig, arg3, arg4, arg5));if (!is_error (ret) && arg2 - &&put_user_ual (deathsig, arg2)) { + &&put_user_s32 (deathsig, arg2)) {return -TARGET_EFAULT ; }return ret;
Quoted 16 lines
Quoted 8 lines
linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)linux-user/syscall.c +0
-0linux-user/syscall.c static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, · line 10262
Quoted 8 lines
linux-user/syscall.c +1
-1@@ -10256,7 +10256,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,int deathsig; ret =get_errno (prctl (arg1, &deathsig, arg3, arg4, arg5));if (!is_error (ret) && arg2 - &&put_user_ual (deathsig, arg2)) { + &&put_user_s32 (deathsig, arg2)) {return -TARGET_EFAULT ; }return ret;
Hi Laurent, is it possible to get this patch into master?
Laurent Vivier
AppliedLe 26/09/2020 à 03:56, Stephen Long a écrit :
Quoted 19 lines
Quoted 16 lines
Quoted 8 lines
linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)linux-user/syscall.c +0
-0linux-user/syscall.c static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, · line 10262
Quoted 8 lines
linux-user/syscall.c +1
-1@@ -10256,7 +10256,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,int deathsig; ret =get_errno (prctl (arg1, &deathsig, arg3, arg4, arg5));if (!is_error (ret) && arg2 - &&put_user_ual (deathsig, arg2)) { + &&put_user_s32 (deathsig, arg2)) {return -TARGET_EFAULT ; }return ret;Hi Laurent, is it possible to get this patch into master?
Applied to my linux-user-for-5.2 branch.
Thanks,
Laurent
Le 07/05/2020 à 15:03, Stephen Long a écrit :
Quoted 30 lines
The bug was triggered by the following code on aarch64-linux-user:
#include <
signal.h>
#include <sys/prctl.h>int main(void)
{
int PDeathSig = 0;
if (prctl(PR_GET_PDEATHSIG, &PDeathSig)== 0 && PDeathSig == SIGKILL)prctl(PR_GET_PDEATHSIG, 0);return (PDeathSig == SIGKILL);
}Signed-off-by Stephen Long <[email protected]>Signed-off-by Ana Pazos <[email protected]>---
I fixed the incorrect subject line.
PR_GETDEATHSIGshould bePR_GET_PDEATHSIG. Is there a test folder where I can include the code that triggered the bug? Also, I thought "int" can be 2 bytes on some machines.linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)linux-user/syscall.c +0
-0
linux-user/syscall.c static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, · line 10262
Quoted 8 lines
linux-user/syscall.c +1
-1@@ -10256,7 +10256,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,int deathsig; ret =get_errno (prctl (arg1, &deathsig, arg3, arg4, arg5));if (!is_error (ret) && arg2 - &&put_user_ual (deathsig, arg2)) { + &&put_user_s32 (deathsig, arg2)) {return -TARGET_EFAULT ; }return ret;