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=-6.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 BF79AC43461 for ; Thu, 17 Sep 2020 11:37:19 +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 5A6F920663 for ; Thu, 17 Sep 2020 11:37:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="TJuibtYV"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="MZtwfo2W" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5A6F920663 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=NRGo6XFLcJZTXqZZi24E6lNfjPJujVqaFHS94M0H3Ww=; b=TJuibtYV9yvlMf3YGtTvTWMmN QJk9mBt6EXdAVBRgoc1ml+oeJZYPpyBaWAiWW8GbLSf1F6DN48SntM8NkmX8j1r/AQJ90ayP72EH6 qz8QYTqwzo+U87q9MnnMdEfonLr5DA4BxMc2Bz5+/iNGd1TZlWYQ79D2iAKkR9LMQpPpT8lDM0iB2 p1sQerCZqVrMs7Gkh5OEAoHv7XDTLr8Yd+ZdW1GqBquUzTan/E4JD2lfuSP85vQnUOLGAL162+r84 Nyd0bRrvNiH2UmnyAGpvfKgGUakpL9fEnVE7enld6qQWIOvcxjcsUjV2a9BwRA2H+aKepPMd/Q7Ga t7/H1xcGw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIsCe-0005Oh-G7; Thu, 17 Sep 2020 11:35:52 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIsCZ-0005O7-9d for linux-arm-kernel@lists.infradead.org; Thu, 17 Sep 2020 11:35:51 +0000 Received: by mail-wr1-x444.google.com with SMTP id t10so1700405wrv.1 for ; Thu, 17 Sep 2020 04:35:45 -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=EtH4/cbuQgykQYd+jjjiuY8limbLr894Hm1Wfr5TKQE=; b=MZtwfo2Wkr6xjMeQYiz0AzKCHXOeKN48g2ul8ghIqc3xiqk9zQf+HOBZ+UHRPpswvD 9SBgHRwMaFLJDl27uhHNtO8R/rVQPrHwHvld1k1cSpz8o0eAbb3ZsN9tjQpOpqlJKGlW GrwSOQnzS9k0pLp3WVTGsfCkX2nwuK4/KULnQidX0PveC+EMFDCZsR5EPDsAU4hnW/C4 FwjND5Y6WgjF+MR48bLLBhiZwio2a9ADpBpQiFIj+6TTVuegNGnGK+5dwnjCcZZiHSIO 9G8jASY5hC9NeCi7D/s0svoVNRSESbWKf5XK5jmgjExYi5hfODHSRbI3XH+jyy9nFahP i+zA== 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=EtH4/cbuQgykQYd+jjjiuY8limbLr894Hm1Wfr5TKQE=; b=Azp3va+3TRmxFpA4XeGacwTX5FPRGFqslLLdwNlCb4xL4hzga871I8aDH2onT1t9cR APU/aQNdb8AnSMlmVwLaQ73zpyuRBwk96l29HYl0GOcFHL/7XFOD7ViQ63wGbwr03XKo y40VzeRNCxEmNLXYy6xfMWVSUupmY7yeiJebWf+gWWsTbIwRmuYh0F+S+hyM65TE68g1 r0nMpNK4eKlv44BiJvgmy3S4AIP9ekT3jtDjjpEsfE4TPj8ZLMjSUss4Z1Kc0nT3QGvG VyRWomQEZhaA+7nOi+1oRf4YFgrmAVq9xT14ZT00BPNTtU57Kb5TYmS9UFlcPdlrpjJB LGNw== X-Gm-Message-State: AOAM533/AjO8jmQ2J9LMA2vlToh+2nw5aD6QNlaW9S1Tej+mrT/gKwf8 tOgjJksOf6MgtpgwJ9G4rRr4cudMtrDXHw== X-Google-Smtp-Source: ABdhPJwAdcQbPsLcZZV58AgYAMNaXQbRRw54r+D+72HaJLI/PEWaAMsAwIznC1PUJ+lKzs+dj/3gLQ== X-Received: by 2002:adf:df87:: with SMTP id z7mr32658549wrl.239.1600342544219; Thu, 17 Sep 2020 04:35:44 -0700 (PDT) Received: from google.com (49.222.77.34.bc.googleusercontent.com. [34.77.222.49]) by smtp.gmail.com with ESMTPSA id f14sm10591991wme.22.2020.09.17.04.35.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 04:35:42 -0700 (PDT) Date: Thu, 17 Sep 2020 11:35:40 +0000 From: George Popescu To: Marco Elver Subject: Re: [PATCH 06/14] Fix CFLAGS for UBSAN_BOUNDS on Clang Message-ID: <20200917113540.GA1742660@google.com> References: <202009141509.CDDC8C8@keescook> <20200915102458.GA1650630@google.com> <20200915120105.GA2294884@google.com> <20200916074027.GA2946587@google.com> <20200916121401.GA3362356@google.com> <20200916134029.GA1146904@elver.google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200917_073547_444704_605B28AD X-CRM114-Status: GOOD ( 37.59 ) 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 , Alexander Potapenko , Will Deacon , kvmarm@lists.cs.columbia.edu, Fangrui Song , maz@kernel.org, Masahiro Yamada , suzuki.poulose@arm.com, kasan-dev , clang-built-linux , Linux ARM , David Brazdil , julien.thierry.kdev@gmail.com, Kees Cook , Arnd Bergmann , Linux Kbuild mailing list , Andrey Konovalov , broonie@kernel.org, Andrew Scull , Nathan Chancellor , Dmitry Vyukov , Michal Marek , Nick Desaulniers , LKML , james.morse@arm.com, 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 On Thu, Sep 17, 2020 at 08:37:07AM +0200, Marco Elver wrote: > On Wed, 16 Sep 2020 at 15:40, Marco Elver wrote: > > On Wed, Sep 16, 2020 at 12:14PM +0000, George Popescu wrote: > > > On Wed, Sep 16, 2020 at 10:32:40AM +0200, Marco Elver wrote: > > > > On Wed, 16 Sep 2020 at 09:40, George Popescu wrote: > > > > > On Tue, Sep 15, 2020 at 07:32:28PM +0200, Marco Elver wrote: > > > > > > On Tue, 15 Sep 2020 at 14:01, George Popescu wrote: > > > > > > > On Tue, Sep 15, 2020 at 01:18:11PM +0200, Marco Elver wrote: > > > > > > > > On Tue, 15 Sep 2020 at 12:25, George Popescu wrote: > > > > > > > > > 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 > > > > > > > > > > > > > > > > > > > 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. > > > > > > > > > > > > > > > > Does -fno-sanitize-trap=bounds help? > > [...] > > > > Your full config would be good, because it includes compiler version etc. > > > My full config is: > > > > Thanks. Yes, I can reproduce, and the longer I keep digging I start > > wondering why we have local-bounds at all. > > > > It appears that local-bounds finds a tiny subset of the issues that > > KASAN finds: > > > > http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20131021/091536.html > > http://llvm.org/viewvc/llvm-project?view=revision&revision=193205 > > > > fsanitize=undefined also does not include local-bounds: > > > > https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#available-checks > > > > And the reason is that we do want to enable KASAN and UBSAN together; > > but local-bounds is useless overhead if we already have KASAN. > > > > I'm inclined to say that what you propose is reasonable (but the commit > > message needs to be more detailed explaining the relationship with > > KASAN) -- but I have no idea if this is going to break somebody's > > usecase (e.g. find some OOB bugs, but without KASAN -- but then why not > > use KASAN?!) > > So, it seems that local-bounds can still catch some rare OOB accesses, > where KASAN fails to catch it because the access might skip over the > redzone. > > The other more interesting bit of history is that > -fsanitize=local-bounds used to be -fbounds-checking, and meant for > production use as a hardening feature: > http://lists.llvm.org/pipermail/llvm-dev/2012-May/049972.html > > And local-bounds just does not behave like any other sanitizer as a > result, it just traps. The fact that it's enabled via > -fsanitize=local-bounds (or just bounds) but hasn't much changed in > behaviour is a little unfortunate. > I suppose there are 3 options: > > 1. George implements trap handling somehow. Is this feasible? If not, > why not? Maybe that should also have been explained in the commit > message. > > 2. Only enable -fsanitize=local-bounds if UBSAN_TRAP was selected, at > least for as long as Clang traps for local-bounds. I think this makes > sense either way, because if we do not expect UBSAN to trap, it really > should not trap! > > 3. Change the compiler. As always, this will take a while to implement > and then to reach whoever should have that updated compiler. > > Preferences? Considering of what you said above, I find option 2 the most elegant. The first one doesn't sound doable for the moment, also the third. I will edit this patch considering your comments and resend it to the list. Thank you for your support. Thanks, George _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel