From: Willy Tarreau <w@1wt.eu>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: "Paul E. McKenney" <paulmck@kernel.org>,
Shuah Khan <shuah@kernel.org>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 2/6] tools/nolibc: disable function sanitizer for _start_c()
Date: Sat, 19 Apr 2025 12:27:02 +0200 [thread overview]
Message-ID: <20250419102702.GA2527@1wt.eu> (raw)
In-Reply-To: <96891976-1f46-4080-91af-1a810fe4498c@t-8ch.de>
On Sat, Apr 19, 2025 at 12:10:24PM +0200, Thomas Weißschuh wrote:
> On 2025-04-19 11:06:31+0200, Willy Tarreau wrote:
> > On Wed, Apr 16, 2025 at 08:40:17PM +0200, Thomas Weißschuh wrote:
> > > Both constructors and main() may be executed with different function
> > > signatures than they are actually using.
> > > This is intentional but trips up UBSAN.
> > >
> > > Disable the function sanitizer of UBSAN in _start_c().
> > >
> > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> > > ---
> > > tools/include/nolibc/crt.h | 5 +++++
> > > 1 file changed, 5 insertions(+)
> > >
> > > diff --git a/tools/include/nolibc/crt.h b/tools/include/nolibc/crt.h
> > > index c4b10103bbec50f1a3a0a4562e34fdbd1b43ce6f..961cfe777c3564e705dfdd581de828b374d05b0b 100644
> > > --- a/tools/include/nolibc/crt.h
> > > +++ b/tools/include/nolibc/crt.h
> > > @@ -7,6 +7,8 @@
> > > #ifndef _NOLIBC_CRT_H
> > > #define _NOLIBC_CRT_H
> > >
> > > +#include "compiler.h"
> > > +
> > > char **environ __attribute__((weak));
> > > const unsigned long *_auxv __attribute__((weak));
> > >
> > > @@ -25,6 +27,9 @@ extern void (*const __fini_array_end[])(void) __attribute__((weak));
> > >
> > > void _start_c(long *sp);
> > > __attribute__((weak,used))
> > > +#if __nolibc_has_feature(undefined_behavior_sanitizer)
> > > + __attribute__((no_sanitize("function")))
> > > +#endif
> >
> > I'm wondering if it wouldn't be more reliable with:
> >
> > #if __nolibc_has_attribute(no_sanitize)
> > __attribute__((no_sanitize("function")))
> > #endif
> >
> > Because in the end, what you want is to always place that attribute
> > whenever it's supported, no ?
>
> That doesn't work because GCC does knows no_sanitize but not
> no_sanitize("function").
> Also no_sanitize is not specific to UBSAN but works for all sanitizers.
OK, thanks for explaining!
Willy
next prev parent reply other threads:[~2025-04-19 10:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 18:40 [PATCH 0/6] tools/nolibc: fix some undefined behaviour and enable UBSAN Thomas Weißschuh
2025-04-16 18:40 ` [PATCH 1/6] tools/nolibc: add __nolibc_has_feature() Thomas Weißschuh
2025-04-16 18:40 ` [PATCH 2/6] tools/nolibc: disable function sanitizer for _start_c() Thomas Weißschuh
2025-04-19 9:06 ` Willy Tarreau
2025-04-19 10:10 ` Thomas Weißschuh
2025-04-19 10:27 ` Willy Tarreau [this message]
2025-04-16 18:40 ` [PATCH 3/6] tools/nolibc: properly align dirent buffer Thomas Weißschuh
2025-04-19 9:11 ` Willy Tarreau
2025-04-19 10:11 ` Thomas Weißschuh
2025-04-16 18:40 ` [PATCH 4/6] tools/nolibc: fix integer overflow in i{64,}toa_r() and Thomas Weißschuh
2025-04-19 9:40 ` Willy Tarreau
2025-04-19 10:26 ` Thomas Weißschuh
2025-04-16 18:40 ` [PATCH 5/6] selftests/nolibc: disable ubsan for smash_stack() Thomas Weißschuh
2025-04-16 18:40 ` [PATCH 6/6] selftests/nolibc: enable UBSAN if available Thomas Weißschuh
2025-04-19 9:41 ` Willy Tarreau
2025-04-18 17:32 ` [PATCH 0/6] tools/nolibc: fix some undefined behaviour and enable UBSAN Paul E. McKenney
2025-04-18 21:20 ` Thomas Weißschuh
2025-04-18 21:29 ` Paul E. McKenney
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=20250419102702.GA2527@1wt.eu \
--to=w@1wt.eu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=paulmck@kernel.org \
--cc=shuah@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: 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