Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3166976pxk; Tue, 15 Sep 2020 11:46:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOjSulY6bCQgjiRISv7ykS4u16w2T5psd9q54wUpIYdOzKztVbkFp0SY8nnG8S74gytYgD X-Received: by 2002:a05:6402:1acf:: with SMTP id ba15mr21479978edb.305.1600195613693; Tue, 15 Sep 2020 11:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600195613; cv=none; d=google.com; s=arc-20160816; b=kSyn5oPw9N/1nuHe/tTYMIqj2i7+6m04NbXutIVxv6ctxIbWypUqDtLtMGKG69xIzZ Qnuykhw/cjoXRqzsX02XQ68nW3KBlk7TmauQqCrHVOcqJnu7zNLQgxwDtj8LF/80nD8b miTkfj5odQ3AbznNJ/U8JCMQv7FORWznNwQ5wipqM4Z/0ag3VTctH0BdJLNGcU2aSaHG DbXCKjg+xefC5m7xIs8Ined5KYMTos9xdbdrCCjdO4KQu+ISIsHLdqGCiunto7ibudQc vdDqYgbXgKWeTH2UsjeayLOSq2c7DJY81vMjQLA1HlptirhqRvgcqYwwQKQ2FOe9VGo6 HWZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=PAtDVfuEJhlt1elf5/lgoBo+0AnWtv6A1Q7VC77Ff04=; b=UuLO+AY6Yst7z6Dtb1vgLV4icLaigSYsqtOu8+cVWVR2wNZP+b0vpWxkc3z9QKXc14 ZuLqheAqKv4idrO7kuoq/3ToMz5u4hFf+h6ON3sVzl5gQqCWNGYe+gUz3Xxyme4K6tiJ vmZ7+5ejyIv3GZRW4VaEyDfPDkwKrxul/wPovQrxgeCazYIonW/PQt2qEOpyX+WadbGE yuov/jqRUYH6bvzd3zdmPaT/dvxJ0cHvtyxgMuGNYmCg/0Vm0pgTakdBSEyf8oNHZMyz IQX3BkH/iD4qIy6N5+2npXNVJBako2ean1jkuw9GN08m3AfNLNiioO7q7kZbUSvPnYEp iVDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=d0JaJ9en; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cx16si10668791edb.575.2020.09.15.11.46.31; Tue, 15 Sep 2020 11:46:53 -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=@google.com header.s=20161025 header.b=d0JaJ9en; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727900AbgIOSoZ (ORCPT + 99 others); Tue, 15 Sep 2020 14:44:25 -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-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