Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp578184rdb; Mon, 29 Jan 2024 11:01:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IHpvUJNITqWbkj8HMxVNr6tWNkZAh/gpz/46Q9FKznZMeBhQBK8gUcW+UZONSw/kfzvWXTC X-Received: by 2002:ac8:5701:0:b0:42a:b19f:420a with SMTP id 1-20020ac85701000000b0042ab19f420amr504014qtw.106.1706554915620; Mon, 29 Jan 2024 11:01:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706554915; cv=pass; d=google.com; s=arc-20160816; b=i6Ikikx5H399QgDYcJoDEO+uRfC2XvSEbkceUCSXP5LLhgZzkwbkMvER3tHXx0pVKH rnflUH5QdB7+azKHxYgwBkxKC9Ym1pZiHciIuQ3VOD9Vpor8GeGkaKvTRNBSaj9GYr1V xsn0yYsdeozOP+TCL27GzlYdDzZws71QobVKoYmUhycfYk8sa/2j9Unta8tPg06LpSt7 fdH7o1IJVCZI+oikwVadkLeVjxvO+cbSEnS1zDh5QD8297KuQWQKOAd0fv0+ES2nqGke VKB5zZ55r5F841iMDzEDngSMfQKBD/JuKwQ/cMhR/Je0NsX8G96pzd/B8UHafuQQZSWZ pdyA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=YYJPquRBqD9Q7jzpQNCrCFu5Gx3v6qV+tI8wEy5zyow=; fh=fzjcMy3SHXvD4Hatv6ES2BNCCUKuhh7QEuBaCzRVZuo=; b=tTGUk27I8fTuorbSq4TYYNXIs7sxeB+wr2JSILL88AGeqtc5AlF/flTxAdPEWGjd3X AqgZ4SWVlb62UvpXfVviJXNjomqUwtk5PcX096TigFix3iFVTHyhEQBotryeUPA0KptG U2n2VpE9o1QzxygcNaNDuGXRxFtbywwlBBY+exn+WeyKBVFBmPD14FIb5ZHT3GTAvlGC 8R2aAFDvbXHkiDxeEg37zfVYgd6YeGz+Il2uBPnDRnTDU7ajrVk6MHLGYotkRvSTgvo4 RIZmIJ1SPnKz4Ddx8sAWgo+jtQlCiT2ojVQMTSqdu41QttFu9A1s0M17mXh2+tSBJzK3 Llww== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Zfeerdiw; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-43379-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43379-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r16-20020ac85c90000000b0042a17ed3043si8296123qta.751.2024.01.29.11.01.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 11:01:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43379-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Zfeerdiw; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-43379-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43379-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id CB7B01C24C30 for ; Mon, 29 Jan 2024 19:00:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C38A736AE1; Mon, 29 Jan 2024 19:00:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Zfeerdiw" Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C9412D044 for ; Mon, 29 Jan 2024 19:00:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706554827; cv=none; b=psGfRTIvU5bJO1gUhzROIVEho1pVV1EJ1DZfsByeXT2ce31Djkf92oud7UNuumTq1fiKCfNH54CbOQh1q8B87OxtugnkFwfV0OlEQValRVqATWwXsvAE0Mf/u79+bNMI+u56dCDc9KWL7VDNE3DxDGeom4afAPJ9R6n/vB32WdE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706554827; c=relaxed/simple; bh=ssMtgarRnRs+LWFQuEr18d3XaNBa10XeJKStTgVMzZw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=URTzA1aKOUdeyGvnVphWRixbJSkrCE+3ItBcKoB3ZyBVFUpOQUl9SiveJ8Resqdh8F25LSOnfVSLH83V9ZLjp35D7duxeZcgnPn5X6fzboYEwKQIBarDN2mQ9tmu1ku4Fszlq/7Zv2nFz2G14/Db0r9t9XU6ihmt5htOUgPSzf4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Zfeerdiw; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-40ef9382752so7855e9.0 for ; Mon, 29 Jan 2024 11:00:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706554810; x=1707159610; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=YYJPquRBqD9Q7jzpQNCrCFu5Gx3v6qV+tI8wEy5zyow=; b=ZfeerdiwfxWViMskYXJhB+YweyCBokktAl4Zyr9iMcfE7BpBFSGXKdo1O0zSn1V9gv ufODj1TKQLdH4T7l2Lll6fPA+bmKijB930YahEfHDIqJnB/24Nt+96Id7kywbe/eJ2Q1 M3xvL0T/xWV/Fjk8g8e+/ADMXDPeg0ZqXjCU1fz788w0mpdXlyuBgN76hTkCgsrg8TY+ y6K85VlVkiWgTSm1HjrX9p0RN3RewVKeiG1+2yXqh9Cg+jpwyHieHEa1aJU/gqmsCXUe v0lkDrm+jh3jw8aWyuEgvLtrv3I3DA1E3VxraSdXbLPeVc7LI/0rn7UD2BehOkkGQRyf Enjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706554810; x=1707159610; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YYJPquRBqD9Q7jzpQNCrCFu5Gx3v6qV+tI8wEy5zyow=; b=ZciO3GZJmq1ZQ4LEFggz2bh/Tt4kgrzDhB9zTdZhJMQYceJNxYTSbBLMRN6iWAANNj YATt1elvyT6Mub0wG3AnEIaTcrVCQ5J9HIqndxigTgfzhgfyYR+0g3MOVnTicAkr6L4l J4uu2G5Fg/xrw8UomuOa9JioZtmkmh4s5l7yrQhKZ8Qs1OhEIprxPcmTY/MvDjFFv9DU M4AAOi1XROP5/gbpgPT6lta+FdV+KccSRUdNr1F7NRydtN5zldCkM3yJ95bl/GKkey6u B+O7U7Fy0Y5usApeXSxmwFf3PVW9ZQYaXLazUGzbzD33PYiP75fvTcOvl3OGHw58njxc Pi1A== X-Gm-Message-State: AOJu0Yz37uzTO9lWIrxRy745NQMnnOe5p9Q+RdvbDb0LlB4Fg/cKaueM d/8QetUGI5hSxz5HVtcWpf3CjyuEQwQAtq7jj0IrTURtrWqNAyNu3b5jvtAajRjQKF5Dk75Z8PW 4r/D1+ZMT31SoEJzzm71bkb+VF18rxSuruT2v X-Received: by 2002:a05:600c:c12:b0:40d:839b:7844 with SMTP id fm18-20020a05600c0c1200b0040d839b7844mr14670wmb.6.1706554809639; Mon, 29 Jan 2024 11:00:09 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240129175033.work.813-kees@kernel.org> <20240129180046.3774731-1-keescook@chromium.org> In-Reply-To: <20240129180046.3774731-1-keescook@chromium.org> From: Fangrui Song Date: Mon, 29 Jan 2024 10:59:55 -0800 Message-ID: Subject: Re: [PATCH 1/6] ubsan: Use Clang's -fsanitize-trap=undefined option To: Kees Cook Cc: Marco Elver , Nathan Chancellor , Masahiro Yamada , Nicolas Schier , Nick Desaulniers , Bill Wendling , Justin Stitt , linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, Andrey Konovalov , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jan 29, 2024 at 10:00=E2=80=AFAM Kees Cook = wrote: > > Clang changed the way it enables UBSan trapping mode. Update the Makefile > logic to discover it. > > Suggested-by: Fangrui Song > Link: https://lore.kernel.org/lkml/CAFP8O3JivZh+AAV7N90Nk7U2BHRNST6MRP0zH= tfQ-Vj0m4+pDA@mail.gmail.com/ > Cc: Nathan Chancellor > Cc: Masahiro Yamada > Cc: Nicolas Schier > Cc: Nick Desaulniers > Cc: Bill Wendling > Cc: Justin Stitt > Cc: linux-kbuild@vger.kernel.org > Cc: llvm@lists.linux.dev > Signed-off-by: Kees Cook > --- > scripts/Makefile.ubsan | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/scripts/Makefile.ubsan b/scripts/Makefile.ubsan > index 4749865c1b2c..7cf42231042b 100644 > --- a/scripts/Makefile.ubsan > +++ b/scripts/Makefile.ubsan > @@ -10,6 +10,6 @@ ubsan-cflags-$(CONFIG_UBSAN_DIV_ZERO) +=3D -fsa= nitize=3Dinteger-divide-by-zero > ubsan-cflags-$(CONFIG_UBSAN_UNREACHABLE) +=3D -fsanitize=3Dunreach= able > ubsan-cflags-$(CONFIG_UBSAN_BOOL) +=3D -fsanitize=3Dbool > ubsan-cflags-$(CONFIG_UBSAN_ENUM) +=3D -fsanitize=3Denum > -ubsan-cflags-$(CONFIG_UBSAN_TRAP) +=3D -fsanitize-undefined= -trap-on-error > +ubsan-cflags-$(CONFIG_UBSAN_TRAP) +=3D $(call cc-option,-fs= anitize-trap=3Dundefined,-fsanitize-undefined-trap-on-error) > > export CFLAGS_UBSAN :=3D $(ubsan-cflags-y) > -- > 2.34.1 Thanks for the patch. Clang has had -fsanitize-trap=3D since 2015. GCC added -fsanitize-trap=3Dundefined in 2022 (https://gcc.gnu.org/git/gitweb.cgi?p=3Dgcc.git;h=3D2c7cfc7b418564 ; milestone: 13.1), so we cannot use -fsanitize-trap=3Dundefined unconditionally. Reviewed-by: Fangrui Song -- =E5=AE=8B=E6=96=B9=E7=9D=BF