[PATCH OLK-5.10] ubsan: Fix incorrect hand-side used in handle

From: Junhui Pei <paradoxskin233@gmail.com> mainline inclusion from mainline-v6.17-rc4 commit ae91aea2d2265c88dbed65a07bbaf3c133fe970c category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ICZMWA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i... -------------------------------- __ubsan_handle_divrem_overflow() incorrectly uses the RHS to report. It always reports the same log: division of -1 by -1. But it should report division of LHS by -1. Signed-off-by: Junhui Pei <paradoxskin233@gmail.com> Fixes: c6d308534aef ("UBSAN: run-time undefined behavior sanity checker") Link: https://lore.kernel.org/r/20250602153841.62935-1-paradoxskin233@gmail.com Signed-off-by: Kees Cook <kees@kernel.org> Conflicts: lib/ubsan.c [The conflicts were due to some minor issue.] Signed-off-by: Xiaomeng Zhang <zhangxiaomeng13@huawei.com> --- lib/ubsan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ubsan.c b/lib/ubsan.c index ee14c46cac89..12c7baa422d7 100644 --- a/lib/ubsan.c +++ b/lib/ubsan.c @@ -225,18 +225,18 @@ EXPORT_SYMBOL(__ubsan_handle_negate_overflow); void __ubsan_handle_divrem_overflow(void *_data, void *lhs, void *rhs) { struct overflow_data *data = _data; - char rhs_val_str[VALUE_LENGTH]; + char lhs_val_str[VALUE_LENGTH]; if (suppress_report(&data->location)) return; ubsan_prologue(&data->location, "division-overflow"); - val_to_string(rhs_val_str, sizeof(rhs_val_str), data->type, rhs); + val_to_string(lhs_val_str, sizeof(lhs_val_str), data->type, lhs); if (type_is_signed(data->type) && get_signed_val(data->type, rhs) == -1) pr_err("division of %s by -1 cannot be represented in type %s\n", - rhs_val_str, data->type->type_name); + lhs_val_str, data->type->type_name); else pr_err("division by zero\n"); -- 2.34.1

反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/18160 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/2MI... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/18160 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/2MI...
participants (2)
-
patchwork bot
-
Xiaomeng Zhang