From patchwork Mon Jul 22 12:50:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 169384 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7488842ilk; Mon, 22 Jul 2019 05:52:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6JARWLxYcl6a1TriBt5gtWjbse/UIyoccCBUbkdSDhYCYSv4Lnm4MxE3mSRWXnPZsWRRI X-Received: by 2002:a63:e901:: with SMTP id i1mr55154072pgh.451.1563799944658; Mon, 22 Jul 2019 05:52:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563799944; cv=none; d=google.com; s=arc-20160816; b=L9/WgiewEEZvQyiIuSVIidbOr5ohszgIEeLzJNQeE4f9bfpIoUFbajK4okk4vQlgfE BEuCveb0BZXK08QiE7srkdq5/+mgedL2AOVm6wKFl+y333KHmZwoZmgoNoKO/4zNlWat ZgSrv3ERBZJoJFfXrt2xYeiNAie/ZikIKmLspWxDLjoYtM3ZB3isQZpldTD5EqrjNjam TnWcA1U4hT7PQ9sRuLV7eLj8T1heKmuNrVWBKZyijPtMEBPedyvwEj0cwblIy0+nueXt cnjjXKGecZMOr7Ve/KeL++CTOo8oDU1kOPsrwuh/c2USB4R085WrkpmDG3CvbARUcNoN i4nw== 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:mime-version :message-id:date:subject:cc:to:from; bh=kNEmVsUid4Fi+RFmi/8D6rVT8/YygJE1FYcmVh5eSzQ=; b=LITXWui9FGBeAMwsV4EKcfhD+inuGhH6NDgSsvmqGMTcl0pCyuYiFSi8g24yNpkka4 RgWC9yI6g4tgiXfZt7EUjeaCvLUWtznqVPNZn7rdgG1AuvBtTnrdKA9SUhVpjcFJxt6c EcumLF9euv9uPZtSVgeQMoDmqs8MmdkinVAAlelVQ0bNDNnsQGTXkhFzjTHx2bxVB2NN cKN5UBL3vpJh/ybegXw3/AeKNIxkLd+Wdv6tXhuxfWvCYoTfGYG93Lcu6nH2Fp/L05Dg 2U0DYWySkm7p8RmumjCZtIT9K/nTGCYpPPl/+ISJ54GxG2wRPnrTTqguUDUhJW9fNwvY NZeQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g1si8460239plg.353.2019.07.22.05.52.23; Mon, 22 Jul 2019 05:52:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727721AbfGVMwX (ORCPT + 14 others); Mon, 22 Jul 2019 08:52:23 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:58069 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726236AbfGVMwX (ORCPT ); Mon, 22 Jul 2019 08:52:23 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.145]) with ESMTPA (Nemesis) id 1MysBI-1icPK53l90-00vyTP; Mon, 22 Jul 2019 14:51:48 +0200 From: Arnd Bergmann To: Andrey Ryabinin , akpm@linux-foundation.org Cc: Josh Poimboeuf , Peter Zijlstra , Arnd Bergmann , stable@vger.kernel.org, Borislav Petkov , Dmitry Vyukov , Thomas Gleixner , Ingo Molnar , Kees Cook , Matthew Wilcox , Ard Biesheuvel , Andy Shevchenko , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH] [v2] ubsan: build ubsan.c more conservatively Date: Mon, 22 Jul 2019 14:50:44 +0200 Message-Id: <20190722125139.1335385-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:ZbSfErMSYT0XZps8vqU+FdzxiZIIfdRsVbwo2+ZwWA6bzGC/I+J KFdIEBcdZUW8aDO6RrtMhqauXy0rH/NfKjfGmJdkiNOSJ6sdejYtP9dfLjtgYCLslrunH9o 19YhL4jj2fsSiGKT2n+rbI92yJSkhdQoS9MC8aZW/5hAa6/MYJaW1MjL7ikoW258MJ1j+PP b0qBCormfF0Ay2Iq69rrg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:Fru7WA/0SPY=:vO4Aj/PjqBmpCCbNqTzdyt Q6nVC4CU8ncCdVXbm8ukI4ZyQqE//Fg1Ah2aNRoJ4DfapUAnRfr1osMWBFxLya51TxOtb9NUk GRz40FOeFIx80pOUfvhhF+tx/IhFoWY1cK9WEr39vVn62G6WnMIrhK4T5oq9yygamIX04E4yR 3kFacJ7KQyfHeyqShHR9REb1f9viZ6l1kmal0m2hqrw9PEqJIWE5Bxjh+MOyVoPmw95XVh+OW VrrwGM3ns9CIUB5rc+G1dMmIKeu6u+QQp845bHrq7/CUrcV7YHW4k710EaRMydfRBhSCaGCVP NShVaXH78Fgcg580XfZm/K2WcFynGrXCTzNg8vRBlv0fSGb0BEQL46NMg6vndTS2vY2U215r/ qIF9/HM+mXd0mRbAyQdvmV+rCXPWw8p6Wp3eIswYqqjAmdJb7zjm836JsIf6bjqFNrXjuCbNo jOQEmaLNsk/VnQE0An7GL9XlPpJXfMqIaL2xG0xYImPrxEIWPGKtXE+U/U5f10ZCxJDCEYgSs vy2KkPtfigdXkAwDKmW61IgWgYn7r+Ptu1K2rXv9y9UsxbivKSGDx0zVfFpFoVYqUwLcNqlwH gob87cPAZ07kHesQoQ/N52T+bj3X9YKlof11u9Ui/6L5f76bITDEdlluo6uRX0rCWjmpGSSM1 gmqdS4siGLsLPVxRZaVA0hJRPw0OtnP/hCs9JRG/UNiI1rbgwSOZKiJXXiEDrT+YvQRC+MZx0 qzcwZ+nCd8IvJ43W5K8v4dkSbNg7ahYvXvLqSQ== Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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. According to Andrey Ryabinin, that option is not even needed, dropping it here fixes the stackprotector issue. Fixes: d08965a27e84 ("x86/uaccess, ubsan: Fix UBSAN vs. SMAP") Link: https://lore.kernel.org/lkml/20190617123109.667090-1-arnd@arndb.de/t/ Link: https://lore.kernel.org/lkml/20190722091050.2188664-1-arnd@arndb.de/t/ Cc: stable@vger.kernel.org Signed-off-by: Arnd Bergmann --- v2: - drop -fno-conserve-stack - fix the Fixes: line --- lib/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.20.0 Reviewed-by: Andrey Ryabinin diff --git a/lib/Makefile b/lib/Makefile index 095601ce371d..29c02a924973 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-stack-protector) $(DISABLE_STACKLEAK_PLUGIN) obj-$(CONFIG_SBITMAP) += sbitmap.o