Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1508132ybg; Tue, 2 Jun 2020 11:53:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNK7skd3HF6Sf0HlzLS9XWiOuplm1pXmvJB5gSB4BAhgPHDNzQPfDs6a0PC8mFmC3Kk6QP X-Received: by 2002:a17:906:f2d9:: with SMTP id gz25mr26823350ejb.467.1591124017833; Tue, 02 Jun 2020 11:53:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591124017; cv=none; d=google.com; s=arc-20160816; b=vrivS/rYgC5Gbm4ivsE231isfz2B+WLiPZN9iZIWU9MwRemQmRUJwzysh91Bke+TCM jguON5y+gDFEuYUhgfD1O8DuK2Brv42TaWMFSCC+PN9zw3YmRYeuzvtLCDcXf9gN+Yga 4zzXaX6ca6tchu0787y/k/MIPc0iNSG73tSutHsF6EHl0dmjMEB4U6eYsn7ZTrBvBuW3 Fps2e5MiIC+BVZ+wTUWs60GpJ7K8THCLRn3m0Vqvn71vMnpeOMNq7DW0vzZNNWbWMOs2 2jBbui/2v5FeuNmsD8uPlfgy+mj8BljVoCsHOn8Ug7gTTUgFguL5/zzw5looo5bYGH7A 1BaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=5xlo4rK4g8fnalu7U0lbya/uKNvvM9T5qVFKFRMeKAc=; b=VVv8SuIu2WFxkU8H7AGezDNa86HchHAbgXIcLwKayOdnNSPQt26EfYpt0z0stWJS9K zQMy8qh26ubthd25CKx0ExIOzLGiMubBiCTxhtJtoNcvHQSgX3DQvwicjeQo5gRSw6om y4Y5FOXAIeBkb9KYYMmFdE+/zSCsHdpMsurL07k81zBbhCsD5ftWPGu6a8/IgYjTamj4 CRZTyZX/Nh5Vy5bjNpbPW3HdBc5Zd8UtKr1aMo1n+9i0kDtBRBTpdpoRMGWaC7AdRe+k BKM376U1PwwtKeTcDDjv+IfvssEgbNnwz0CJtjJHytxUDhj78h8Mhsmmbk5PLum4V59w u4/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Cmj2yrH3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce20si2178795edb.478.2020.06.02.11.53.14; Tue, 02 Jun 2020 11:53:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Cmj2yrH3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726373AbgFBStX (ORCPT + 99 others); Tue, 2 Jun 2020 14:49:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726000AbgFBStW (ORCPT ); Tue, 2 Jun 2020 14:49:22 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60B68C08C5C0 for ; Tue, 2 Jun 2020 11:49:22 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id d6so1972279pjs.3 for ; Tue, 02 Jun 2020 11:49:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5xlo4rK4g8fnalu7U0lbya/uKNvvM9T5qVFKFRMeKAc=; b=Cmj2yrH3qEvNmtyfHon2kKl7S72MckaUFizNRpDYa2PKNa4QFR1gb7MnhKguJRH84w hTS1vzbKiXdRyx0i4bWrJYJyRj7ry4Soppmro6CW+RvUpSWXKSJ3sH810c1zkOhsrukA 162KUUhbHn3rYn2vlmxII6COL2ffUg2ruVQH5TAUuyYhZIzv2hFNo64oX8grE+oKOe8O zAVw2A8hmOOVlhAsruoYkmT5gR5n+4jQM9qCHdR1qQdhkP96TV8MPM5JAHFbYmfD6UmS bu7cdQen0hfX6Lqm6cbTmYQDx2B6Bczq/4jNmwvLjmE7OV5i3qcNCfi/CjSoC0YF48mb X3fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5xlo4rK4g8fnalu7U0lbya/uKNvvM9T5qVFKFRMeKAc=; b=A0KIRtgKSTHLu7ubxHTCr7YNkDvlbLPYoDOV78AXQOkVM5XQs3RsLmUSeAgHCcXp25 Ph5RjyD0X6smLxMEa0zN8fM2Z4zPDbr1t5RIpyrw7rBg6O9K6xi/DMf8nNXPKUP/P8Tp Fnk81IyYruooATFwgUKjiFz++ZvkbDBEdD3o3lqWBECdaXnplUGRIijmqMCwOwTxJYsR HQ7xqjeZf6oY3zCh1JuC31Zwy/4thQ9JtG1CNlA7Ib0oQddrcIUSqGbahLZm+0oe3kVg mGuloI6AF1Mkp/9srL95SGqOnoUiEdyPRXtRaaU/Co5+LVY/sijFr3C4CCQK6DMYROk/ v0CQ== X-Gm-Message-State: AOAM531/jR0S2XStxvYz+obCx9EnR6OGhe29X6HhmGO8iK1N2yz274qh TPIOcRpUoShoEgVPpr6WQ3ve7AYE/PMaZbjpVctM8A== X-Received: by 2002:a17:90b:4c47:: with SMTP id np7mr601098pjb.101.1591123761720; Tue, 02 Jun 2020 11:49:21 -0700 (PDT) MIME-Version: 1.0 References: <20200602184409.22142-1-elver@google.com> <20200602184409.22142-2-elver@google.com> In-Reply-To: <20200602184409.22142-2-elver@google.com> From: Nick Desaulniers Date: Tue, 2 Jun 2020 11:49:10 -0700 Message-ID: Subject: Re: [PATCH -tip 2/2] compiler_types.h: Add __no_sanitize_{address,undefined} to noinstr To: Marco Elver , Miguel Ojeda Cc: Will Deacon , Peter Zijlstra , Borislav Petkov , Thomas Gleixner , Ingo Molnar , clang-built-linux , "Paul E. McKenney" , Dmitry Vyukov , Alexander Potapenko , Andrey Konovalov , kasan-dev , LKML , syzbot+dc1fa714cb070b184db5@syzkaller.appspotmail.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 2, 2020 at 11:44 AM 'Marco Elver' via Clang Built Linux wrote: > > Adds the portable definitions for __no_sanitize_address, and > __no_sanitize_undefined, and subsequently changes noinstr to use the > attributes to disable instrumentation via KASAN or UBSAN. > > Link: https://lore.kernel.org/lkml/000000000000d2474c05a6c938fe@google.com/ > Reported-by: syzbot+dc1fa714cb070b184db5@syzkaller.appspotmail.com > Signed-off-by: Marco Elver Currently most of our compiler attribute detection is done in include/linux/compiler_attributes.h; I think this should be handled there. +Miguel Ojeda > --- > > Note: __no_sanitize_coverage (for KCOV) isn't possible right now, > because neither GCC nor Clang support such an attribute. This means > going and changing the compilers again (for Clang it's fine, for GCC, > it'll take a while). > > However, it looks like that KCOV_INSTRUMENT := n is currently in all the > right places. Short-term, this should be reasonable. > --- > include/linux/compiler-clang.h | 8 ++++++++ > include/linux/compiler-gcc.h | 6 ++++++ > include/linux/compiler_types.h | 3 ++- > 3 files changed, 16 insertions(+), 1 deletion(-) > > diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h > index 2cb42d8bdedc..c0e4b193b311 100644 > --- a/include/linux/compiler-clang.h > +++ b/include/linux/compiler-clang.h > @@ -33,6 +33,14 @@ > #define __no_sanitize_thread > #endif > > +#if __has_feature(undefined_behavior_sanitizer) > +/* GCC does not have __SANITIZE_UNDEFINED__ */ > +#define __no_sanitize_undefined \ > + __attribute__((no_sanitize("undefined"))) > +#else > +#define __no_sanitize_undefined > +#endif > + > /* > * Not all versions of clang implement the the type-generic versions > * of the builtin overflow checkers. Fortunately, clang implements > diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h > index 7dd4e0349ef3..1c74464c80c6 100644 > --- a/include/linux/compiler-gcc.h > +++ b/include/linux/compiler-gcc.h > @@ -150,6 +150,12 @@ > #define __no_sanitize_thread > #endif > > +#if __has_attribute(__no_sanitize_undefined__) > +#define __no_sanitize_undefined __attribute__((no_sanitize_undefined)) > +#else > +#define __no_sanitize_undefined > +#endif > + > #if GCC_VERSION >= 50100 > #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1 > #endif > diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h > index 02becd21d456..89b8c1ae18a1 100644 > --- a/include/linux/compiler_types.h > +++ b/include/linux/compiler_types.h > @@ -198,7 +198,8 @@ struct ftrace_likely_data { > > /* Section for code which can't be instrumented at all */ > #define noinstr \ > - noinline notrace __attribute((__section__(".noinstr.text"))) __no_kcsan > + noinline notrace __attribute((__section__(".noinstr.text"))) \ > + __no_kcsan __no_sanitize_address __no_sanitize_undefined > > #endif /* __KERNEL__ */ > > -- -- Thanks, ~Nick Desaulniers