Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2468486pxk; Mon, 14 Sep 2020 14:22:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0T3YxHcZnqXk35bvVveSyjlZbu6LH2L0+xCIBfhIXxLJVUaUbhiYi3TMJ08CDxKE3MTcv X-Received: by 2002:a17:906:b097:: with SMTP id x23mr16204971ejy.21.1600118551022; Mon, 14 Sep 2020 14:22:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600118551; cv=none; d=google.com; s=arc-20160816; b=INwtA9DiKW6l6mLeEUVb0FUEFEUpR8atm8PlrulEiSSXYRlueHNt5BykErPyrXPeF8 s3et0X3W2k/kJREA0Lk4bYFmxe8LQMLkO64i4gOHlvi0uoR/mTplKccEFgiV/6wBE2Db bUb5/mqXvQD2ZqNKvs1AR8cAEqOiYoo1TZmzE9CsGJBTshl5ms6s/G6RzcvOpvn1x2vC L6IrT2MZ7FQ51IOV5nITgCfG/w391adiOSUjVcgz/f5aqyDLIbWHTT2ZVp7yYlfe9aAF JrS6vc5XpvC6JAPkA38MLFgbhdh9fRdG7kNlQ7T90EC8fElTsXftg4P8rOKwCPx6VBi0 i5UQ== 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=C7sgFtQoGvHj7+x9+CzUrIZAY69PKOdgVMUAIaHzDvk=; b=gw94arDu2DL2kgWG5eC8rBA94ARs3Lk+V8w/5pXzbEztVWwpbQdRFLEtMwTGQNmf33 zqr6GdJbJP9UDXJS8v1w96M6WON0ATdbKzuws6eEF+yTfOBslXP7VmnR0/JmSIPMWnyA ljC13aKrCsMptxLy8h2NPTBBhyC4dWfNyYpueQWvh7anFGEO2b6f/+1dqiWM0ZQvfbzI cagpKHIecf57Y8NP+vH5e3AEZNI7WZRzvBYSO6rYZq4UgjExEQQgF3/5X/3lpR5T2C2y 0DxxBKu3cyKSF3pU1l7ykZFxyV0xL27LYquSnyObaBB9JWlgSkcV7S5ZCDYqYLIetsD4 oz6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=gnDqleJF; 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 z13si4971919edx.167.2020.09.14.14.22.07; Mon, 14 Sep 2020 14:22:31 -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=gnDqleJF; 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 S1725999AbgINVRy (ORCPT + 99 others); Mon, 14 Sep 2020 17:17:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725920AbgINVRw (ORCPT ); Mon, 14 Sep 2020 17:17:52 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8B1FC06174A for ; Mon, 14 Sep 2020 14:17:51 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id c196so661614pfc.0 for ; Mon, 14 Sep 2020 14:17:51 -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=C7sgFtQoGvHj7+x9+CzUrIZAY69PKOdgVMUAIaHzDvk=; b=gnDqleJFU5cmc1mv/6wA2ZIagFuJ9D2lmUavjWv6EMmYdNLbqf6A5K8TJOdNg7N3FY mLuwcwvWwVMJQJrF2vg/ffFdc2javZdPcWINp34Ym7c19crbmYZ6x7dPhu+mEvQ/56Mt wXI10/4tolCDr+DmylqtpAkdoH72EKStTvyCo4DLIhzvt5QZhg6xpH43JtkExoMvKdNv LiH4JqsEpciJm2TR7hD6NTbttRz8qwE8OiW3LIT6n7PyHgKqCdDh80IzfCFVyqmWmdeJ ggSFYCBKX6oP4E5HLBAdw6dziC0aI3JUI14PFxwSd6FPjVSFMR3cn3pNJ4nX1aMKU4om qYbA== 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=C7sgFtQoGvHj7+x9+CzUrIZAY69PKOdgVMUAIaHzDvk=; b=jDRyn2Q4qXwj9mJ3i8pcDuqN6HTID7OglqNWrzXY9gttKhwAvvZRHg2gCtgYLsM/K2 JacXAuiyT8ltbTBbSCq91gfu/O5eEfg+lPBeGu/wCfSYLaE9ng27d0e0GjFFslkawcRO DuQr2CquuIOn5bKeBu3qT5Qb2v5K8HWa5hyy2adWCVi+g1FAUss0hXIsJkaB7uugXhFU 26OVuqF5mC9yZDXWanIKuRnDxXOetfyU9vJ/PM2PaQWO/2dwQrbLYWWHeebTvbZ8N4s2 b0MDnm9yt9FHq5OFaMy2HZPn+IIcMx4tDkDq/yQdr4XZDnr2oIzQKyEqzj5prHGFJCQi 3LaA== X-Gm-Message-State: AOAM530ZTxZCoPkbXCASuRXu97eXHS+Y/R3WRT5EqGL/0AwsDM3TaCRT oLAeqsjQ+VLQap15jIJiznpNKgnfbm0SJ8qf1nHsFw== X-Received: by 2002:a63:7882:: with SMTP id t124mr2686911pgc.381.1600118271305; Mon, 14 Sep 2020 14:17:51 -0700 (PDT) MIME-Version: 1.0 References: <20200914172750.852684-1-georgepope@google.com> <20200914172750.852684-7-georgepope@google.com> In-Reply-To: <20200914172750.852684-7-georgepope@google.com> From: Nick Desaulniers Date: Mon, 14 Sep 2020 14:17:39 -0700 Message-ID: Subject: Re: [PATCH 06/14] Fix CFLAGS for UBSAN_BOUNDS on Clang To: George-Aurelian Popescu Cc: Marc Zyngier , Catalin Marinas , Will Deacon , Masahiro Yamada , Michal Marek , Linux ARM , kvmarm@lists.cs.columbia.edu, LKML , Linux Kbuild mailing list , clang-built-linux , James Morse , Julien Thierry , Suzuki K Poulose , Nathan Chancellor , David Brazdil , Mark Brown , Fangrui Song , ascull@google.com, Kees Cook , Andrew Morton , Dmitry Vyukov , Marco Elver , Thomas Gleixner , Arnd Bergmann , kernel-dynamic-tools 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 + kernel-dynamic-tools to help review. On Mon, Sep 14, 2020 at 10:28 AM George-Aurelian Popescu wrote: > > From: George Popescu > > When the kernel is compiled with Clang, UBSAN_BOUNDS inserts a brk after > the handler call, preventing it from printing any information processed > inside the buffer. > For Clang -fsanitize=bounds expands to -fsanitize=array-bounds and > -fsanitize=local-bounds, and the latter adds a brk after the handler > call > > Signed-off-by: George Popescu > --- > scripts/Makefile.ubsan | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/scripts/Makefile.ubsan b/scripts/Makefile.ubsan > index 27348029b2b8..3d15ac346c97 100644 > --- a/scripts/Makefile.ubsan > +++ b/scripts/Makefile.ubsan > @@ -4,7 +4,14 @@ ifdef CONFIG_UBSAN_ALIGNMENT > endif > > ifdef CONFIG_UBSAN_BOUNDS > - CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds) > + # For Clang -fsanitize=bounds translates to -fsanitize=array-bounds and > + # -fsanitize=local-bounds; the latter adds a brk right after the > + # handler is called. > + ifdef CONFIG_CC_IS_CLANG > + CFLAGS_UBSAN += $(call cc-option, -fsanitize=array-bounds) You can remove the cc-option check above; Clang has supported this option for many releases. (One less compiler invocation at build time, FWIW). You cannot remove the below cc-option; GCC only implemented that sanitizer in the 5.0+ releases; the kernel still support GCC 4.9. > + else > + CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds) > + endif > endif > > ifdef CONFIG_UBSAN_MISC > -- > 2.28.0.618.gf4bc123cb7-goog > -- Thanks, ~Nick Desaulniers