Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp164442pxk; Wed, 16 Sep 2020 00:43:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaKTHPOn8ZueNeLB0WDE+OuSKr9Dd1qAg4Re4h1hz2dz6BBnyffytNI6CfV/GHwJ9T7qMK X-Received: by 2002:a17:907:2079:: with SMTP id qp25mr17684299ejb.186.1600242203342; Wed, 16 Sep 2020 00:43:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600242203; cv=none; d=google.com; s=arc-20160816; b=zPJPnHDAJbea6SKmGu3hh8LuRdb8rPqTuYwH0sIa1b6rlVy4iTusP1YpPhGO1VNQcc BU2CeoB4cykf+wlzxNe8M3mSJMufoVGDj2JwycPzkYLeQ/2Brbr94D6eSnFcc9TtvWpf +JASwEEQb5VP+jrGLQoyyYOqkznJgF2iLHfiHYw6yKci3UOlWm2T14zUZhf7i5uWnjZ7 mZPTKKCmziA6YblMR3Bv3nVCrBVotuLCT9021R074oCH5X5TIfQkbwXfm6s7llxCqcyw sMIrU2n9c8N+hGY2Qw0Nk9UTaShEoGMRiP1CDB6/gGHoWk/Ev9RjH/fVivdv7Hfic98F 3uVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=tqvp+bkIU1TWNlZpwcv+TKRU2X5GojmD5HYurFQV7BY=; b=EptLt8tPVo/zhQRr3a1u5j7xxE/xUPxJJmxGQXN20rOkupHZD3HW9uPt4kJ9HenYLx Kov42Bymc0q9M8VCWO+gLcdywPx91eBYjMRsxYzFhTu4i+b6p6fGPJosbwkbkzFGPyN0 RM5gVRTW9aunVbW4TlTMmp5W+8AMCmnGwCzGFsWzyoz+AezEHPHv0XVkuyEfI5EdqWxO SKNM6nYF8qdVhyAKhs668045+XB0zSr8B4AEErPLy1HZLu7QhAR5UKrJnAlc2y8RediI r1jEwvxEJAtyMm/M+Us9eR5V9TSfuSN5hTvs1YvFu9OIiCUpkPGmAIpio/aY3QMc8o6W /dJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=gjM7bxmS; 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 l21si10752030edq.277.2020.09.16.00.43.00; Wed, 16 Sep 2020 00:43:23 -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=gjM7bxmS; 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 S1726506AbgIPHkg (ORCPT + 99 others); Wed, 16 Sep 2020 03:40:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726159AbgIPHkd (ORCPT ); Wed, 16 Sep 2020 03:40:33 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE615C06174A for ; Wed, 16 Sep 2020 00:40:31 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id e17so1773085wme.0 for ; Wed, 16 Sep 2020 00:40:31 -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=tqvp+bkIU1TWNlZpwcv+TKRU2X5GojmD5HYurFQV7BY=; b=gjM7bxmS6+Hzs07rV/WLqiZ7oypbPZeeynUIbEGf+1I9i5xUZgFTr9pBvxoJKit3lh /TC/qQi6Hp2TtnCO/NeCATHt2bkpPA/JZvcO9Wttw2I/Sc/8JV0ACXRCD1k8lq2qSH2u xFt8e4VclXK6orUp/sR81UNyuRsBU9CKP69jotta8/o3ZN0y/ATIUSrKa0W8LIOgRy2n DkB86wfYPzlKcUglMBue1jJjXIt1v3N2MKI2EvcrO/plB1MItPyrUhAx217Bc/mR4MCH vj2Ii+bGg1WlPNB/9eezKaFrqWjQ4uNrrqwZjwW+1wrycv8XxA+imCdxpWXZ+TBspfEU cO6A== 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=tqvp+bkIU1TWNlZpwcv+TKRU2X5GojmD5HYurFQV7BY=; b=tEiPOo+4gO0iFCGzfb7+nE/vki/+/g8WxGsu7j69sdItqspefaMU5L1PQxI9m1J4co W+k2mAy5kxKA6k4VLQJarg433R77otw06ZkXHksh3bZ4WX0wOdwQTxEvwWGJk4P3tHqt BBvULYFfGw4Kyi1pAfKB/Twrnj0r6Qb4sd+cqWgAqpyjGPs69HGPTCXcJrMXuogljo5I 1/W64F8Cuwi0fX2AvpFwmP9F7hQ33PYqE591nD+r0tblvTUyL3N7lByjN5JTLOlUSSBZ IlR5yQ7zulZaBwh/gmwwbozPfAalEJiK0f8qpN7kpwyf6+pnOt7TQzRmyT1Lcwc65t72 12yg== X-Gm-Message-State: AOAM530aImVDxOhmVgOu3uQRmtPFrinnJ4O+UlKJAzwz74i4D1+hkUVr OsyTEBoMmK/7l4TwFD6P7ykBaw== X-Received: by 2002:a1c:9a57:: with SMTP id c84mr3177066wme.136.1600242029785; Wed, 16 Sep 2020 00:40:29 -0700 (PDT) Received: from google.com (49.222.77.34.bc.googleusercontent.com. [34.77.222.49]) by smtp.gmail.com with ESMTPSA id u66sm3770553wme.12.2020.09.16.00.40.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 00:40:29 -0700 (PDT) Date: Wed, 16 Sep 2020 07:40:27 +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 Subject: Re: [PATCH 06/14] Fix CFLAGS for UBSAN_BOUNDS on Clang Message-ID: <20200916074027.GA2946587@google.com> References: <20200914172750.852684-1-georgepope@google.com> <20200914172750.852684-7-georgepope@google.com> <202009141509.CDDC8C8@keescook> <20200915102458.GA1650630@google.com> <20200915120105.GA2294884@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Thanks, George