From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B0F2D288CC; Sat, 19 Apr 2025 09:06:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=163.172.96.212 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745053608; cv=none; b=ErkqWTRoJ4w6xBr5Eo1bBWFiKfrLCFq67tUueveYbquuMzz/p9q7RM+MD+yFO9SN/A8OJ39RwvSpu93h0W7jcJgoR9UrrBfBxlnZprr3V9br9Uece4js+Rbc7GCLBXkfPQRQLnkaqmHKEyhF0CnoUjXHublEW9IhiZX6n8mIdZg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745053608; c=relaxed/simple; bh=JO4nI6509DAVavai5pLevTpGNK9zOusprZDRtRVv3+4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VUbfLy+D9I3LyOGXrFL6zAu8qWpX8P1VfLbCSgF2TacpZeF6jlYPNjLweRLIdoqhAMfQWNDYCbkkB0ebM+6K3TcBh0a7T9lwzeRdRilkMwUR5gSoGDuQvEq/PJzWdze9WGPeFSVTv0eQl2gXkC72joWHRBnt7whcPHXg7OxSgu0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=1wt.eu; spf=pass smtp.mailfrom=1wt.eu; arc=none smtp.client-ip=163.172.96.212 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=1wt.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=1wt.eu Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 53J96VFw031969; Sat, 19 Apr 2025 11:06:31 +0200 Date: Sat, 19 Apr 2025 11:06:31 +0200 From: Willy Tarreau To: Thomas =?iso-8859-1?Q?Wei=DFschuh?= Cc: "Paul E. McKenney" , Shuah Khan , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH 2/6] tools/nolibc: disable function sanitizer for _start_c() Message-ID: <20250419090631.GB31874@1wt.eu> References: <20250416-nolibc-ubsan-v1-0-c4704bb23da7@weissschuh.net> <20250416-nolibc-ubsan-v1-2-c4704bb23da7@weissschuh.net> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20250416-nolibc-ubsan-v1-2-c4704bb23da7@weissschuh.net> User-Agent: Mutt/1.10.1 (2018-07-13) 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 > --- > 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 ? > void _start_c(long *sp) > { > long argc; Willy