mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 3/3] Revert "common: ubsan: ignore shifting one into sign bit"
Date: Thu, 15 Oct 2020 11:00:56 +0200	[thread overview]
Message-ID: <20201015090055.31130-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20201015090055.31130-1-a.fatoum@pengutronix.de>

With the previous commit, we now explicitly tell GCC not to optimize
constructs like (1 << 31) under assumption that they are undefined
anyway. GCC >= 8.0 -fsanitize=undefined should now not warn any longer
about (1 << 31) instances, so remove our work around.

This reverts commit 55397b9ebe3a21a3aeb6a98131c0991bff0f7123.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 lib/ubsan.c | 20 --------------------
 1 file changed, 20 deletions(-)

diff --git a/lib/ubsan.c b/lib/ubsan.c
index 085d470cf784..648c7cc48a60 100644
--- a/lib/ubsan.c
+++ b/lib/ubsan.c
@@ -382,26 +382,6 @@ void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data,
 	if (suppress_report(&data->location))
 		return;
 
-	/* This handler would be called for code shifting a one into the
-	 * sign bit like (1 << 31), which is all too common in barebox.
-	 * It's technically UB, but it's so prevalent that it's highly
-	 * unlikely to be treated by a compiler as anything else than the
-	 * standard-compliant (1U << 31). Thus check for this case here
-	 * and ignore it selectively
-	 */
-	if (type_is_signed(lhs_type)) {
-		s_max lhs_int, rhs_int;
-
-		lhs_int = get_signed_val(lhs_type, lhs);
-		rhs_int = get_signed_val(rhs_type, rhs);
-
-		if (fls(lhs_int) + rhs_int == type_bit_width(lhs_type)) {
-			pr_debug("signed left shift of %lld by %lld ignored.\n",
-				(s64)lhs_int, (s64)rhs_int);
-			return;
-		}
-	}
-
 	ubsan_prologue(&data->location, &flags);
 
 	val_to_string(rhs_str, sizeof(rhs_str), rhs_type, rhs);
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2020-10-15  9:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-15  9:00 [PATCH 1/3] sandbox: fix link error when UBSAN is selected without ASAN Ahmad Fatoum
2020-10-15  9:00 ` [PATCH 2/3] kbuild: force compiler to assume two's complement Ahmad Fatoum
2020-10-15  9:00 ` Ahmad Fatoum [this message]
2020-10-19  7:58 ` [PATCH 1/3] sandbox: fix link error when UBSAN is selected without ASAN Sascha Hauer

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=20201015090055.31130-3-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox