From: Yuchen Wei <weiyuchen3@huawei.com> To: <catalin.marinas@arm.com>, <will@kernel.org> Cc: <mark.rutland@arm.com>, <vincenzo.frascino@arm.com>, <keescook@chromium.org>, <pcc@google.com>, <weiyuchen3@huawei.com>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH] arm64: audit: fix return value high 32bit truncation problem Date: Thu, 22 Jul 2021 14:07:07 +0800 [thread overview] Message-ID: <20210722060707.531-1-weiyuchen3@huawei.com> (raw) From: weiyuchen <weiyuchen3@huawei.com> Add error code judgment in invoke_syscall() to prevent kernel components such as audit and tracepoint from obtaining incorrect return values. For example: type=SYSCALL msg=audit(342.780:69): arch=40000028 syscall=235 success=yes exit=4294967235 The syscall return value is -61, but due to the following process in invoke_syscall(): if (is_compat_task()) ret = lower_32_bits(ret); regs->regs[0] = ret; The return value audit or tracepoint get from regs[0] is 4294967235, which is an incorrect return value. Signed-off-by: weiyuchen <weiyuchen3@huawei.com> --- arch/arm64/kernel/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c index 263d6c1a525f..f9f042d9a088 100644 --- a/arch/arm64/kernel/syscall.c +++ b/arch/arm64/kernel/syscall.c @@ -54,7 +54,7 @@ static void invoke_syscall(struct pt_regs *regs, unsigned int scno, ret = do_ni_syscall(regs, scno); } - if (is_compat_task()) + if (is_compat_task() && !IS_ERR_VALUE(ret)) ret = lower_32_bits(ret); regs->regs[0] = ret; -- 2.12.3
WARNING: multiple messages have this Message-ID (diff)
From: Yuchen Wei <weiyuchen3@huawei.com> To: <catalin.marinas@arm.com>, <will@kernel.org> Cc: <mark.rutland@arm.com>, <vincenzo.frascino@arm.com>, <keescook@chromium.org>, <pcc@google.com>, <weiyuchen3@huawei.com>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH] arm64: audit: fix return value high 32bit truncation problem Date: Thu, 22 Jul 2021 14:07:07 +0800 [thread overview] Message-ID: <20210722060707.531-1-weiyuchen3@huawei.com> (raw) From: weiyuchen <weiyuchen3@huawei.com> Add error code judgment in invoke_syscall() to prevent kernel components such as audit and tracepoint from obtaining incorrect return values. For example: type=SYSCALL msg=audit(342.780:69): arch=40000028 syscall=235 success=yes exit=4294967235 The syscall return value is -61, but due to the following process in invoke_syscall(): if (is_compat_task()) ret = lower_32_bits(ret); regs->regs[0] = ret; The return value audit or tracepoint get from regs[0] is 4294967235, which is an incorrect return value. Signed-off-by: weiyuchen <weiyuchen3@huawei.com> --- arch/arm64/kernel/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c index 263d6c1a525f..f9f042d9a088 100644 --- a/arch/arm64/kernel/syscall.c +++ b/arch/arm64/kernel/syscall.c @@ -54,7 +54,7 @@ static void invoke_syscall(struct pt_regs *regs, unsigned int scno, ret = do_ni_syscall(regs, scno); } - if (is_compat_task()) + if (is_compat_task() && !IS_ERR_VALUE(ret)) ret = lower_32_bits(ret); regs->regs[0] = ret; -- 2.12.3 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2021-07-22 6:07 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-07-22 6:07 Yuchen Wei [this message] 2021-07-22 6:07 ` [PATCH] arm64: audit: fix return value high 32bit truncation problem Yuchen Wei 2021-07-30 12:22 ` Will Deacon 2021-07-30 12:22 ` Will Deacon 2021-07-30 14:23 ` Mark Rutland 2021-07-30 14:23 ` Mark Rutland
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210722060707.531-1-weiyuchen3@huawei.com \ --to=weiyuchen3@huawei.com \ --cc=catalin.marinas@arm.com \ --cc=keescook@chromium.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mark.rutland@arm.com \ --cc=pcc@google.com \ --cc=vincenzo.frascino@arm.com \ --cc=will@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.