Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2494105pxk; Mon, 14 Sep 2020 15:14:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzug4dA3U2GxZE6fEugr7Ev8lpKuUEzWWWK7+A0zwwm4llgk0k/2AqYIfeALnlV5fku789a X-Received: by 2002:a05:6402:48a:: with SMTP id k10mr19801430edv.22.1600121681780; Mon, 14 Sep 2020 15:14:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600121681; cv=none; d=google.com; s=arc-20160816; b=ql1kJFeIp7pSSSnH+uVA/9vqxUS2TKjEXVJG++y656OD6CSNV+asV4o14fri0RLdFK qIBlXtEUJ/W+GgQlemkPn6gMuyIEw0pFoem0hxJ1Td52D8Jb54n7e6x3f6Wwu/NXWSs7 LGDfpobv4dDeEMrP0kaJqQ/yREWeylYO/SHvdHcFiQvCkKKuu7eo9ZOS3JNpIGjUKJWG 9gTxxnVvZkpwYzfZPRsdQN9imKhS7UkRX3YvokcadX3UIpty6B9HGtqwUfypyu+mpoB2 WoLP4ex01C4hlhbZm4l6Oi/af0aYt8Qw4+Ur2LfjlzlIVk1eX8onm7cChGglXYxMzmZM c7nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=XKHeWnZTmr+44PA1uk+tmIoZZMZNVyaEbUZsmkorfxM=; b=q4fN4N/bhCMycWemTVDdZfxlkXnQ/xMfhuD0sOHzUA3wz5tZaR39VEt4A6Ek4W7sQJ MVIn2PXcCZhaKPf1gjxD9p7JLvRLJz331GPBsnav1PF7wH+66WjbK3Qbmx9OELuE6IEw UStQ9iamFisrvpHb4DxtG86ehudzvfVv82mvH9368d/D2jkxhYqmaQXziCnDlwZ3GRC3 e9FVjA2AffZ3YqtJKJGGbs3oitSzsixrpzLJgYSLHUXo5mHkia/rgzdd5Q2iTqJjN5Dt M7GNWi3SzOcb0Y+ktQBriQo3NXKL0GbNHs9sLoOduRdVx5gBqTc6H2m41KuodvZR5fXw XI+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FLfu5qkp; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g10si8432830edv.47.2020.09.14.15.14.20; Mon, 14 Sep 2020 15:14:41 -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=@chromium.org header.s=google header.b=FLfu5qkp; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726062AbgINWNT (ORCPT + 99 others); Mon, 14 Sep 2020 18:13:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725926AbgINWNR (ORCPT ); Mon, 14 Sep 2020 18:13:17 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF7E7C06174A for ; Mon, 14 Sep 2020 15:13:16 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id r19so231771pls.1 for ; Mon, 14 Sep 2020 15:13:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=XKHeWnZTmr+44PA1uk+tmIoZZMZNVyaEbUZsmkorfxM=; b=FLfu5qkpDm7o5/xP0ilZmNxVe+jdmcJEkTL/4DGLQ5xUBs9smNtW0pRVX074Wodffb QUGa2sH5fudwFrwS49G9uXA9hzulhM+YqeS3JvomF2XSTDvvz161Ko8MHkn/a5Vkn26o 2wUHbRjJ9JT+dslYXV4aBJuwNU5aQBs5Tz/Pg= 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=XKHeWnZTmr+44PA1uk+tmIoZZMZNVyaEbUZsmkorfxM=; b=mh1vGBr5VEmuCt1qDxWtdQNa+lpZH4faX10yUKj+QiI08OUfd5miOsNmSXNPu/cwFy WONQixvQC4CQLKgJ798kphzI5dSGgxT1k9Uxq0MHtX4gHZTEG3gK+eYJSsQ8wkIGZj6A joy2Vn73AMWNwL2/dycA0WaQKFgQnKykEEskzStXQIdMakBUPHdLd9f7V9XqhAt2HeUm gtO/k5vC0bxtmIKZpVad4H/w8Yhqo2XZbO5yn97NOTiCai+r2KLwEVy+PL1Z/OZ5ACwU qMw58KqSU36a4eOd/Ad0mKhOvUT1P7MvRzUCPbPKFlYqVvRLpcef01zRlaEplKhN98lz KgOw== X-Gm-Message-State: AOAM533JdqQ/R/RuxDvbM47aZ8XRqHqan+hYxoFEGDutov2b+cV7hVPC St128ReqgW+VQv7IYR8chUOf7Q== X-Received: by 2002:a17:90b:3505:: with SMTP id ls5mr1284670pjb.105.1600121596214; Mon, 14 Sep 2020 15:13:16 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id i187sm9130990pgd.82.2020.09.14.15.13.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 15:13:15 -0700 (PDT) Date: Mon, 14 Sep 2020 15:13:14 -0700 From: Kees Cook To: George-Aurelian Popescu 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: <202009141509.CDDC8C8@keescook> References: <20200914172750.852684-1-georgepope@google.com> <20200914172750.852684-7-georgepope@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200914172750.852684-7-georgepope@google.com> 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 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? > 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? > + else > + CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds) > + endif > endif > > ifdef CONFIG_UBSAN_MISC > -- > 2.28.0.618.gf4bc123cb7-goog > -- Kees Cook