From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EAFAC433E2 for ; Mon, 14 Sep 2020 21:17:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E37C1208B3 for ; Mon, 14 Sep 2020 21:17:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="gnDqleJF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726046AbgINVRz (ORCPT ); Mon, 14 Sep 2020 17:17:55 -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-Google-Smtp-Source: ABdhPJxjub95+5dDKi00tb/Da2i1oajSsikg4UGw9vf1zvL6UGwb/mS50BQN7Q/j8wmacDIAUdFy2S5MHc9JZU28vt0= 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1B0CC43461 for ; Mon, 14 Sep 2020 21:17:56 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 49B7D215A4 for ; Mon, 14 Sep 2020 21:17:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="gnDqleJF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 49B7D215A4 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 828034B4A5; Mon, 14 Sep 2020 17:17:55 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mnVMbZ6EYeEq; Mon, 14 Sep 2020 17:17:54 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 6F17A4B5A4; Mon, 14 Sep 2020 17:17:54 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 80B9F4B59A for ; Mon, 14 Sep 2020 17:17:53 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 57X-Kg23uQBE for ; Mon, 14 Sep 2020 17:17:52 -0400 (EDT) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 610D54B58D for ; Mon, 14 Sep 2020 17:17:52 -0400 (EDT) Received: by mail-pf1-f196.google.com with SMTP id w7so640460pfi.4 for ; Mon, 14 Sep 2020 14:17:52 -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=tJkY9VcsvM8XTCGjt+P9eePo0os1AzkGnl/xrMoIifyHB5jZ6P8gWjYUm+eizImZEN 8jIyuWFmruVlfo6yubmIWd+/T8n6QLL5EfKPZ9jO+kzdOrya3L/FRl8Vy11E9wFfMB6x R2b8hI76w8t0TJQQsvsvLu28kQgob3oZQtCfpBZeOrqA8q2iHgM6Qz4fBt3hKMKjWPFE I90YhY1LBUG5M4GMXqiuM2iLpTL1A7bsmJGsBNl6H6HIflxeQ6S2ya0iz5E95IhgSFtA QxeEWO7N1GAOOMhsNDiTSA+SQxvTsDHUPlNJnTjtljo+IzSm6csG3KOkbXBHgPbcxq/a 9kOA== X-Gm-Message-State: AOAM533/AE6t15joWNynFn17oFJjwTVrDasJ3uy1G3gdyrte3aLAS8Zv tXvgT5HkKnsEh59gvXCXlBC4GJp49A2YM5WLovTuXg== X-Google-Smtp-Source: ABdhPJxjub95+5dDKi00tb/Da2i1oajSsikg4UGw9vf1zvL6UGwb/mS50BQN7Q/j8wmacDIAUdFy2S5MHc9JZU28vt0= 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: Thomas Gleixner , Catalin Marinas , Will Deacon , kvmarm@lists.cs.columbia.edu, Fangrui Song , Marc Zyngier , Masahiro Yamada , clang-built-linux , Linux ARM , kernel-dynamic-tools , Marco Elver , Kees Cook , Arnd Bergmann , Linux Kbuild mailing list , Mark Brown , Nathan Chancellor , Dmitry Vyukov , Michal Marek , LKML , Andrew Morton X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu + 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 _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CF5DC433E2 for ; Mon, 14 Sep 2020 21:19:55 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BCC9D208B3 for ; Mon, 14 Sep 2020 21:19:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="GFlToYDk"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="gnDqleJF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BCC9D208B3 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=C+6QFFUJdAefraeQgPH3SLxXq726BAF0R0kgqYRNynU=; b=GFlToYDkFh5SNVRx4wrpHcLKp niQeYcnCHEo0harR/Ke+D3uzC+ZOFF5NxzGjQFZoTH1Py/gML6wMBd1YvR/hMfd2bIXl0ODSC3aKI LpDNo8XbMgrzJzh718qXplln140MeoqerFb6bNhAMJ7KWAx2IkaoZ1WktPpzmxgx+MmzsNVrzcmQV 7ioktGTPomYqJn3OlwIwF0/GRd6gyrojEDRpj6OOtuHZ7E52K1eVY/PVeGyumDxbwmHMY7p7SBQjb ZgQIxuuMMyDormvI0sIUHXiM1VcXOP6W38rgMhKKldZhtu7jkZunAR2o4/ENL/1vsmSPkDqnSlgWF 36NI+IHnQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHvrJ-0000fU-MV; Mon, 14 Sep 2020 21:17:57 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHvrH-0000f4-5l for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2020 21:17:56 +0000 Received: by mail-pf1-x441.google.com with SMTP id o68so649608pfg.2 for ; Mon, 14 Sep 2020 14:17:53 -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=Ywie33yfzX2AmpTQXp57Ijl+wpGTLSi/eO8AKV3G4mmYg6V1h1vVNhEuKp0ar16i3V HUqCNuTSjes4szpvfk5uRASuKmW/km2nyPX2XxALxgE61WVcq1ogptIkjagJkAj0jb5N +YczkByAAEne5HMWQyxLvhdSjpjZrkJfQwr4/VNAZTtQjO6pkCEwKzoTyND7YtP/8kkN 3OjWEvPdqfiVphsWNCV8UXbRSmqzwKhykTghyRWWgAuWCUzOEsvCguYH39gDbtvzcJYA mh4vGdqI/vIuqTyDK91IKsBqqt+pB3AD0nElOMpo4TGgRovdOgmajB5pOgxSJNtUGmGa xVOg== X-Gm-Message-State: AOAM533wnc5DIaWBl6GAmNjqZsQ7Ui1NeoWk2wsH5jePgo3BIl7hew3A +yEo7aETxSVy706EXsVPzZdPKlWRJnq0FweZRjzVNw== X-Google-Smtp-Source: ABdhPJxjub95+5dDKi00tb/Da2i1oajSsikg4UGw9vf1zvL6UGwb/mS50BQN7Q/j8wmacDIAUdFy2S5MHc9JZU28vt0= 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200914_171755_272435_4D6710DF X-CRM114-Status: GOOD ( 21.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Gleixner , Catalin Marinas , Will Deacon , kvmarm@lists.cs.columbia.edu, Fangrui Song , Marc Zyngier , Masahiro Yamada , Suzuki K Poulose , clang-built-linux , Linux ARM , David Brazdil , Julien Thierry , kernel-dynamic-tools , Marco Elver , Kees Cook , Arnd Bergmann , Linux Kbuild mailing list , Mark Brown , ascull@google.com, Nathan Chancellor , Dmitry Vyukov , Michal Marek , LKML , James Morse , Andrew Morton Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel