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=-3.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,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 895E5C43461 for ; Thu, 17 Sep 2020 11:35:50 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id EEDC620795 for ; Thu, 17 Sep 2020 11:35:49 +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="MZtwfo2W" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EEDC620795 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 2C48E4B308; Thu, 17 Sep 2020 07:35:49 -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 qtu2Yo56hY9K; Thu, 17 Sep 2020 07:35:47 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id ED2384B345; Thu, 17 Sep 2020 07:35:47 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id C89D44B30B for ; Thu, 17 Sep 2020 07:35:46 -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 eEwXBY0Q78xg for ; Thu, 17 Sep 2020 07:35:45 -0400 (EDT) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 5EF024B308 for ; Thu, 17 Sep 2020 07:35:45 -0400 (EDT) Received: by mail-wr1-f66.google.com with SMTP id z1so1698790wrt.3 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=nH+IBPSkL9SCpnkrrZUcK0nYNSQjhPNm709MfHAq40bKFbppC64KML3E5dfKG9sevf g54kXkB3D1THaF8yn0TXmwS0is/7jMI8sEQlf9WjeIJGbHgSAJIJIoPubuu7+CnIa+1i jBPu5+ioAvzvTh8s+0HR38BkJ71SZn7oVcFLiPsVBhFfBGFxcdU9DHQcQwrkTfULbfsg /Y/NaapzeJYGpCWrQfeiQzhm4jaBHPX6oJcDtDaDWYMW6X2gjUUV869zK6X4dq7qs44i lss1u2AYBNgaFXwFQONx8aG48P5TMOuJcm9Z3vGC8dbky3unRqydApnmbZ3l3VM8GljU a8kA== X-Gm-Message-State: AOAM53345/q3GVXp9Pw1c81IETIYMZlDnk7JuhvXS7dOixkznyywkF4T Ed4zcwk9HUVezphBBNSvOlN1tw== 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: Cc: Thomas Gleixner , Catalin Marinas , Alexander Potapenko , Will Deacon , kvmarm@lists.cs.columbia.edu, Fangrui Song , maz@kernel.org, Masahiro Yamada , kasan-dev , clang-built-linux , Linux ARM , Kees Cook , Arnd Bergmann , Linux Kbuild mailing list , Andrey Konovalov , broonie@kernel.org, Nathan Chancellor , Dmitry Vyukov , Michal Marek , Nick Desaulniers , 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 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 _______________________________________________ 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.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL 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 65B5AC43461 for ; Thu, 17 Sep 2020 11:45:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E4DA206B6 for ; Thu, 17 Sep 2020 11:45:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="MZtwfo2W" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726917AbgIQLph (ORCPT ); Thu, 17 Sep 2020 07:45:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726873AbgIQLgJ (ORCPT ); Thu, 17 Sep 2020 07:36:09 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE1AAC061756 for ; Thu, 17 Sep 2020 04:35:45 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id o5so1663475wrn.13 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=Q4lrIP/BXFbwqahB/awBp3U08xeOUN8TMyBd5h57DMJoknx2ZLe/pitmokKUk0rpmG X4zG4gAb4vsW+5ysSxThP812ZMq4YyjRm45KHkAyG1FCsq9ITKBBBLFi4EbCUB8RfYxj ekzUEkuiMA+yrhACcK3asnqBDoHLQ0HpDq5MW/FSOY+LvPkXIXz2U3C3lXzinbVRJTY3 jVOyNlKp2/vNCZQJV/pYdFitX/7i98oPS3Kt8dmmkJoiH95mzy+2JNqiy8JMZLXKMQCP dY2ppDmYA1X8buxNsRfuM3i102VEpMHADBsF6jGBkylxKNsTEr4257smdBRJRUFa21AL k3Bw== X-Gm-Message-State: AOAM531lFArweD4URYZcTo1zYqtD/1GimgsAn+iCKxmWF4UbOJNVnDcC BvRApkW/M+/kWJznNOELVB1MVg== 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 Cc: Kees Cook , maz@kernel.org, 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@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, Nathan Chancellor , Nick Desaulniers , David Brazdil , broonie@kernel.org, Fangrui Song , Andrew Scull , Andrew Morton , Dmitry Vyukov , Thomas Gleixner , Arnd Bergmann , kasan-dev , Andrey Konovalov , Alexander Potapenko 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.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 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