Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7193125ybi; Mon, 22 Jul 2019 08:38:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwRWUrL1FaoJ3ooF73Dr+8SM/rwhOtuCVdH7/Bmyc62UwfMBMwZ3MJZ8DQ0wXs/Yyg55l9V X-Received: by 2002:a63:e54:: with SMTP id 20mr70680480pgo.244.1563809903426; Mon, 22 Jul 2019 08:38:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563809903; cv=none; d=google.com; s=arc-20160816; b=SuS7IKDq7TwTb0XnawHslw2htLKjWpM+zQ5q07Qjj3mvWdOmTxEY/DcVoUhzwyw8Rx tsBNdlTOwP+kMFGV7hOX1ucW+9V9xRl32hArZiTIcrOOdoK90Eqe8oUyaW9/jUk9yUG5 su/PlAMabZ06PEhF154N1TDkKL4QjZ3Z4pnCo4+dCprpEQ2xyVrdoF8bDNb+h4nMzMdk EXYFIeJ5txXIp7zdTJx7cIk7gCcZtQxisd4/YKpC+kaWzrHk/wH9P71D7rUZ7vjiFGyy mHxEqT5OBYwsHCWHJ6fYhWsqBTYd2eb4JarL+8rQ/nfG0QwIm4OKdqnd44OcdwGrJzYL vv2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=GX6WTIGpXlEmgpoBSTRC9ODKtMxSOJRGIMA2HYYDI+w=; b=i1gjv5QHfno7f3uvfI5f1WE+X4uerzImC6811w3BgUNLXAW5oB3QMBxaAH0D9oEIw7 Byjis5Xm36EkEuzR97V+5m1KolMb1JAG5Pw8/1LyS+x+ojSDg54hWzwu5z2ZAfD4jWng C/aHxmdoU9MHKVeh53kOVS6/d7OgrNrYdUmfeQy3mN37t9CB/ctE9+HZwWck84UVJaUx NvoO0gxlZHVaB2sgvjTlfa4mNoYEDBJNpDg2vXYFgnf4T947hC3dbZ5iHHEXDdorb+FK /AFQiYUIkRcDYOAcP/8mfm0ZL3FL4GsEa4DZCk1qw4ToWG2jq75yYs2bec9NgwrqINBw ljwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w184si14855036pgb.305.2019.07.22.08.38.07; Mon, 22 Jul 2019 08:38:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728646AbfGVMZT (ORCPT + 99 others); Mon, 22 Jul 2019 08:25:19 -0400 Received: from relay.sw.ru ([185.231.240.75]:41606 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727040AbfGVMZT (ORCPT ); Mon, 22 Jul 2019 08:25:19 -0400 Received: from [172.16.25.12] by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1hpXNO-0001ko-UQ; Mon, 22 Jul 2019 15:25:11 +0300 Subject: Re: [PATCH] ubsan: build ubsan.c more conservatively To: Arnd Bergmann , akpm@linux-foundation.org Cc: Josh Poimboeuf , Peter Zijlstra , stable@vger.kernel.org, Sodagudi Prasad , Linus Torvalds , Kees Cook , Andy Shevchenko , "David S. Miller" , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com References: <20190722091050.2188664-1-arnd@arndb.de> From: Andrey Ryabinin Message-ID: Date: Mon, 22 Jul 2019 15:25:12 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190722091050.2188664-1-arnd@arndb.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/22/19 12:10 PM, Arnd Bergmann wrote: > objtool points out several conditions that it does not like, depending > on the combination with other configuration options and compiler > variants: > > stack protector: > lib/ubsan.o: warning: objtool: __ubsan_handle_type_mismatch()+0xbf: call to __stack_chk_fail() with UACCESS enabled > lib/ubsan.o: warning: objtool: __ubsan_handle_type_mismatch_v1()+0xbe: call to __stack_chk_fail() with UACCESS enabled > > stackleak plugin: > lib/ubsan.o: warning: objtool: __ubsan_handle_type_mismatch()+0x4a: call to stackleak_track_stack() with UACCESS enabled > lib/ubsan.o: warning: objtool: __ubsan_handle_type_mismatch_v1()+0x4a: call to stackleak_track_stack() with UACCESS enabled > > kasan: > lib/ubsan.o: warning: objtool: __ubsan_handle_type_mismatch()+0x25: call to memcpy() with UACCESS enabled > lib/ubsan.o: warning: objtool: __ubsan_handle_type_mismatch_v1()+0x25: call to memcpy() with UACCESS enabled > > The stackleak and kasan options just need to be disabled for this file > as we do for other files already. For the stack protector, we already > attempt to disable it, but this fails on clang because the check is > mixed with the gcc specific -fno-conserve-stack option, so we need to > test them separately. > > Fixes: 42440c1f9911 ("lib/ubsan: add type mismatch handler for new GCC/Clang") There was no uaccess validataion at that time, so the right fixes line is probably this: Fixes: d08965a27e84 ("x86/uaccess, ubsan: Fix UBSAN vs. SMAP") > Link: https://lore.kernel.org/lkml/20190617123109.667090-1-arnd@arndb.de/t/ > Cc: stable@vger.kernel.org > Signed-off-by: Arnd Bergmann > --- > lib/Makefile | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/lib/Makefile b/lib/Makefile > index 095601ce371d..320e3b632dd3 100644 > --- a/lib/Makefile > +++ b/lib/Makefile > @@ -279,7 +279,8 @@ obj-$(CONFIG_UCS2_STRING) += ucs2_string.o > obj-$(CONFIG_UBSAN) += ubsan.o > > UBSAN_SANITIZE_ubsan.o := n > -CFLAGS_ubsan.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) > +KASAN_SANITIZE_ubsan.o := n > +CFLAGS_ubsan.o := $(call cc-option, -fno-conserve-stack) $(call cc-option, -fno-stack-protector) $(DISABLE_STACKLEAK_PLUGIN) $(call cc-option, -fno-conserve-stack) can be removed entirely. It's just copy paste from kasan Makefile. It was added in kasan purely for performance reasons. Not sure that it's needed even in kasan Makefile, the code which was the reason for adding fno-conserve-stack might not get into the final version of KASAN patches.