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.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, 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 BF335C35280 for ; Fri, 8 May 2020 01:36:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8577F208DB for ; Fri, 8 May 2020 01:36:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="odhokjjC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8577F208DB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 36CDC900010; Thu, 7 May 2020 21:36:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 31CF4900002; Thu, 7 May 2020 21:36:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2591E900010; Thu, 7 May 2020 21:36:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0233.hostedemail.com [216.40.44.233]) by kanga.kvack.org (Postfix) with ESMTP id 0D6E1900002 for ; Thu, 7 May 2020 21:36:26 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C2C41988D for ; Fri, 8 May 2020 01:36:25 +0000 (UTC) X-FDA: 76791836730.09.snake06_72502a172db32 X-HE-Tag: snake06_72502a172db32 X-Filterd-Recvd-Size: 4126 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Fri, 8 May 2020 01:36:25 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6725C21655; Fri, 8 May 2020 01:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588901784; bh=f9J9dSVZx76PStL71j6469SaTfwQ9eUSXhcpTRRQ0bU=; h=Date:From:To:Subject:In-Reply-To:From; b=odhokjjCsF8werdPERTE/AiCfK2AG9Bl0XO1R7nODsStTpdXU6hCHTQGaGPIcVxSI WOdDDxXyplG2PjsT9ZpTyK05jKuuVxeaDtLdM1jLwd7OAJsJfPbKbysqqneuKguqxe r5eGrUR1Dlr54Fnxn0K59oV4xPsVl5yi843pfxOw= Date: Thu, 07 May 2020 18:36:23 -0700 From: Andrew Morton To: akpm@linux-foundation.org, aryabinin@virtuozzo.com, jpoimboe@redhat.com, keescook@chromium.org, linux-mm@kvack.org, mm-commits@vger.kernel.org, peterz@infradead.org, rdunlap@infradead.org, sfr@canb.auug.org.au, torvalds@linux-foundation.org Subject: [patch 14/15] ubsan: disable UBSAN_ALIGNMENT under COMPILE_TEST Message-ID: <20200508013623.Dg79k43ni%akpm@linux-foundation.org> In-Reply-To: <20200507183509.c5ef146c5aaeb118a25a39a8@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Kees Cook Subject: ubsan: disable UBSAN_ALIGNMENT under COMPILE_TEST The documentation for UBSAN_ALIGNMENT already mentions that it should not be used on all*config builds (and for efficient-unaligned-access architectures), so just refactor the Kconfig to correctly implement this so randconfigs will stop creating insane images that freak out objtool under CONFIG_UBSAN_TRAP (due to the false positives producing functions that never return, etc). Link: http://lkml.kernel.org/r/202005011433.C42EA3E2D@keescook Fixes: 0887a7ebc977 ("ubsan: add trap instrumentation option") Signed-off-by: Kees Cook Reported-by: Randy Dunlap Link: https://lore.kernel.org/linux-next/202004231224.D6B3B650@keescook/ Cc: Josh Poimboeuf Cc: Stephen Rothwell Cc: Peter Zijlstra Cc: Andrey Ryabinin Signed-off-by: Andrew Morton --- lib/Kconfig.ubsan | 15 ++++------ tools/testing/selftests/wireguard/qemu/debug.config | 1 2 files changed, 6 insertions(+), 10 deletions(-) --- a/lib/Kconfig.ubsan~ubsan-disable-ubsan_alignment-under-compile_test +++ a/lib/Kconfig.ubsan @@ -60,18 +60,15 @@ config UBSAN_SANITIZE_ALL Enabling this option will get kernel image size increased significantly. -config UBSAN_NO_ALIGNMENT - bool "Disable checking of pointers alignment" - default y if HAVE_EFFICIENT_UNALIGNED_ACCESS +config UBSAN_ALIGNMENT + bool "Enable checks for pointers alignment" + default !HAVE_EFFICIENT_UNALIGNED_ACCESS + depends on !X86 || !COMPILE_TEST help - This option disables the check of unaligned memory accesses. - This option should be used when building allmodconfig. - Disabling this option on architectures that support unaligned + This option enables the check of unaligned memory accesses. + Enabling this option on architectures that support unaligned accesses may produce a lot of false positives. -config UBSAN_ALIGNMENT - def_bool !UBSAN_NO_ALIGNMENT - config TEST_UBSAN tristate "Module for testing for undefined behavior detection" depends on m --- a/tools/testing/selftests/wireguard/qemu/debug.config~ubsan-disable-ubsan_alignment-under-compile_test +++ a/tools/testing/selftests/wireguard/qemu/debug.config @@ -25,7 +25,6 @@ CONFIG_KASAN=y CONFIG_KASAN_INLINE=y CONFIG_UBSAN=y CONFIG_UBSAN_SANITIZE_ALL=y -CONFIG_UBSAN_NO_ALIGNMENT=y CONFIG_UBSAN_NULL=y CONFIG_DEBUG_KMEMLEAK=y CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE=8192 _