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 47F49C433E2 for ; Tue, 15 Sep 2020 18:44:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED64820872 for ; Tue, 15 Sep 2020 18:44:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="d0JaJ9en" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727921AbgIOSob (ORCPT ); Tue, 15 Sep 2020 14:44:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727682AbgIORdK (ORCPT ); Tue, 15 Sep 2020 13:33:10 -0400 Received: from mail-oo1-xc43.google.com (mail-oo1-xc43.google.com [IPv6:2607:f8b0:4864:20::c43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60A14C06174A for ; Tue, 15 Sep 2020 10:32:42 -0700 (PDT) Received: by mail-oo1-xc43.google.com with SMTP id r4so963796ooq.7 for ; Tue, 15 Sep 2020 10:32:42 -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=PAtDVfuEJhlt1elf5/lgoBo+0AnWtv6A1Q7VC77Ff04=; b=d0JaJ9en3sRyhoZPnW1QJJsxEdsVuPco3gIwh9SOrfnk19I2FwZ7GOdGlPhvQTrY1k txY0wp2cgnvWub0vDpMs/MJk8Pu0yM9YHo71bPPgXGTmrj9nzguJi8qtik3HijV58bFt d2O3luG/WR9UWz1jRPucM/caqSWmjD+RDDJXnr1xoFcys3qOaGdlWvq4ZmxcVwZrx/uI ozBsIng1hGBF00/o2vwNEvqKXH5n+W0odVBB5j6WYIu+mwKz8DADLNADAd9ic1lxeC/z G1T+PpfVFVmx/i24SgJG/1ndRmiiK8yYYYDVKwOqn1uak0gt53v94/41Wg3i8R6SJtn0 JVNw== 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=PAtDVfuEJhlt1elf5/lgoBo+0AnWtv6A1Q7VC77Ff04=; b=KOLyouXiENe86fvIwI5xH4gOBBpOLSrdgjUc5zuX4NuDgUXiIAo5llvoJDW382tWoJ bGwIur7rDB9WrOPNAS8mKMJERcUxf9zJkREiRQTyvQPDicrCF9CWTxk1mXm5FahFXeOp FhNjIhOxL4ztboWWUEmKExf9h4uUZcfCoGUsfOC0a+5fl4bNenU3Gxk29dt/zpwxRGFd x52qXypj65omE6u2+0ITcRiI7A+330WUfbhFkRdobohib4q3yEaQo/YUYM7hbnSeGXBy PlOwlAP+kBvUBKPexOAW7g/Xp371QM84WDCiKGg6a+HAARLRkWGJkxyC6Cpt3pzeIRKa hOzA== X-Gm-Message-State: AOAM530VKl6h52fAqcWuLIg0IaxjhQMAQEEpFszK7hf2WrFLb+1JswhJ rPFciD5DibuRquyeaMoAOIyKnsgL9T5J6VeXmt1dlQ== X-Google-Smtp-Source: ABdhPJyCzInxRpJlSmxXfBdbgreenCQjI8gKUscz7zGArVGzNAylhuh/sQNja0PJx+ORauOO7/zkeU7+nZkaJKmgHdU= X-Received: by 2002:a4a:751a:: with SMTP id j26mr14993283ooc.14.1600191160831; Tue, 15 Sep 2020 10:32:40 -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> In-Reply-To: <20200915120105.GA2294884@google.com> From: Marco Elver Date: Tue, 15 Sep 2020 19:32:28 +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 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. Thanks, -- Marco 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 AEA60C433E2 for ; Tue, 15 Sep 2020 17:45:48 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id E9B2020659 for ; Tue, 15 Sep 2020 17:45:47 +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="d0JaJ9en" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E9B2020659 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 3794D4B2CC; Tue, 15 Sep 2020 13:45:47 -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 kT73kcI65-pB; Tue, 15 Sep 2020 13:45:46 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 2CA694B2B7; Tue, 15 Sep 2020 13:45:46 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id AF4FA4B24B for ; Tue, 15 Sep 2020 13:32:42 -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 6ulmPH1V44aI for ; Tue, 15 Sep 2020 13:32:41 -0400 (EDT) Received: from mail-oo1-f66.google.com (mail-oo1-f66.google.com [209.85.161.66]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id BB8134B249 for ; Tue, 15 Sep 2020 13:32:41 -0400 (EDT) Received: by mail-oo1-f66.google.com with SMTP id k13so971357oor.2 for ; Tue, 15 Sep 2020 10:32:41 -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=PAtDVfuEJhlt1elf5/lgoBo+0AnWtv6A1Q7VC77Ff04=; b=d0JaJ9en3sRyhoZPnW1QJJsxEdsVuPco3gIwh9SOrfnk19I2FwZ7GOdGlPhvQTrY1k txY0wp2cgnvWub0vDpMs/MJk8Pu0yM9YHo71bPPgXGTmrj9nzguJi8qtik3HijV58bFt d2O3luG/WR9UWz1jRPucM/caqSWmjD+RDDJXnr1xoFcys3qOaGdlWvq4ZmxcVwZrx/uI ozBsIng1hGBF00/o2vwNEvqKXH5n+W0odVBB5j6WYIu+mwKz8DADLNADAd9ic1lxeC/z G1T+PpfVFVmx/i24SgJG/1ndRmiiK8yYYYDVKwOqn1uak0gt53v94/41Wg3i8R6SJtn0 JVNw== 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=PAtDVfuEJhlt1elf5/lgoBo+0AnWtv6A1Q7VC77Ff04=; b=euTqYcYmg19R2qMydFQAHPap4gUMY28TmYNzgSmifoOKtUBjFhA+bEWu9t76WrHs8/ 77/XtVxH+m/gRwI4IR328V6XXP2/3Z1eC8+pHjvfU+jCeJzYmNFc9HaXtHOtD7GrAkT/ Ws3F6bOQLblaujYiA2DjD2xjQH+kqIWlBQMGYIG20Y0AfvUNwColKAGJbAhvcayajVLk anQZ2bFv+uPfdljLs+Q/HbDyH2WdUrYtRTqDiu3FnoxxrADnSUcd43S/d7OIbOjAz4XV aIUDFqjZaBvzw8ARTgXBDHDmYcVfZCTzqvpyXhm9NYGHF5tu2UwEYHrTLNTelOieA1rr wxtQ== X-Gm-Message-State: AOAM533F1vouYEDy5EA4wM9d0RUkrv9c9NkncdrgpyP2CMrjeU5tdWBt 8pYlgo0wKkYW50ftvMrbXFOxJxi+YCvmqUZYdfduOg== X-Google-Smtp-Source: ABdhPJyCzInxRpJlSmxXfBdbgreenCQjI8gKUscz7zGArVGzNAylhuh/sQNja0PJx+ORauOO7/zkeU7+nZkaJKmgHdU= X-Received: by 2002:a4a:751a:: with SMTP id j26mr14993283ooc.14.1600191160831; Tue, 15 Sep 2020 10:32:40 -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> In-Reply-To: <20200915120105.GA2294884@google.com> From: Marco Elver Date: Tue, 15 Sep 2020 19:32:28 +0200 Message-ID: Subject: Re: [PATCH 06/14] Fix CFLAGS for UBSAN_BOUNDS on Clang To: George Popescu X-Mailman-Approved-At: Tue, 15 Sep 2020 13:45:45 -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 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. Thanks, -- Marco _______________________________________________ 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 367EFC433E2 for ; Tue, 15 Sep 2020 17:34:17 +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 C298F20936 for ; Tue, 15 Sep 2020 17:34:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="VEcyHh6u"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="d0JaJ9en" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C298F20936 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=fdEfMiZiFj+cc95yQxL+Iqo28MqWIaQ1iEuG8wasGbY=; b=VEcyHh6uKVu1itAf5t7NBbl5D MeRCBEDX2QR++/XfBHUciBXyToWiTWhfPFsQEPbUG6aGwqrEFwUtaM6T5y+XYbXZmLtD49kA/r6Aq V++x2VsGmG8MuVTTSZek5FoaRm581yT0+SOjm8+qw46eAjlUKEL3UIyeAg1zoUCxArd2ngTC+OQ6w R0oRXt6W0ccdCDa/Ac/8CovNdeb5EeEN/eeJsYyx8sRSvUtIX84PHMDZmvc/HaaOnrGw/0K/6nFd5 PqJA7Rj0bIK6bXDrAyD6YWAkPfLgJ+hlf/HL/WQL/WzrXf1MKb6xl/EMWHf1ddv32cDXDBpZrjsNu IqHr/5/aQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIEov-0002bv-Iz; Tue, 15 Sep 2020 17:32:45 +0000 Received: from mail-oo1-xc41.google.com ([2607:f8b0:4864:20::c41]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIEot-0002Vo-2q for linux-arm-kernel@lists.infradead.org; Tue, 15 Sep 2020 17:32:44 +0000 Received: by mail-oo1-xc41.google.com with SMTP id o20so969485ook.1 for ; Tue, 15 Sep 2020 10:32:42 -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=PAtDVfuEJhlt1elf5/lgoBo+0AnWtv6A1Q7VC77Ff04=; b=d0JaJ9en3sRyhoZPnW1QJJsxEdsVuPco3gIwh9SOrfnk19I2FwZ7GOdGlPhvQTrY1k txY0wp2cgnvWub0vDpMs/MJk8Pu0yM9YHo71bPPgXGTmrj9nzguJi8qtik3HijV58bFt d2O3luG/WR9UWz1jRPucM/caqSWmjD+RDDJXnr1xoFcys3qOaGdlWvq4ZmxcVwZrx/uI ozBsIng1hGBF00/o2vwNEvqKXH5n+W0odVBB5j6WYIu+mwKz8DADLNADAd9ic1lxeC/z G1T+PpfVFVmx/i24SgJG/1ndRmiiK8yYYYDVKwOqn1uak0gt53v94/41Wg3i8R6SJtn0 JVNw== 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=PAtDVfuEJhlt1elf5/lgoBo+0AnWtv6A1Q7VC77Ff04=; b=ngCeVVnCIMHeNfoDQ+rdLgZNDbAPXc07c3TKMgEBuAp9KcykmsW88/lR9zFgzTY083 jqa2iaAan+Vqeu8Yv6CnmlJcgqyQbqAUh9Lrba2EGrCbLDheslPQT/lgWTJlL7yx4ANg JmR71cLTl5uoR6GSi5CAbT2Bw+7oFZ+PC4j/I63ahVxZzea8uhNlDk7D4NvNWJbVrWj0 B/VOSfm8A2p1bRS+Zp4QSAagjAG8ylxsLb0zf9X8q5Nhr1gJwa3DeaeLXjrB5bbpFNMS zj/4NaXi7wai4ktv4J9+V00sx3b3rZuRzcMCDOut8DWyOGQCchcm5BMwsS90RoK/odG3 j3ag== X-Gm-Message-State: AOAM532Oc6Dr/jjQ7YRQIPE3SazVYn9dswjydTBQp/wdokMkQqBK18SI tDFYpsoITkaqWkJWoAKhS0bsxA/NOjJ3Fgs2xNhHIQ== X-Google-Smtp-Source: ABdhPJyCzInxRpJlSmxXfBdbgreenCQjI8gKUscz7zGArVGzNAylhuh/sQNja0PJx+ORauOO7/zkeU7+nZkaJKmgHdU= X-Received: by 2002:a4a:751a:: with SMTP id j26mr14993283ooc.14.1600191160831; Tue, 15 Sep 2020 10:32:40 -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> In-Reply-To: <20200915120105.GA2294884@google.com> From: Marco Elver Date: Tue, 15 Sep 2020 19:32:28 +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-20200915_133243_241399_CBA40D17 X-CRM114-Status: GOOD ( 22.73 ) 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 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. Thanks, -- Marco _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel