Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3435976ybv; Sat, 15 Feb 2020 20:47:34 -0800 (PST) X-Google-Smtp-Source: APXvYqxzc7ccSKSFfd4PtSxixkVzOo2/T5LJDaLiAx5wl0zh0jMgcFJGVxNgoUf0tMS+HrrQaIpI X-Received: by 2002:aca:90f:: with SMTP id 15mr6624035oij.18.1581828454296; Sat, 15 Feb 2020 20:47:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581828454; cv=none; d=google.com; s=arc-20160816; b=PQ5xUi6on6A9EBmMeU9l4WXbMnUn19MS4SGYG9auW4PaLCdKv2SjivQlFva2tfydEU 9o/O9qLmaEcBM8l3tQduCs9nAAIqHxcAzj2338lZToZcwtP+uMTfTeKPgxbGtBUo+80k v5GZBPr8Mtln3DbmY+wdXU4WqUitI2cG/Nu/SGbCpXeSGyYfIut8OoO6TUQxTbML7yWd 8+RSLvw84r6Kl2iuy4eH7pg45Gt0zrcfHUoD3goFLNmGvKs1EI6wXIa7Wt8aZpHyQYBJ 6G84paYxgc4mT0kh6HU1OfbhMXc3/9aTl4yuKwUj1XBHxiF/wu9JXIMc6oACEbt52kBO ebeQ== 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:dkim-filter; bh=kRDtLlY/sMJu/K4srmxboOx3IqTLY+xR78bIUykXjLE=; b=nBgkdOnzo8hy8gdTGRuG7YG1dZC4zQiLtckf5Qa6aCL7jETU/3kuOr5ELccgK6QUt3 0qBa5Y4oVB/q8XAbVKnLN1MFcXlV9oeUH1GDHCfwDthWQ56oXHf+yhDuPBBjZmoEardp 0/vYMX6+4faP0ScbGBBwfveGHUHUzdsxuOr+raN2UziWqDpxhT6l1IZRUxnVg+wZ3ug8 d2ub43ttSyJdz+klvgXtu/ZnUcZ4wlv6vvEHv8M42LQEKzdwHd8Tk/1luq7ws6UOQvJx zshg60k7AIuohKfHomWAnJij99hLEASFLCNaj7Yy6oivDK0jeHTH66Br5moLTGMadNM8 pRaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=KxDBp5N+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b191si4753188oii.266.2020.02.15.20.47.06; Sat, 15 Feb 2020 20:47:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=KxDBp5N+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727640AbgBPEqy (ORCPT + 99 others); Sat, 15 Feb 2020 23:46:54 -0500 Received: from conssluserg-02.nifty.com ([210.131.2.81]:42736 "EHLO conssluserg-02.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726634AbgBPEqy (ORCPT ); Sat, 15 Feb 2020 23:46:54 -0500 Received: from mail-vk1-f175.google.com (mail-vk1-f175.google.com [209.85.221.175]) (authenticated) by conssluserg-02.nifty.com with ESMTP id 01G4knUL018848; Sun, 16 Feb 2020 13:46:50 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-02.nifty.com 01G4knUL018848 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1581828410; bh=kRDtLlY/sMJu/K4srmxboOx3IqTLY+xR78bIUykXjLE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=KxDBp5N+FL3ryREMNWh/kC/WEIPSOjGnWsw8xE5DqYJYm/K+KuoAuycSwv59Ov+LX q6qXypmIoU14tfcczuA+3VGbNP7daCHYwLx7/wTuY+OFfEKvyiQoeIBJS3dtc4h4V5 koIvsXNcZ4mgEdEk6HHlIHdFtgsmYaSzZZsROHnL5wviWdbRlmhNWgWd/90Tfi+3ws 03URtjD0FFe0x2pculeWmv/jECotLzXiCYRM9lkY/2A8kn1bai2Jbm1yW6QVuWkUnP SlP4p8R1pKTrMrreqy19bpjl1Tmu6KDx4SHFfl4ikcHegmh2OqpUZwv1CwGAiI8Axa aoHjuhND/bDxQ== X-Nifty-SrcIP: [209.85.221.175] Received: by mail-vk1-f175.google.com with SMTP id w4so3691431vkd.5; Sat, 15 Feb 2020 20:46:50 -0800 (PST) X-Gm-Message-State: APjAAAXPUu5vjDJOY+e3qc099lEvASJCtFYy7meqXTh55SzlIlvwds0v 1yhOmnCTudYfmL/1oQRM87op/rjbmQb/CHca16A= X-Received: by 2002:a1f:bfc2:: with SMTP id p185mr2951268vkf.73.1581828408908; Sat, 15 Feb 2020 20:46:48 -0800 (PST) MIME-Version: 1.0 References: <20200201062459.7150-1-changbin.du@gmail.com> <20200201062459.7150-2-changbin.du@gmail.com> In-Reply-To: <20200201062459.7150-2-changbin.du@gmail.com> From: Masahiro Yamada Date: Sun, 16 Feb 2020 13:46:13 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] sanitize: Add SANITIZE_xx.o and SANITIZE to disable all sanitizers for specific files To: Changbin Du Cc: Andrey Ryabinin , Alexander Potapenko , Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , X86 ML , Andy Lutomirski , "open list:DOCUMENTATION" , Linux Kernel Mailing List , Linux Kbuild mailing list 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 Hi Changbin, On Sat, Feb 1, 2020 at 3:25 PM Changbin Du wrote: > > This patch add two new flags to disable all sanitizers (UBSAN and KASAN): > o SANITIZE_xx.o - disable all sanitizers for a single file. > o SANITIZE - disable all sanitizers for current directory. > > Signed-off-by: Changbin Du > --- > Documentation/dev-tools/kasan.rst | 12 ++++++++++++ > scripts/Makefile.lib | 4 ++-- > 2 files changed, 14 insertions(+), 2 deletions(-) > > diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst > index e4d66e7c50de..f59fc5fb2cd8 100644 > --- a/Documentation/dev-tools/kasan.rst > +++ b/Documentation/dev-tools/kasan.rst > @@ -55,6 +55,18 @@ similar to the following to the respective kernel Makefile: > > KASAN_SANITIZE := n > > +Similarly, to disable all sanitizers (KASAN, UBSAN) for specific files or > +directories, add a line similar to the following to the respective kernel > +Makefile: > + > +- For a single file (e.g. main.o):: > + > + SANITIZE_main.o := n > + > +- For all files in one directory:: > + > + SANITIZE := n > + > Error reports > ~~~~~~~~~~~~~ > > diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib > index 3fa32f83b2d7..9b7d784e3252 100644 > --- a/scripts/Makefile.lib > +++ b/scripts/Makefile.lib > @@ -122,13 +122,13 @@ endif > # > ifeq ($(CONFIG_KASAN),y) > _c_flags += $(if $(patsubst n%,, \ > - $(KASAN_SANITIZE_$(basetarget).o)$(KASAN_SANITIZE)y), \ > + $(SANITIZE_$(basetarget).o)$(SANITIZE)$(KASAN_SANITIZE_$(basetarget).o)$(KASAN_SANITIZE)y), \ I think this would be very unlikely to happen, but if both SANITIZE and KASAN_SANITIZE existed, KASAN_SANITIZE should take precedence over SANITIZE, maybe? Perhaps, like this? $(KASAN_SANITIZE_$(basetarget).o)$(SANITIZE_$(basetarget).o)$(KASAN_SANITIZE)$(SANITIZE)y > $(CFLAGS_KASAN), $(CFLAGS_KASAN_NOSANITIZE)) > endif > > ifeq ($(CONFIG_UBSAN),y) > _c_flags += $(if $(patsubst n%,, \ > - $(UBSAN_SANITIZE_$(basetarget).o)$(UBSAN_SANITIZE)$(CONFIG_UBSAN_SANITIZE_ALL)), \ > + $(SANITIZE_$(basetarget).o)$(SANITIZE)$(UBSAN_SANITIZE_$(basetarget).o)$(UBSAN_SANITIZE)$(CONFIG_UBSAN_SANITIZE_ALL)), \ > $(CFLAGS_UBSAN)) > endif > > -- > 2.24.0 > -- Best Regards Masahiro Yamada