Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp509067ybg; Wed, 3 Jun 2020 06:38:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkTz0PYAm5AX0OD2pQHyyOyq3CRTDNl8R5gjz8eW7P6K7rHFL8pfJ7JaR9qUDsCWdXvrL3 X-Received: by 2002:a17:906:6888:: with SMTP id n8mr10693342ejr.159.1591191494132; Wed, 03 Jun 2020 06:38:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591191494; cv=none; d=google.com; s=arc-20160816; b=cc8eFF0YqcK0Ly+n28J2SMMXBaFy2otumYm4t+SZp7c6090NufUbBmwJBVcVEBm+25 rEuthSZjfGt7m4Qt2/eE8Ysdx0f0w6HZ9/4Ju++aJRWThI2bzE6J4OlBV7Zu+5s3vTfb FKZb6NfswM418fVE73DaFaS7t2pVYInZRCor8FecGRQ/npBeBBpTKuEBz5nmLENKJg52 sGWgJ1ZUJG5/XD4RAYwOoSNweEOL9dt1Yuoe5MLvc4XIFQdrrpPGwIozxbkWmaUghPCg tvYTqlPg0paBKTDCYnVriaGvnW1szDWwWt8shf5cVk0lvuZZoP8qA7+Nq1pCuOncOmOz WUXw== 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=pzgEpVCSH7j0u78t2npqiORwBbG9mOLC23VmgaWMcFo=; b=nvlgf5nZ7nSRLO2uVVozntrvrQVREXi1Y2nr25lNKpSGTn8fEko94r57p1gM+7A0x6 KXRTrQIl6Xb/FN+d3Bcz8wjpXgtdNftVaP4TnPH+F3VlCmIQJoMRVmFmgWVZVC9jbayw cAjhlZc2bk2Cm38NQo4CZuHvGNVkCgGkR4Id1XlFoD0gA23Fhst48IwW6YjPCTgItIfa jBYwvZsI0KdlhKzJXUhhosTF0P5LGtOu7TLAJsVnWinkRMfWSV76drKFRKXL5XM9/KeN YdtoNfZJpCtHlk20q0FDf3ze3Umfc4TRhsu4rIxWXUfvAi8fANDZKqwp9AJ5I3Su5j64 DKSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ECLofNCH; 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 s12si506520ejx.234.2020.06.03.06.37.50; Wed, 03 Jun 2020 06:38:14 -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=ECLofNCH; 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 S1726095AbgFCNfs (ORCPT + 99 others); Wed, 3 Jun 2020 09:35:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725834AbgFCNfr (ORCPT ); Wed, 3 Jun 2020 09:35:47 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCCB8C08C5C0 for ; Wed, 3 Jun 2020 06:35:47 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id d66so1627134pfd.6 for ; Wed, 03 Jun 2020 06:35:47 -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=pzgEpVCSH7j0u78t2npqiORwBbG9mOLC23VmgaWMcFo=; b=ECLofNCH7i+cIDW5jy4tA+xf9SFcjMlXzeqL0/Ao+Vl6TKXjvRBa2ipwaDwIv7fhOL /ImqoSGDCkVIXmzM53YUFCnPUET9KkM8gaDnFVXGHiUyyFWQGHgQuKn9IMelqYO0GtzL HV6fF4cA0pOzr3HmdsK2a9n2kX8r06neqj9aPq4AJ0m8Y+Glu+9pNBwRwDXv08vyrpRk eV0V/1JBcPU2TW7F+OFc59F/Yohdmv4PCgjKdFvDWSz4nyA6Sgp6/I9VcmAsjShvktys 8cOicfrwsTS/cX1dLGmP4lNlnXoNUxmc3OP/ED8B+LQ9YE9nLS5/7YzMGJJoHzkRAgNZ BLzg== 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=pzgEpVCSH7j0u78t2npqiORwBbG9mOLC23VmgaWMcFo=; b=rG+P6Y4TBJ/PT4U9Sd8AE+YR7KQICXY4mm+EWKFU4zIDcbYm43XEc6G0RNybWdXSCm Mi5Hwpw74q8E6AQvWGD3OkcefpBcw281yNpVX4uM0VKrnrToUNkUCEWEZI4ezarIi3Lg pPIs1F6AQ8eGLY4wHCbaUYtR/7nW2kbsDh0PslYtvcTfTiqnF5UyEnxuKLAP8z5PHKy3 94oTjxim0trQdqJsHOi2DtAgHlnd6L2PbCSaO0bXHUhpbNJPmZxb2nvsMnFm3IaSu9VQ hxhWxtpWvSytdY2kIuRUt5H7vFBP4lRt66yMn7pSoAkGdLpOpHClDPlNCUZwUJpZGtkB ismg== X-Gm-Message-State: AOAM533nN6ud/JRYC1iVE/9hcLOXZnUJbKSFmjcu/5h3Y+yDFUG/MKTB 8sASE5Z4moALlu+LXXd9kVIM0Kfu0F/7L1pZCLAItw== X-Received: by 2002:a17:90b:1981:: with SMTP id mv1mr5878381pjb.41.1591191347177; Wed, 03 Jun 2020 06:35:47 -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: Andrey Konovalov Date: Wed, 3 Jun 2020 15:35:36 +0200 Message-ID: Subject: Re: [PATCH -tip 2/2] compiler_types.h: Add __no_sanitize_{address,undefined} to noinstr To: Marco Elver Cc: Will Deacon , Peter Zijlstra , Borislav Petkov , Thomas Gleixner , Ingo Molnar , clang-built-linux , "Paul E . McKenney" , Dmitry Vyukov , Alexander Potapenko , 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 8:44 PM Marco Elver 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 Acked-by: Andrey Konovalov > --- > > 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__ */ > > -- > 2.27.0.rc2.251.g90737beb825-goog >