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 86EEDC433E2 for ; Tue, 15 Sep 2020 12:09:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4BF91206DB for ; Tue, 15 Sep 2020 12:09:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Zb9L1job" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726382AbgIOMI5 (ORCPT ); Tue, 15 Sep 2020 08:08:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726465AbgIOMBm (ORCPT ); Tue, 15 Sep 2020 08:01:42 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B833EC061351 for ; Tue, 15 Sep 2020 05:01:08 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id x14so2971665wrl.12 for ; Tue, 15 Sep 2020 05:01:08 -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=D1RHl8ABdhn5KjoXJVQFbK3lZzim3prS8WaJzdIy+Zo=; b=Zb9L1jobJQn7TM+/5qKmWs5QBd2EXGxISO/ZkcumPM8Vro0Vr55MmlKUwUifKoKJg+ zl/iDbZ2w5XqrlxmJkjZgmmZP5NI1934atyy561Ay2MXa+FnuuynbncFOlg6j1nAM8ei nQJq5CvBO8QomgfteMuJPONS1P+ZZCvCiP3bLKVjNIYXIcqQgdzXgAjr3TShuD/NTpLq WK/qwY8X5PijIrR+U2tADWCc41LFvUI6wRrhWcMVNdBvt24fQOuGsuHn/kO9UmXlrJl9 lA14MFwIiIxLtPEKAUDzC+4CdfxeTGre++QHrUGZAZncOeGJWO14UVlnAnY/vdGLIltr bPKA== 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=D1RHl8ABdhn5KjoXJVQFbK3lZzim3prS8WaJzdIy+Zo=; b=qD1ADhZXIsKNiQyLeO5ZybpRQF7y5C9Gk2YdKAsSpePKMkpax6RaZ/heERnLJT6afC Hpw4Ma9bU5EaOU9lh5FfWhVhQKecv9xJwwiNlRxTXYwPl9EvLbwK5ltE4sjVBsIMex4O 956DFlEk1XnzqedAqds+vVDhj7VZkm+y/eKB4GLQLVKZTMuWM3XyxNJNnnNNXmw9N+ZJ nI1v+rwk/DJtU2Tj3CGGP0b1xGgjPu0XHUG50/4elRW2rNoxm0yS2l4+JSyWCqgN3TEC DhP0c9jLAQRfadXGIXPQFA9Q8V09cdjYKJKWfgZf49s4jTKU6BVyXLkLAifyLWEPF838 1DXA== X-Gm-Message-State: AOAM530EsKDMvu4mag+/F+yMcJwqa3DKpUa1xlGSgg7IChi9peWdNDOq ubpts0RoN+rtYBIFT0/6MKjVZg== X-Google-Smtp-Source: ABdhPJw9xzBTkm1ex/SpXs3gzQoe/wJz8pjYJNPqDjhDGb9ai+C4+hJhDspqERQLDE8pW/IN0QMg9Q== X-Received: by 2002:adf:91c2:: with SMTP id 60mr22458843wri.292.1600171267204; Tue, 15 Sep 2020 05:01:07 -0700 (PDT) Received: from google.com (49.222.77.34.bc.googleusercontent.com. [34.77.222.49]) by smtp.gmail.com with ESMTPSA id s124sm25145526wme.29.2020.09.15.05.01.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 05:01:06 -0700 (PDT) Date: Tue, 15 Sep 2020 12:01:05 +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 , dbrazdil@google.com, broonie@kernel.org, maskray@google.com, ascull@google.com, Andrew Morton , Dmitry Vyukov , Thomas Gleixner , Arnd Bergmann Subject: Re: [PATCH 06/14] Fix CFLAGS for UBSAN_BOUNDS on Clang Message-ID: <20200915120105.GA2294884@google.com> References: <20200914172750.852684-1-georgepope@google.com> <20200914172750.852684-7-georgepope@google.com> <202009141509.CDDC8C8@keescook> <20200915102458.GA1650630@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 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. 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=-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 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 C793EC433E2 for ; Tue, 15 Sep 2020 12:01:16 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 3A08621D7B for ; Tue, 15 Sep 2020 12:01:15 +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="Zb9L1job" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A08621D7B 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 933B34B1EB; Tue, 15 Sep 2020 08:01:15 -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 8lRXOo5Sl6A7; Tue, 15 Sep 2020 08:01:10 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 93A764B163; Tue, 15 Sep 2020 08:01:10 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 7487C4B163 for ; Tue, 15 Sep 2020 08:01:09 -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 3-GSKn3Loq+d for ; Tue, 15 Sep 2020 08:01:08 -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 624184B161 for ; Tue, 15 Sep 2020 08:01:08 -0400 (EDT) Received: by mail-wr1-f66.google.com with SMTP id e16so3050739wrm.2 for ; Tue, 15 Sep 2020 05:01:08 -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=D1RHl8ABdhn5KjoXJVQFbK3lZzim3prS8WaJzdIy+Zo=; b=Zb9L1jobJQn7TM+/5qKmWs5QBd2EXGxISO/ZkcumPM8Vro0Vr55MmlKUwUifKoKJg+ zl/iDbZ2w5XqrlxmJkjZgmmZP5NI1934atyy561Ay2MXa+FnuuynbncFOlg6j1nAM8ei nQJq5CvBO8QomgfteMuJPONS1P+ZZCvCiP3bLKVjNIYXIcqQgdzXgAjr3TShuD/NTpLq WK/qwY8X5PijIrR+U2tADWCc41LFvUI6wRrhWcMVNdBvt24fQOuGsuHn/kO9UmXlrJl9 lA14MFwIiIxLtPEKAUDzC+4CdfxeTGre++QHrUGZAZncOeGJWO14UVlnAnY/vdGLIltr bPKA== 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=D1RHl8ABdhn5KjoXJVQFbK3lZzim3prS8WaJzdIy+Zo=; b=mMkSf2WE95i6N64GT5Z1WzOIq9sczYRzophhDOs3EYNYwQq+JvRdr+TiKDCmrk9LgW Nh5amk5LuMmJtW62Ua3yhXd5iLXDxAFxDAxn4ly8vyN+8I0SRvlfok60dTKmL+szaXf1 yO5k1KNQjl3hbsz4TAu7UJaRm3KOgMXAmZTSBNV//eC85YMYLb/S1fzIS55YUnD+cAa9 8KZWmjBtWThq56JxTwb9m4iVtdSLl9nSVDo9JbFMBThNFBkKgnpxwrX+WMJZFqdQ9qYJ 09TFKXiYAMgsc/GyZtLLs9qx7iDhldi0QAidqAD3iI6kUSPiwPke5aEWyYRyzuAMI3Y/ a8SQ== X-Gm-Message-State: AOAM5333aXwdB2vISXg8qg7RzTmV67Hy5+qZXrI7w7WJRN5jqMSWytFo MstOxjY7Tf4ghGGASJpJIYE6bQ== X-Google-Smtp-Source: ABdhPJw9xzBTkm1ex/SpXs3gzQoe/wJz8pjYJNPqDjhDGb9ai+C4+hJhDspqERQLDE8pW/IN0QMg9Q== X-Received: by 2002:adf:91c2:: with SMTP id 60mr22458843wri.292.1600171267204; Tue, 15 Sep 2020 05:01:07 -0700 (PDT) Received: from google.com (49.222.77.34.bc.googleusercontent.com. [34.77.222.49]) by smtp.gmail.com with ESMTPSA id s124sm25145526wme.29.2020.09.15.05.01.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 05:01:06 -0700 (PDT) Date: Tue, 15 Sep 2020 12:01:05 +0000 From: George Popescu To: Marco Elver Subject: Re: [PATCH 06/14] Fix CFLAGS for UBSAN_BOUNDS on Clang Message-ID: <20200915120105.GA2294884@google.com> References: <20200914172750.852684-1-georgepope@google.com> <20200914172750.852684-7-georgepope@google.com> <202009141509.CDDC8C8@keescook> <20200915102458.GA1650630@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Cc: Thomas Gleixner , Catalin Marinas , Will Deacon , kvmarm@lists.cs.columbia.edu, maskray@google.com, 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, 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. 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=-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 125AAC43461 for ; Tue, 15 Sep 2020 12:02:48 +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 B589321D43 for ; Tue, 15 Sep 2020 12:02:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="DqGsHrnG"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="Zb9L1job" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B589321D43 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=vuC4EE7SpBVcJhWhULTZiIUn/MDleZbk3DCbQE+iFDU=; b=DqGsHrnGsNxAVJfbsTFRJBqeD UcW/BQaW8FPekGl1ZWZXkN0LllMnLIYi76uzZT2L/OyeQhWsOS1iJIGoz21H98MYpGe7BUIVwd+j6 enh+GrKsemKBGnU79Rmw3DJvJWyQp9jKF3Z9ZE2GDyAbiE8K6qWqx524krfxlm2KmeXZ315pJHueI HLOGiJhAvCt7c4v6paOIajVLg22/wyzTU6dU9BmkMJvDIoQD3d4uZXrZE1+N6YJi1XDBvkWmBi+4F R5t1kcgr/zwqDbmeRDQsT9klLU3V5vwJ64EuGAEJ0mQ4OrFtfjqSpsVzwsfu9n6rjd/b7c5uAeSWN N+Oh5Ymig==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kI9e4-0004uR-1j; Tue, 15 Sep 2020 12:01:12 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kI9e0-0004tp-CH for linux-arm-kernel@lists.infradead.org; Tue, 15 Sep 2020 12:01:10 +0000 Received: by mail-wr1-x441.google.com with SMTP id z4so3029087wrr.4 for ; Tue, 15 Sep 2020 05:01:08 -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=D1RHl8ABdhn5KjoXJVQFbK3lZzim3prS8WaJzdIy+Zo=; b=Zb9L1jobJQn7TM+/5qKmWs5QBd2EXGxISO/ZkcumPM8Vro0Vr55MmlKUwUifKoKJg+ zl/iDbZ2w5XqrlxmJkjZgmmZP5NI1934atyy561Ay2MXa+FnuuynbncFOlg6j1nAM8ei nQJq5CvBO8QomgfteMuJPONS1P+ZZCvCiP3bLKVjNIYXIcqQgdzXgAjr3TShuD/NTpLq WK/qwY8X5PijIrR+U2tADWCc41LFvUI6wRrhWcMVNdBvt24fQOuGsuHn/kO9UmXlrJl9 lA14MFwIiIxLtPEKAUDzC+4CdfxeTGre++QHrUGZAZncOeGJWO14UVlnAnY/vdGLIltr bPKA== 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=D1RHl8ABdhn5KjoXJVQFbK3lZzim3prS8WaJzdIy+Zo=; b=j148TihpxbU4cmSuz/HdexD8CeS4/2Z3aVYGK9mSiP0FO7rGIQV6fHrRoEZoup2X49 nRMdgKXX2cyAutZfkJQfjyBmm3eFGHIO9NwdhkTJgjwLlV9HawCYBF0SjolEgHx7itFM DFwqotVVeDitQWkgZoiPhnrH/TGpNmIupaoLju7KXy6DmUcT492qCnEUoonj1O0hX9wZ qzFwNj3LTtyf8+1mvykyHPayr69nYhhyc1jo18Rqz0lkycuyMrTCrCDVgbeFtPtiYh/B 9FBV3+tmKe3LQlhdwxiz6HBLjHFz06AM9WTLI9QgIA7eOu36gjLgWj9/bfilQNDC2zAv UbvQ== X-Gm-Message-State: AOAM5315j7PQxzSsPL8e8edLhO1DPid85ljeJneYh4dnieJ+9WH/dWVO r+mKfXhC6bY7/WLTiYAO8CbzMA== X-Google-Smtp-Source: ABdhPJw9xzBTkm1ex/SpXs3gzQoe/wJz8pjYJNPqDjhDGb9ai+C4+hJhDspqERQLDE8pW/IN0QMg9Q== X-Received: by 2002:adf:91c2:: with SMTP id 60mr22458843wri.292.1600171267204; Tue, 15 Sep 2020 05:01:07 -0700 (PDT) Received: from google.com (49.222.77.34.bc.googleusercontent.com. [34.77.222.49]) by smtp.gmail.com with ESMTPSA id s124sm25145526wme.29.2020.09.15.05.01.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 05:01:06 -0700 (PDT) Date: Tue, 15 Sep 2020 12:01:05 +0000 From: George Popescu To: Marco Elver Subject: Re: [PATCH 06/14] Fix CFLAGS for UBSAN_BOUNDS on Clang Message-ID: <20200915120105.GA2294884@google.com> References: <20200914172750.852684-1-georgepope@google.com> <20200914172750.852684-7-georgepope@google.com> <202009141509.CDDC8C8@keescook> <20200915102458.GA1650630@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-20200915_080109_710826_33C81B17 X-CRM114-Status: GOOD ( 22.04 ) 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, maskray@google.com, maz@kernel.org, Masahiro Yamada , suzuki.poulose@arm.com, clang-built-linux , Linux ARM , dbrazdil@google.com, julien.thierry.kdev@gmail.com, Kees Cook , Arnd Bergmann , Linux Kbuild mailing list , broonie@kernel.org, ascull@google.com, 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, 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. Thanks, George _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel