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 AFC4F185B72; Sat, 19 Apr 2025 10:27:08 +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=1745058431; cv=none; b=Ndb91lzo/IDxki9G4SlMDzdB94PnxV8ZacRxseFjl9LQyFtaDBiaTk2pUyJHOPttGh0Hmmv+4NEOHNuWqSFf99gekXSuZNWBaxC5knbN/yI226eg9LrHFR09hymHSrWMFdbk0GFN2Ju/or9sgqW/cF5SJtogAiKGrQ+AElM6tno= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745058431; c=relaxed/simple; bh=SrENdsjsHzxkgYVPfKAXj/QOB27nruL+a7RnTFZRSfk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GmQgFp0PNumue8aZz2zYltL6bOR78YzzOm9E+qVaGCKuw8CAyWsQHZJ+QnpMRnJPbc3RdEINlYtuYW9Da+SxMsiYXvcxd9ZBpYoacQBBWqY2tVE2fLo2Fh04IEkr9iUXph5Yp1M83sH8JN8K+z9+wij7DwoaxEMNl2RFxpHmOrE= 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 53JAR2C3002633; Sat, 19 Apr 2025 12:27:02 +0200 Date: Sat, 19 Apr 2025 12:27:02 +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: <20250419102702.GA2527@1wt.eu> References: <20250416-nolibc-ubsan-v1-0-c4704bb23da7@weissschuh.net> <20250416-nolibc-ubsan-v1-2-c4704bb23da7@weissschuh.net> <20250419090631.GB31874@1wt.eu> <96891976-1f46-4080-91af-1a810fe4498c@t-8ch.de> Precedence: bulk X-Mailing-List: linux-kernel@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: <96891976-1f46-4080-91af-1a810fe4498c@t-8ch.de> User-Agent: Mutt/1.10.1 (2018-07-13) 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 > > > --- > > > 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