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 093C4C433E2 for ; Tue, 15 Sep 2020 10:25:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8A4F21D7B for ; Tue, 15 Sep 2020 10:25:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vbBJy4kw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726235AbgIOKZK (ORCPT ); Tue, 15 Sep 2020 06:25:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726102AbgIOKZD (ORCPT ); Tue, 15 Sep 2020 06:25:03 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 839D3C06174A for ; Tue, 15 Sep 2020 03:25:02 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id d4so2798666wmd.5 for ; Tue, 15 Sep 2020 03:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=nCObEKoOnmpHrzYJFBm9pkBKEq9SNCMkpHaxOskN+KQ=; b=vbBJy4kwOuP8fps7ENGxPva5zUYL7ASA78U0Ik7uGtyQwbCdxLIDc5R+Lkce3LiyG9 tLhWib3rO23PtT7aBoJi1Wh5s5YnYthzHConFQ9L9lfT5mJzO+PvYFbCpNkD3Y3Y5pV7 ccjX2TexQXkFDZFRXCF4Vu7sGsVYCi2n6CfR+ga+FrmT/CM19VfdHrlV+uoAyQb7Wnux Ua6jN3ov5SDmM4C4t32H7+HFTozTlN8q3kPzjcNZy74cI/nUj7maUu2W1Xv0iRcsns8V 7sMEIca6qA/KcCQnNsC8rCvlnSY3mxClh6VbPDZTXsnqTmoM6xWaK0XxddnzL4J3SJO6 b+3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=nCObEKoOnmpHrzYJFBm9pkBKEq9SNCMkpHaxOskN+KQ=; b=PeeopoQAlekOqLOE0E5lm7VHUkm9NYexnrhBgQdt00tFf0UEOoPxfxHOjZwjpEIkZT xqLl/0tGl0Zva1PTgjwHz7v8sWwIVgS4PlF607PfKIyKwJHB4380wmO1QrFeTh398b7C L8pD3y1zMZsqvveIaty/uaUhkOLrXmRAQ9QxXM9Tn5gM0HgXfuV/78oUk8/LgJ7L6nSf tdwvb4HiDAtsmIqUKz22bywZjWZxTu87iy23XcdVi52xTJu0stxpLP3vNc0f/c0yQXl7 r0GJQWan4FmCPDMotyG/p5EcHvhT8r9MY2/iJldOOoLMNxFtGGDyQprTMZpjjEWTDVSM yE6g== X-Gm-Message-State: AOAM530GSmw1QKW0E2ght80ZDPXlrUk71yBLvlEYQr6GQZrsXVXNEzEs Mrgcl9BK4RvSsUqaZzc8HxFu7w== X-Google-Smtp-Source: ABdhPJyLkeeoM2ZZcrGWaota2zFMVO2kAkBf28Jt84EjulN5M4ljnumj2SEmrORUfgsijOJP5ZWZqg== X-Received: by 2002:a1c:2e08:: with SMTP id u8mr4155025wmu.156.1600165500941; Tue, 15 Sep 2020 03:25:00 -0700 (PDT) Received: from google.com (49.222.77.34.bc.googleusercontent.com. [34.77.222.49]) by smtp.gmail.com with ESMTPSA id w15sm27651716wro.46.2020.09.15.03.25.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 03:25:00 -0700 (PDT) Date: Tue, 15 Sep 2020 10:24:58 +0000 From: George Popescu To: Kees Cook Cc: maz@kernel.org, catalin.marinas@arm.com, will@kernel.org, masahiroy@kernel.org, michal.lkml@markovi.net, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, clang-built-linux@googlegroups.com, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, natechancellor@gmail.com, ndesaulniers@google.com, dbrazdil@google.com, broonie@kernel.org, maskray@google.com, ascull@google.com, akpm@linux-foundation.org, dvyukov@google.com, elver@google.com, tglx@linutronix.de, arnd@arndb.de Subject: Re: [PATCH 06/14] Fix CFLAGS for UBSAN_BOUNDS on Clang Message-ID: <20200915102458.GA1650630@google.com> References: <20200914172750.852684-1-georgepope@google.com> <20200914172750.852684-7-georgepope@google.com> <202009141509.CDDC8C8@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202009141509.CDDC8C8@keescook> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 14, 2020 at 03:13:14PM -0700, Kees Cook wrote: > On Mon, Sep 14, 2020 at 05:27:42PM +0000, 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 > > That sounds like a compiler bug? Actually in clang 12 documentation is written that -fsanitize=bounds expands to that. GCC doesn't have those two options, only the -fsanitize=bounds which looks similar to -fsanitize=array-bounds from clang. So I don't see it as a compiler bug, just a misuse of flags. > > 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) > > This would mean losing the local-bounds coverage? Isn't that for locally > defined arrays on the stack? This would mean losing the local-bounds coverage. I tried to test it without local-bounds and with a locally defined array on the stack and it works fine (the handler is called and the error reported). For me it feels like --array-bounds and --local-bounds are triggered for the same type of undefined_behaviours but they are handling them different. > > + else > > + CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds) > > + endif > > endif > > > > ifdef CONFIG_UBSAN_MISC > > -- > > 2.28.0.618.gf4bc123cb7-goog > > > > -- Thanks, George 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 EA6C2C43461 for ; Tue, 15 Sep 2020 10:25:06 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 3790421D7F for ; Tue, 15 Sep 2020 10:25:05 +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="vbBJy4kw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3790421D7F 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 774AE4B209; Tue, 15 Sep 2020 06:25:05 -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 A9xLiFge+hkT; Tue, 15 Sep 2020 06:25:04 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 6FBE24B2B7; Tue, 15 Sep 2020 06:25:04 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 5F5B84B1F7 for ; Tue, 15 Sep 2020 06:25:03 -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 CYooSNS7yuvJ for ; Tue, 15 Sep 2020 06:25:02 -0400 (EDT) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 38F2F4B1F1 for ; Tue, 15 Sep 2020 06:25:02 -0400 (EDT) Received: by mail-wm1-f68.google.com with SMTP id w2so2828744wmi.1 for ; Tue, 15 Sep 2020 03:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=nCObEKoOnmpHrzYJFBm9pkBKEq9SNCMkpHaxOskN+KQ=; b=vbBJy4kwOuP8fps7ENGxPva5zUYL7ASA78U0Ik7uGtyQwbCdxLIDc5R+Lkce3LiyG9 tLhWib3rO23PtT7aBoJi1Wh5s5YnYthzHConFQ9L9lfT5mJzO+PvYFbCpNkD3Y3Y5pV7 ccjX2TexQXkFDZFRXCF4Vu7sGsVYCi2n6CfR+ga+FrmT/CM19VfdHrlV+uoAyQb7Wnux Ua6jN3ov5SDmM4C4t32H7+HFTozTlN8q3kPzjcNZy74cI/nUj7maUu2W1Xv0iRcsns8V 7sMEIca6qA/KcCQnNsC8rCvlnSY3mxClh6VbPDZTXsnqTmoM6xWaK0XxddnzL4J3SJO6 b+3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=nCObEKoOnmpHrzYJFBm9pkBKEq9SNCMkpHaxOskN+KQ=; b=CYpGvvAd1b+izYrUUG/38vWz+1mZvemEO/rs/DgUExw6ErMo1/Sv7PK9EK/SRTHPSV QMbBFJlzqwiJxwRjLqE8uP43qTYlv3PhExEX9bsaWBosHrW/eGmicu3kqvn1jq5+sK3U ajPG2BQcS4kUx3E+cDAcnBfdCZ6IuY9jdpwSThQdf2EbeHh5x258ChmdFAGnLo1htKee GlM1rFy6yIu4TREKkrLrvbbFRV/iH2q6y7rvRiOVcN2vK3wBOikC0JS/Y2ZQT5cqXjwa UxhkHsa9SWsOMdy2F9K4Nnho3RsxURwoVpgO/rePREPVBTgVBxmeMcESp5L7fAyL8ldX OAug== X-Gm-Message-State: AOAM532ptGXuekMeuV+BX3NLAhlKsUnuDc+e/CF330zfzW9NBr0Wflqz LeC0iCssyydxKpSe/JsqTZR8Cw== X-Google-Smtp-Source: ABdhPJyLkeeoM2ZZcrGWaota2zFMVO2kAkBf28Jt84EjulN5M4ljnumj2SEmrORUfgsijOJP5ZWZqg== X-Received: by 2002:a1c:2e08:: with SMTP id u8mr4155025wmu.156.1600165500941; Tue, 15 Sep 2020 03:25:00 -0700 (PDT) Received: from google.com (49.222.77.34.bc.googleusercontent.com. [34.77.222.49]) by smtp.gmail.com with ESMTPSA id w15sm27651716wro.46.2020.09.15.03.25.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 03:25:00 -0700 (PDT) Date: Tue, 15 Sep 2020 10:24:58 +0000 From: George Popescu To: Kees Cook Subject: Re: [PATCH 06/14] Fix CFLAGS for UBSAN_BOUNDS on Clang Message-ID: <20200915102458.GA1650630@google.com> References: <20200914172750.852684-1-georgepope@google.com> <20200914172750.852684-7-georgepope@google.com> <202009141509.CDDC8C8@keescook> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <202009141509.CDDC8C8@keescook> Cc: tglx@linutronix.de, catalin.marinas@arm.com, will@kernel.org, kvmarm@lists.cs.columbia.edu, maskray@google.com, maz@kernel.org, masahiroy@kernel.org, clang-built-linux@googlegroups.com, linux-arm-kernel@lists.infradead.org, elver@google.com, arnd@arndb.de, linux-kbuild@vger.kernel.org, broonie@kernel.org, natechancellor@gmail.com, dvyukov@google.com, michal.lkml@markovi.net, ndesaulniers@google.com, linux-kernel@vger.kernel.org, akpm@linux-foundation.org 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 On Mon, Sep 14, 2020 at 03:13:14PM -0700, Kees Cook wrote: > On Mon, Sep 14, 2020 at 05:27:42PM +0000, 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 > > That sounds like a compiler bug? Actually in clang 12 documentation is written that -fsanitize=bounds expands to that. GCC doesn't have those two options, only the -fsanitize=bounds which looks similar to -fsanitize=array-bounds from clang. So I don't see it as a compiler bug, just a misuse of flags. > > 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) > > This would mean losing the local-bounds coverage? Isn't that for locally > defined arrays on the stack? This would mean losing the local-bounds coverage. I tried to test it without local-bounds and with a locally defined array on the stack and it works fine (the handler is called and the error reported). For me it feels like --array-bounds and --local-bounds are triggered for the same type of undefined_behaviours but they are handling them different. > > + else > > + CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds) > > + endif > > endif > > > > ifdef CONFIG_UBSAN_MISC > > -- > > 2.28.0.618.gf4bc123cb7-goog > > > > -- Thanks, George _______________________________________________ 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=-12.7 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=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 150E8C433E2 for ; Tue, 15 Sep 2020 10:26:59 +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 785B421D7B for ; Tue, 15 Sep 2020 10:26:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PsLgG2uX"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="vbBJy4kw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 785B421D7B 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:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/CqlDcIoa1x4i/Ee3SVigmvE96hJaRJK0FjoU8uSCMo=; b=PsLgG2uXvSrZcw1pR4o+y0GwD Kx6d3ApppjXDlHCciWspDWVCeHj6YiDC3jkW6VGxSA0cKkIY+kGvsbpq/vnvrJ/xZvpqG0bIQ15Se rhRTtWcAwtcMyIVcDHDz0jBbgzWQS5lcxliUskJmJnrK9TXnVCRpXUrbFqPqX0ADLDX8VbE9g/Fv+ hUcgK8iyRjRrUW4mvdamuFBB5zivQSGdVTfOdrz0rcyFNs3ZtjMMTWf2s1n9b3q2o5g+CjhRg3Xlb VzFnXLpom1MQeDoVaDbcAjzRugik2g4WQOh2HPrdqq19j74aybCO4As2g6vVUgaDDSsX+IEh2H/hP wBuaZZnUg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kI89A-0005I4-4G; Tue, 15 Sep 2020 10:25:12 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kI891-0005H4-9e for linux-arm-kernel@lists.infradead.org; Tue, 15 Sep 2020 10:25:04 +0000 Received: by mail-wm1-x342.google.com with SMTP id x23so2812307wmi.3 for ; Tue, 15 Sep 2020 03:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=nCObEKoOnmpHrzYJFBm9pkBKEq9SNCMkpHaxOskN+KQ=; b=vbBJy4kwOuP8fps7ENGxPva5zUYL7ASA78U0Ik7uGtyQwbCdxLIDc5R+Lkce3LiyG9 tLhWib3rO23PtT7aBoJi1Wh5s5YnYthzHConFQ9L9lfT5mJzO+PvYFbCpNkD3Y3Y5pV7 ccjX2TexQXkFDZFRXCF4Vu7sGsVYCi2n6CfR+ga+FrmT/CM19VfdHrlV+uoAyQb7Wnux Ua6jN3ov5SDmM4C4t32H7+HFTozTlN8q3kPzjcNZy74cI/nUj7maUu2W1Xv0iRcsns8V 7sMEIca6qA/KcCQnNsC8rCvlnSY3mxClh6VbPDZTXsnqTmoM6xWaK0XxddnzL4J3SJO6 b+3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=nCObEKoOnmpHrzYJFBm9pkBKEq9SNCMkpHaxOskN+KQ=; b=T2jOXymkWKE0Ogai2NcXyUvQHUpCGSLk17PgpaS6+Aa1DsLh9dPmzJdim9vbco6F3V 5qcwGQQRB/f861S1bueo2zXXudg/PVZ6ji+n87Sba3yOfNyQVXK2Lf0lzsLC+nMV9/Ey pkDH8vACgs1xwXh1+pgfOPpce//HmWoL22iIe9FDlu38I+TFxCURVoUHeq9wJhrEfGJG nF1s4Xbw2qdqH/7UaNNh3QUwFIuLxQLqu0+H0mWo3C7SJOZdK3QsnYhXjlBlK85eekEW UEwetRf+sDjxlVBvOvMJpVrv/EpYjpKT7uZ2gOdmLt06JQYsy2eMoNfu2V+JwG0sU+Vy 2vlg== X-Gm-Message-State: AOAM531UpteKkJv798YYM2E4XMMmOXmdvoPm07OdzIFox/76syCjP0e1 JMB1FcTZNM2z1zPkDsDK6j9XGA== X-Google-Smtp-Source: ABdhPJyLkeeoM2ZZcrGWaota2zFMVO2kAkBf28Jt84EjulN5M4ljnumj2SEmrORUfgsijOJP5ZWZqg== X-Received: by 2002:a1c:2e08:: with SMTP id u8mr4155025wmu.156.1600165500941; Tue, 15 Sep 2020 03:25:00 -0700 (PDT) Received: from google.com (49.222.77.34.bc.googleusercontent.com. [34.77.222.49]) by smtp.gmail.com with ESMTPSA id w15sm27651716wro.46.2020.09.15.03.25.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 03:25:00 -0700 (PDT) Date: Tue, 15 Sep 2020 10:24:58 +0000 From: George Popescu To: Kees Cook Subject: Re: [PATCH 06/14] Fix CFLAGS for UBSAN_BOUNDS on Clang Message-ID: <20200915102458.GA1650630@google.com> References: <20200914172750.852684-1-georgepope@google.com> <20200914172750.852684-7-georgepope@google.com> <202009141509.CDDC8C8@keescook> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <202009141509.CDDC8C8@keescook> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200915_062503_460271_FC319BE6 X-CRM114-Status: GOOD ( 24.54 ) 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: tglx@linutronix.de, catalin.marinas@arm.com, will@kernel.org, kvmarm@lists.cs.columbia.edu, maskray@google.com, maz@kernel.org, masahiroy@kernel.org, suzuki.poulose@arm.com, clang-built-linux@googlegroups.com, linux-arm-kernel@lists.infradead.org, dbrazdil@google.com, julien.thierry.kdev@gmail.com, elver@google.com, arnd@arndb.de, linux-kbuild@vger.kernel.org, broonie@kernel.org, ascull@google.com, natechancellor@gmail.com, dvyukov@google.com, michal.lkml@markovi.net, ndesaulniers@google.com, linux-kernel@vger.kernel.org, james.morse@arm.com, akpm@linux-foundation.org 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 On Mon, Sep 14, 2020 at 03:13:14PM -0700, Kees Cook wrote: > On Mon, Sep 14, 2020 at 05:27:42PM +0000, 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 > > That sounds like a compiler bug? Actually in clang 12 documentation is written that -fsanitize=bounds expands to that. GCC doesn't have those two options, only the -fsanitize=bounds which looks similar to -fsanitize=array-bounds from clang. So I don't see it as a compiler bug, just a misuse of flags. > > 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) > > This would mean losing the local-bounds coverage? Isn't that for locally > defined arrays on the stack? This would mean losing the local-bounds coverage. I tried to test it without local-bounds and with a locally defined array on the stack and it works fine (the handler is called and the error reported). For me it feels like --array-bounds and --local-bounds are triggered for the same type of undefined_behaviours but they are handling them different. > > + else > > + CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds) > > + endif > > endif > > > > ifdef CONFIG_UBSAN_MISC > > -- > > 2.28.0.618.gf4bc123cb7-goog > > > > -- Thanks, George _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel