From: Eugene Syromyatnikov Date: Fri, 5 Jan 2018 20:09:48 +0000 (+0100) Subject: ldt.c: manually set modify_ldt's error code X-Git-Tag: v4.21~176 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8830aa8fcaa58f1df59e3d0225ec39dc3cd7ad5a;p=strace ldt.c: manually set modify_ldt's error code * ldt.c (modify_ldt): Move parsing under entering(tcp). Check whether return code is erroneous and set tcp->u_error appropriately along with RVAL_PRINT_ERR_VAL flag. --- diff --git a/ldt.c b/ldt.c index 735cb137..4ede5ba0 100644 --- a/ldt.c +++ b/ldt.c @@ -70,14 +70,28 @@ print_user_desc(struct tcb *const tcp, const kernel_ulong_t addr) SYS_FUNC(modify_ldt) { - tprintf("%d, ", (int) tcp->u_arg[0]); - if (tcp->u_arg[2] != sizeof(struct user_desc)) - printaddr(tcp->u_arg[1]); - else - print_user_desc(tcp, tcp->u_arg[1]); - tprintf(", %" PRI_klu, tcp->u_arg[2]); + if (entering(tcp)) { + tprintf("%d, ", (int) tcp->u_arg[0]); + if (tcp->u_arg[2] != sizeof(struct user_desc)) + printaddr(tcp->u_arg[1]); + else + print_user_desc(tcp, tcp->u_arg[1]); + tprintf(", %" PRI_klu, tcp->u_arg[2]); + + return 0; + } - return RVAL_DECODED; + /* + * For some reason ("tht ABI for sys_modify_ldt() expects + * 'int'"), modify_ldt clips higher bits on x86_64. + */ + + if (syserror(tcp) || (kernel_ulong_t) tcp->u_rval < 0xfffff000) + return 0; + + tcp->u_error = -(unsigned int) tcp->u_rval; + + return RVAL_PRINT_ERR_VAL; } SYS_FUNC(set_thread_area)