linux-user: prctl follow-ups
cover linux-user: prctl follow-ups
Hi Laurent, as requested. I did all of the cap_task_prctl options, and fixed a few existing bugs with PR_GET_DEATHSIG.
r~
Richard Henderson (4):
linux-user: Do not special-case NULL for PR_GET_PDEATHSIG
linux-user: Map signal number in PR_GET_PDEATHSIG
linux-user: Implement PR_SET_PDEATHSIG
linux-user: Implement capability prctls
linux-user/syscall.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.1
PATCH 1/4 linux-user: Do not special-case NULL for PR_GET_PDEATHSIG
The kernel does not special-case arg2 != NULL, so
neither should we.
--- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/syscall.c +1 -1
@@ -6444,7 +6444,7 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,int deathsig; ret =get_errno (prctl (PR_GET_PDEATHSIG , &deathsig, arg3, arg4, arg5)); -if (!is_error (ret) && arg2 &&put_user_s32 (deathsig, arg2)) { +if (!is_error (ret) &&put_user_s32 (deathsig, arg2)) {return -TARGET_EFAULT ; }return ret;
Signature · 1 line
2.25.1
Re: [PATCH 1/4] linux-user: Do not special-case NULL for PR_GET_PDEATHSIG
Le 06/01/2022 à 23:57, Richard Henderson a écrit :
Quoted 13 lines
The kernel does not special-case arg2 != NULL, so
neither should we.Signed-off-by Richard Henderson <[email protected]>--- 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_prctl(CPUArchState *env, abi_long option, abi_long arg2, · line 6450
Quoted 8 lines
linux-user/syscall.c +1
-1@@ -6444,7 +6444,7 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,int deathsig; ret =get_errno (prctl (PR_GET_PDEATHSIG , &deathsig, arg3, arg4, arg5)); -if (!is_error (ret) && arg2 &&put_user_s32 (deathsig, arg2)) { +if (!is_error (ret) &&put_user_s32 (deathsig, arg2)) {return -TARGET_EFAULT ; }return ret;
Laurent Vivier
Reviewed-byRe: [PATCH 1/4] linux-user: Do not special-case NULL for PR_GET_PDEATHSIG
Le 08/01/2022 à 18:10, Laurent Vivier a écrit :
Quoted 9 lines
Le 06/01/2022 à 23:57, Richard Henderson a écrit :
Quoted 8 lines
The kernel does not special-case arg2 != NULL, so
neither should we.Signed-off-by Richard Henderson <[email protected]>---
linux-user/syscall.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
linux-user/syscall.c static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, · line 6450
Quoted 13 lines
linux-user/syscall.c +1
-1@@ -6444,7 +6444,7 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, int deathsig; ret = get_errno(prctl(PR_GET_PDEATHSIG, &deathsig, arg3, arg4, arg5)); - if (!is_error(ret) && arg2 && put_user_s32(deathsig, arg2)) { + if (!is_error(ret) && put_user_s32(deathsig, arg2)) { return -TARGET_EFAULT; } return ret;Reviewed-by Laurent Vivier <[email protected]>
PATCH 2/4 linux-user: Map signal number in PR_GET_PDEATHSIG
In reply to Richard HendersonConvert the host signal number to guest signal number before returning the value to the guest.
--- linux-user/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
linux-user/syscall.c +2 -1
@@ -6444,7 +6444,8 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,int deathsig; ret =get_errno (prctl (PR_GET_PDEATHSIG , &deathsig, arg3, arg4, arg5)); -if (!is_error (ret) &&put_user_s32 (deathsig, arg2)) { +if (!is_error (ret) && +put_user_s32 (host_to_target_signal (deathsig), arg2)) {return -TARGET_EFAULT ; }return ret;
Signature · 1 line
2.25.1
Re: [PATCH 2/4] linux-user: Map signal number in PR_GET_PDEATHSIG
Quoted 7 lines · Richard Henderson
Convert the host signal number to guest signal number before returning the value to the guest.
Signed-off-by Richard Henderson <[email protected]>--- linux-user/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
PATCH 3/4 linux-user: Implement PR_SET_PDEATHSIG
In reply to Richard Henderson--- linux-user/syscall.c | 3 +++ 1 file changed, 3 insertions(+)
linux-user/syscall.c +3 -0
@@ -6450,6 +6450,9 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, }return ret; } +case PR_SET_PDEATHSIG : +return get_errno (prctl (PR_SET_PDEATHSIG ,target_to_host_signal (arg2), + arg3, arg4, arg5));case PR_GET_NAME : {void *name =lock_user (VERIFY_WRITE , arg2,16 ,1 );
Signature · 1 line
2.25.1
Re: [PATCH 3/4] linux-user: Implement PR_SET_PDEATHSIG
Le 06/01/2022 à 23:57, Richard Henderson a écrit :
Quoted 10 lines
Signed-off-by Richard Henderson <[email protected]>--- linux-user/syscall.c | 3 +++ 1 file changed, 3 insertions(+)linux-user/syscall.c +0
-0
linux-user/syscall.c static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, · line 6458
Quoted 9 lines
linux-user/syscall.c +3
-0@@ -6450,6 +6450,9 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, }return ret; } +case PR_SET_PDEATHSIG : +return get_errno (prctl (PR_SET_PDEATHSIG ,target_to_host_signal (arg2), + arg3, arg4, arg5));case PR_GET_NAME : {void *name =lock_user (VERIFY_WRITE , arg2,16 ,1 );
PATCH 4/4 linux-user: Implement capability prctls
In reply to Richard HendersonThis is PR_CAPBSET_READ, PR_CAPBSET_DROP and the "legacy" PR_CAP_AMBIENT PR_GET_SECUREBITS, PR_SET_SECUREBITS.
All of these arguments are integer values only, and do not require mapping of values between host and guest.
--- linux-user/syscall.c | 5 +++++ 1 file changed, 5 insertions(+)
linux-user/syscall.c +5 -0
@@ -6504,10 +6504,15 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,case PR_SET_UNALIGN :return do_prctl_set_unalign (env, arg2); +case PR_CAP_AMBIENT : +case PR_CAPBSET_READ : +case PR_CAPBSET_DROP :case PR_GET_DUMPABLE :case PR_SET_DUMPABLE :case PR_GET_KEEPCAPS :case PR_SET_KEEPCAPS : +case PR_GET_SECUREBITS : +case PR_SET_SECUREBITS :case PR_GET_TIMING :case PR_SET_TIMING :case PR_GET_TIMERSLACK :
Signature · 1 line
2.25.1
Re: [PATCH 4/4] linux-user: Implement capability prctls
Le 06/01/2022 à 23:57, Richard Henderson a écrit :
Quoted 21 lines
This is
PR_CAPBSET_READ,PR_CAPBSET_DROPand the "legacy"PR_CAP_AMBIENTPR_GET_SECUREBITS,PR_SET_SECUREBITS.All of these arguments are integer values only, and do not require mapping of values between host and guest.
Signed-off-by Richard Henderson <[email protected]>--- linux-user/syscall.c | 5 +++++ 1 file changed, 5 insertions(+)linux-user/syscall.c +2
-0@@ -6504,10 +6504,15 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,case PR_SET_UNALIGN :return do_prctl_set_unalign (env, arg2); +case PR_CAP_AMBIENT : +case PR_CAPBSET_READ :
linux-user/syscall.c static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, · line 6518
Quoted 10 lines
linux-user/syscall.c +3
-0+case PR_CAPBSET_DROP :case PR_GET_DUMPABLE :case PR_SET_DUMPABLE :case PR_GET_KEEPCAPS :case PR_SET_KEEPCAPS : +case PR_GET_SECUREBITS : +case PR_SET_SECUREBITS :case PR_GET_TIMING :case PR_SET_TIMING :case PR_GET_TIMERSLACK :
Le 06/01/2022 à 23:57, Richard Henderson a écrit :
Quoted 5 lines
Hi Laurent, as requested. I did all of the
cap_task_prctloptions, and fixed a few existing bugs withPR_GET_DEATHSIG.r~
Quoted 9 lines
Richard Henderson (4):
linux-user: Do not special-case NULL forPR_GET_PDEATHSIG
linux-user: Map signal number inPR_GET_PDEATHSIG
linux-user: ImplementPR_SET_PDEATHSIG
linux-user: Implement capability prctlslinux-user/syscall.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
Series applied to my linux-user-for-7.0 branch.
Thanks,
Laurent