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,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 7F2D1C433E2 for ; Wed, 16 Sep 2020 08:32:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 38C6520795 for ; Wed, 16 Sep 2020 08:32:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PS2WB70x" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726532AbgIPIc4 (ORCPT ); Wed, 16 Sep 2020 04:32:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725840AbgIPIcx (ORCPT ); Wed, 16 Sep 2020 04:32:53 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 033A4C06174A for ; Wed, 16 Sep 2020 01:32:53 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id q21so304594ota.8 for ; Wed, 16 Sep 2020 01:32: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=gutnwyq/fY1R+B0kj3zMSfdQMIw4d9tjzY6YslUPxq0=; b=PS2WB70x9ySf7kxgHgUr09U5FuNJgjvgaH7MMVEi0w25wj+geORkHkwqZc6VzcevOQ hCiEAnLVhUXjSlfOS/9LyAWzsln3c5crRxRoQqAuBiTozsIvZrtIZiM8OPXSSAy9Vae7 OMDs11gtOlkCkG/6Uw/jn9znWaF+uoVU/C8MX31oKa9yxTGAe460K1qfCI8awGr7H8z3 6k+OgXFK6UAPvAOVBG0ab6JFxnyX6o+ajKqqqNU8mHtleCW4IaanfL2KUVXoPA9N90ZA qgRYedd2f9Q0CTxAQi3665Ew2/NkBkKd0kVGjtH4Awdg11uBiQ484d2fJCsAhk4O2Zlx Meug== 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=gutnwyq/fY1R+B0kj3zMSfdQMIw4d9tjzY6YslUPxq0=; b=NCIVszuu68OZrdON6YF0xs20WlFqtBKF5g+CrtPe7XLa2m66Nc3IejPPrwE662iLAg yNYmz7Xvv5WBNPLVS4SsgLJ7HDRqiPRSTPe7RorSlDBhcEeo97X6SQM2sv7bkpt3zOeU Ttm0h4xfq9tKaDcGJXXXO9/VJftwN4DMigTjmOx3ZnFD+eMvyhGwcm9+P7FA3GWyYLHA 2UL38SjwjOR+34S6Hz6GGi2tlJ4SM64cA7J6tdMRSsLQyEN4Dq09dL0R151Q3FNkYWMl 1YprzbqM4LKUcBb4kLg/hKvsYtPKtc/FpMEySnot04XJD88LmxwfMUOcY0Qdu8FCI88f SPMA== X-Gm-Message-State: AOAM530/gwKu+CSV8gg4g6wfedb3u6I76iy1eFF74tWe7M/OfaLZxarK BA/G4kU+X5ZbwfCaTh+F6j0Lg/EekeVHM8bVa7oPdw== X-Google-Smtp-Source: ABdhPJwe6y4pKih3pRHaHK/yYYM4kOk8WdhzR+Jnvf9pdfuOu3tT6QfG19o4rzngArJRA/kONhSAKRQW+ccjYcRX+jI= X-Received: by 2002:a05:6830:1e8c:: with SMTP id n12mr16510993otr.17.1600245172173; Wed, 16 Sep 2020 01:32:52 -0700 (PDT) MIME-Version: 1.0 References: <20200914172750.852684-1-georgepope@google.com> <20200914172750.852684-7-georgepope@google.com> <202009141509.CDDC8C8@keescook> <20200915102458.GA1650630@google.com> <20200915120105.GA2294884@google.com> <20200916074027.GA2946587@google.com> In-Reply-To: <20200916074027.GA2946587@google.com> From: Marco Elver Date: Wed, 16 Sep 2020 10:32:40 +0200 Message-ID: Subject: Re: [PATCH 06/14] Fix CFLAGS for UBSAN_BOUNDS on Clang To: George Popescu 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 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 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?> > > > > > > I tried replacing it with: > > > ifdef CONFIG_CC_IS_CLANG > > > CFLAGS_UBSAN += $(call cc-option, -fno-sanitize-trap=bounds) > > > CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds) > > > else > > > CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds) > > > endif > > > > > > The code traps. > > > > What's your config? Do you have CONFIG_UBSAN_TRAP=y? If so, you have 2 > > options: honor UBSAN_TRAP and crash the kernel, or have a > > 'CFLAGS_REMOVE_... = -fsanitize-undefined-trap-on-error' for the files > > where you can't deal with traps> > > I don't have CONFIG_UBSAN_TRAP=y. My .config is: > CONFIG_ARCH_HAS_UBSAN_SANITIZE_ALL=y > CONFIG_UBSAN=y > # CONFIG_UBSAN_TRAP is not set > CONFIG_UBSAN_KCOV_BROKEN=y > CONFIG_UBSAN_MISC=y > CONFIG_UBSAN_SANITIZE_ALL=y > # CONFIG_UBSAN_ALIGNMENT is not set > CONFIG_TEST_UBSAN=m Your full config would be good, because it includes compiler version etc. 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 A1AC9C2BB84 for ; Wed, 16 Sep 2020 09:01:17 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id DDB7E20738 for ; Wed, 16 Sep 2020 09:01:16 +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="PS2WB70x" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DDB7E20738 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 56A9D4B377; Wed, 16 Sep 2020 05:01:16 -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 Ar8L2rU6ACtK; Wed, 16 Sep 2020 05:01:15 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 9CC4C4B3B1; Wed, 16 Sep 2020 05:01:13 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id E88434B2F6 for ; Wed, 16 Sep 2020 04:32:54 -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 IcXz5NrkGIjI for ; Wed, 16 Sep 2020 04:32:53 -0400 (EDT) Received: from mail-ot1-f66.google.com (mail-ot1-f66.google.com [209.85.210.66]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 16A014B1B2 for ; Wed, 16 Sep 2020 04:32:53 -0400 (EDT) Received: by mail-ot1-f66.google.com with SMTP id m12so5959606otr.0 for ; Wed, 16 Sep 2020 01:32: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=gutnwyq/fY1R+B0kj3zMSfdQMIw4d9tjzY6YslUPxq0=; b=PS2WB70x9ySf7kxgHgUr09U5FuNJgjvgaH7MMVEi0w25wj+geORkHkwqZc6VzcevOQ hCiEAnLVhUXjSlfOS/9LyAWzsln3c5crRxRoQqAuBiTozsIvZrtIZiM8OPXSSAy9Vae7 OMDs11gtOlkCkG/6Uw/jn9znWaF+uoVU/C8MX31oKa9yxTGAe460K1qfCI8awGr7H8z3 6k+OgXFK6UAPvAOVBG0ab6JFxnyX6o+ajKqqqNU8mHtleCW4IaanfL2KUVXoPA9N90ZA qgRYedd2f9Q0CTxAQi3665Ew2/NkBkKd0kVGjtH4Awdg11uBiQ484d2fJCsAhk4O2Zlx Meug== 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=gutnwyq/fY1R+B0kj3zMSfdQMIw4d9tjzY6YslUPxq0=; b=PU+PZd+duBQ5Jb1KeCdqHdncFKYXtKg3n4h70cUFWkBcwrivKSn22bGRdxABCk/gX4 GMUhgBRaY4co9qBZRyJa6WpT8G1SGjQHBi2iGc4DMthC/BvdSfYF5xw1JrnsKfqJtKR4 Nx45AOtWSQOmOybLSb/VhdLuZ52pIr/PKhYPZ/1DcmgaL4U5Ziir1MRdiczW5yH7RKn5 UlsU7ZdJhjdHz3J/xGIsW/MjeVvMKzC+9kLXos+lC9oAX80exXFlY8CA47phhJHWu1E1 WOXeDnKqfHWScmXt7NAK/MuIHu1/RpIbWeeqCtfMSz3thKBhd/FVb6AzMACSTTiJPSxX qr1w== X-Gm-Message-State: AOAM531ezzdSQym5vCkRv/a4adFCc8zhDGO6bSJB1Q/puIbAucY0gXXh dkQnTWsRI+fcS4UGoFcMTqv237vVbL5TLscGx20Fdw== X-Google-Smtp-Source: ABdhPJwe6y4pKih3pRHaHK/yYYM4kOk8WdhzR+Jnvf9pdfuOu3tT6QfG19o4rzngArJRA/kONhSAKRQW+ccjYcRX+jI= X-Received: by 2002:a05:6830:1e8c:: with SMTP id n12mr16510993otr.17.1600245172173; Wed, 16 Sep 2020 01:32:52 -0700 (PDT) MIME-Version: 1.0 References: <20200914172750.852684-1-georgepope@google.com> <20200914172750.852684-7-georgepope@google.com> <202009141509.CDDC8C8@keescook> <20200915102458.GA1650630@google.com> <20200915120105.GA2294884@google.com> <20200916074027.GA2946587@google.com> In-Reply-To: <20200916074027.GA2946587@google.com> From: Marco Elver Date: Wed, 16 Sep 2020 10:32:40 +0200 Message-ID: Subject: Re: [PATCH 06/14] Fix CFLAGS for UBSAN_BOUNDS on Clang To: George Popescu X-Mailman-Approved-At: Wed, 16 Sep 2020 05:01:11 -0400 Cc: Thomas Gleixner , Catalin Marinas , Will Deacon , kvmarm@lists.cs.columbia.edu, Fangrui Song , maz@kernel.org, Masahiro Yamada , clang-built-linux , Linux ARM , Kees Cook , Arnd Bergmann , Linux Kbuild mailing list , 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 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?> > > > > > > I tried replacing it with: > > > ifdef CONFIG_CC_IS_CLANG > > > CFLAGS_UBSAN += $(call cc-option, -fno-sanitize-trap=bounds) > > > CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds) > > > else > > > CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds) > > > endif > > > > > > The code traps. > > > > What's your config? Do you have CONFIG_UBSAN_TRAP=y? If so, you have 2 > > options: honor UBSAN_TRAP and crash the kernel, or have a > > 'CFLAGS_REMOVE_... = -fsanitize-undefined-trap-on-error' for the files > > where you can't deal with traps> > > I don't have CONFIG_UBSAN_TRAP=y. My .config is: > CONFIG_ARCH_HAS_UBSAN_SANITIZE_ALL=y > CONFIG_UBSAN=y > # CONFIG_UBSAN_TRAP is not set > CONFIG_UBSAN_KCOV_BROKEN=y > CONFIG_UBSAN_MISC=y > CONFIG_UBSAN_SANITIZE_ALL=y > # CONFIG_UBSAN_ALIGNMENT is not set > CONFIG_TEST_UBSAN=m Your full config would be good, because it includes compiler version etc. _______________________________________________ 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=-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 21C52C43461 for ; Wed, 16 Sep 2020 08:34:37 +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 D1CDE206DC for ; Wed, 16 Sep 2020 08:34:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="DHEE8Uhi"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="PS2WB70x" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D1CDE206DC 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=l5Fxjl7uKP02NCqREyOjoyDoRMLwIqKReNT10P9LiXA=; b=DHEE8Uhi0sSgbkMBk+X91CwSR rV0tmRl1GdrhYk/rwEaNWblzksi7bI5ryP4aHdO+vd2Hd++gOKonXoIu3lufCxEZJs0tmseFLyQx4 QjbdfJm4/6TCHJoK1uBvKLPwC2/B/HP+NaMxCaw9NuyA5LwTjCgAcpPeko8yPrhSatTnaGpr2s8zB 0tguRbs1CGjNCLPflSdEQVac6e3miccRA2XCobwVbwzIu6+asoI/kEw/F/niiwoaGBmztRwf1cSNX ZhfqKd2rFwz5Z+ENBFJ6DyBARd3WfsHuyHXaj2VzpvjNsztZY6ULs6djWK0E7RVl3ikyCdIckyQNK uaYk6mrjw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kISs7-0001VZ-41; Wed, 16 Sep 2020 08:32:59 +0000 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kISs2-0001Nn-BW for linux-arm-kernel@lists.infradead.org; Wed, 16 Sep 2020 08:32:57 +0000 Received: by mail-ot1-x341.google.com with SMTP id g96so5877328otb.12 for ; Wed, 16 Sep 2020 01:32: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=gutnwyq/fY1R+B0kj3zMSfdQMIw4d9tjzY6YslUPxq0=; b=PS2WB70x9ySf7kxgHgUr09U5FuNJgjvgaH7MMVEi0w25wj+geORkHkwqZc6VzcevOQ hCiEAnLVhUXjSlfOS/9LyAWzsln3c5crRxRoQqAuBiTozsIvZrtIZiM8OPXSSAy9Vae7 OMDs11gtOlkCkG/6Uw/jn9znWaF+uoVU/C8MX31oKa9yxTGAe460K1qfCI8awGr7H8z3 6k+OgXFK6UAPvAOVBG0ab6JFxnyX6o+ajKqqqNU8mHtleCW4IaanfL2KUVXoPA9N90ZA qgRYedd2f9Q0CTxAQi3665Ew2/NkBkKd0kVGjtH4Awdg11uBiQ484d2fJCsAhk4O2Zlx Meug== 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=gutnwyq/fY1R+B0kj3zMSfdQMIw4d9tjzY6YslUPxq0=; b=EIMVpwI2kqhCTtQ6BNSFmiikJwgG6q/jjszjOdjU87wAgQWd494VXxFJa/K8nCQRB3 ZxqTq+gIyJMv/824W9nhWRfiqoSBVgDsKz0b0gmHLE8Hiatbw2FU1Wh11FeJAz6fDzQw bm7e5q4Qvc6IsTwnWqPiEQ9IjGXiCvtgiwlXecoPCGYHMP+8kx3Ec3ftR3E7i7eJ1jPH Yedh7Ko0N7h82uP3oQKZuRXDPfLL/7NahYs8+V0t6PVL3EJdSlppsiLDcg5xO27vvlAX vgXqtdkcF/WdvTi1rErishIdTi3mkxKbaUPzq/Mg5KlForfDRWbg1pkcz8LDn5qNZU1b UXug== X-Gm-Message-State: AOAM532M0obL9olLPFpFuU6wR4/Gk0t2RNU/QUK569r0yfbiw0v7YbG+ jgxKe8SQ4fGqXn2HfO5KLstam3N96oRenccLpZ4pwg== X-Google-Smtp-Source: ABdhPJwe6y4pKih3pRHaHK/yYYM4kOk8WdhzR+Jnvf9pdfuOu3tT6QfG19o4rzngArJRA/kONhSAKRQW+ccjYcRX+jI= X-Received: by 2002:a05:6830:1e8c:: with SMTP id n12mr16510993otr.17.1600245172173; Wed, 16 Sep 2020 01:32:52 -0700 (PDT) MIME-Version: 1.0 References: <20200914172750.852684-1-georgepope@google.com> <20200914172750.852684-7-georgepope@google.com> <202009141509.CDDC8C8@keescook> <20200915102458.GA1650630@google.com> <20200915120105.GA2294884@google.com> <20200916074027.GA2946587@google.com> In-Reply-To: <20200916074027.GA2946587@google.com> From: Marco Elver Date: Wed, 16 Sep 2020 10:32:40 +0200 Message-ID: Subject: Re: [PATCH 06/14] Fix CFLAGS for UBSAN_BOUNDS on Clang To: George Popescu X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200916_043254_449450_A0B5B080 X-CRM114-Status: GOOD ( 26.78 ) 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 , maz@kernel.org, Masahiro Yamada , suzuki.poulose@arm.com, clang-built-linux , Linux ARM , David Brazdil , julien.thierry.kdev@gmail.com, Kees Cook , Arnd Bergmann , Linux Kbuild mailing list , 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 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?> > > > > > > I tried replacing it with: > > > ifdef CONFIG_CC_IS_CLANG > > > CFLAGS_UBSAN += $(call cc-option, -fno-sanitize-trap=bounds) > > > CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds) > > > else > > > CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds) > > > endif > > > > > > The code traps. > > > > What's your config? Do you have CONFIG_UBSAN_TRAP=y? If so, you have 2 > > options: honor UBSAN_TRAP and crash the kernel, or have a > > 'CFLAGS_REMOVE_... = -fsanitize-undefined-trap-on-error' for the files > > where you can't deal with traps> > > I don't have CONFIG_UBSAN_TRAP=y. My .config is: > CONFIG_ARCH_HAS_UBSAN_SANITIZE_ALL=y > CONFIG_UBSAN=y > # CONFIG_UBSAN_TRAP is not set > CONFIG_UBSAN_KCOV_BROKEN=y > CONFIG_UBSAN_MISC=y > CONFIG_UBSAN_SANITIZE_ALL=y > # CONFIG_UBSAN_ALIGNMENT is not set > CONFIG_TEST_UBSAN=m Your full config would be good, because it includes compiler version etc. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel