From patchwork Wed Aug 19 19:16:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 247995 Delivered-To: patch@linaro.org Received: by 2002:a54:3b12:0:0:0:0:0 with SMTP id j18csp703166ect; Wed, 19 Aug 2020 12:17:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaBfEh7JI9BMI3nJBFD8/r5jWmilwX+3O6bYOi5RRiSc/VQrGzEdwP7rwcxG4i4F4aR0Vd X-Received: by 2002:a17:906:13d8:: with SMTP id g24mr26281591ejc.317.1597864643762; Wed, 19 Aug 2020 12:17:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597864643; cv=none; d=google.com; s=arc-20160816; b=aDVHUhtvJHqraoVE4lFdYHK8LOrkSW0V4rpAr0DR6rrres4YvRlCbbEJKq48cCz7Iz nDCZhsnkztYGVhEohi6bhkuJCZcPtDulRmcRu0B53tRwZ85YB3w3Z2Qfpwtj+eWhzScJ 1Ff+ZwoLj9YsHc2nq45+eZceyp1plG/0a5ypm7OT9WqV++yzE+TygZ1ObzcRmaBF8NgX DYXkNEZGmXO9Ii6PAD4r8sRtuv8Uz4cbgYkq7fbovN1IiEGSsl70YD2Oth08iuAVtzYF Qas//Xk27wk3UF8k7kaD68FiMLZJU/kqYGkG3NGAnbFYTr14j0tDK8Wod/SUo/qQIMzy RICA== 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:cc:to:from :subject:references:mime-version:message-id:in-reply-to:date :dkim-signature; bh=AYTx8OTXrfy1fkjiQ/QJZUTx1nYyS440PAIctrO8h/4=; b=tuYH+vGM/lmwHCLHZ6OXZMwFlKpUQwC3v6fm6IAcEvTT0cTCt5/dJr2z5iVVOpRlxz hn5zA8KlPTUjgR8Z7z65XBL61C0JDMHFtVJ1moSxN9b8VcjsWX4QYWi/VP0kRTgIx8s3 VZupbd+0ee5l/GVZ0dbY1UCkUtxupHU2IbX2AmVyXRzcX8JZYBI5UHqOhRDg1MMSjFhE 70v/OZelJPTqg1jK2br0WjdXk0XrI2kqpyoKj4EjwMnmX/g1FY4xzQh5dA/JwjDwDHOy HzLLT3TFJYAVZDEQt+6wx9nwQeCTQjLZyIeiWpFePC/hBka95j5TJxPMIuDf1wK1X2TO Z6ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="hU5/8DJY"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 f6si15983186edu.604.2020.08.19.12.17.23; Wed, 19 Aug 2020 12:17:23 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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="hU5/8DJY"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 S1726973AbgHSTRT (ORCPT + 15 others); Wed, 19 Aug 2020 15:17:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726991AbgHSTRK (ORCPT ); Wed, 19 Aug 2020 15:17:10 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B1A4C061342 for ; Wed, 19 Aug 2020 12:17:09 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id g127so26790878ybf.11 for ; Wed, 19 Aug 2020 12:17:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=AYTx8OTXrfy1fkjiQ/QJZUTx1nYyS440PAIctrO8h/4=; b=hU5/8DJYdBVIul76iBEmEZ0CUUQxYYOOHdwBe4d4zyPtB5gIZh8vrm6Ccwlw+L7mfG jT4Y2xyv2gvx6x+GF1XuIP6lvuA20HdADAoN96ldTrsTtbKn1/+bcvafV0ipxVGPvx5T OVGD/OW/Rm/RcYoUIfpfQAlOuAUQ5mPdB6lE+Pq/kfD1VWh7KsAWKxXxroLPwLw40+1i kvI45eNE7kkOgbXRICBXBMXLPlBDZYoiRoJLP51z6Bh+cy81LCawEG//TZN3rxPJtz6E aLLhREs3LcMxpShnPm0ZN5pRx9wDMtIvvkd7xgXg9RTXshqTL+GmUQ2DHv1Dd734CK3p ZQEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=AYTx8OTXrfy1fkjiQ/QJZUTx1nYyS440PAIctrO8h/4=; b=b4GGEAoqbFBwfZwzsRC0AFUqj/dnaIy07IBcJ7mpfQro3QBgvRXPaAE/oH7QcNadN/ kQqQTw3q4pImmgaiK2/VVZqaZAHu19m3zbA12Vc5+IPW8hqDCtLh4GlMxt/dAvjNpTRa bisPMzLofvRRCgpBo0Z0BijyNIMKVO95AA8HkiiWowLSvoTlFSeA+zFsgYO6FnjHd2/R 9iS3TwiMCxvgg6H55FlN3AhhjJmeCWOK+G9E3sG8XCbht7eRa1714pGeJlK+fYifpk23 lJep/wwbmwiGHbS7BoiCKPYv2DPfLBFPF9hR2tY3sdqSNLZ7BRpfF5J6mz1cFe66LW7H wYow== X-Gm-Message-State: AOAM53339I9XWMguTak+82TOp0TaOi/ITSkdAlecQ74yOqkUmwaZxgXx fuJ9KObbp9KOkO7TuUAdyCE0/nGQIthPzkXDfSM= X-Received: by 2002:a5b:c08:: with SMTP id f8mr34030464ybq.198.1597864628624; Wed, 19 Aug 2020 12:17:08 -0700 (PDT) Date: Wed, 19 Aug 2020 12:16:50 -0700 In-Reply-To: <20200819191654.1130563-1-ndesaulniers@google.com> Message-Id: <20200819191654.1130563-2-ndesaulniers@google.com> Mime-Version: 1.0 References: <20200819191654.1130563-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog Subject: [PATCH v2 1/5] Makefile: add -fno-builtin-stpcpy From: Nick Desaulniers To: Masahiro Yamada , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: Michal Marek , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Kees Cook , Tony Luck , Dmitry Vyukov , Michael Ellerman , Joe Perches , Joel Fernandes , Daniel Axtens , Arvind Sankar , Andy Shevchenko , Alexandru Ardelean , Yury Norov , x86@kernel.org, "H . Peter Anvin" , Ard Biesheuvel , "Paul E . McKenney" , Daniel Kiper , Bruce Ashfield , Marco Elver , Vamshi K Sthambamkadi , Andi Kleen , Linus Torvalds , "=?UTF-8?q?D=C3=A1vid=20Bolvansk=C3=BD?=" , Eli Friedman , Nick Desaulniers , stable@vger.kernel.org, Sami Tolvanen Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org LLVM implemented a recent "libcall optimization" that lowers calls to `sprintf(dest, "%s", str)` where the return value is used to `stpcpy(dest, str) - dest`. This generally avoids the machinery involved in parsing format strings. This optimization was introduced into clang-12. Because the kernel does not provide an implementation of stpcpy, we observe linkage failures for almost all targets when building with ToT clang. The interface is unsafe as it does not perform any bounds checking. Disable this "libcall optimization" via `-fno-builtin-stpcpy`. Cc: stable@vger.kernel.org # 4.4 Link: https://bugs.llvm.org/show_bug.cgi?id=47162 Link: https://github.com/ClangBuiltLinux/linux/issues/1126 Link: https://reviews.llvm.org/D85963 Reported-by: Sami Tolvanen Suggested-by: Dávid Bolvanský Suggested-by: Kees Cook Reviewed-by: Kees Cook Signed-off-by: Nick Desaulniers --- Makefile | 1 + 1 file changed, 1 insertion(+) -- 2.28.0.297.g1956fa8f8d-goog Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor diff --git a/Makefile b/Makefile index 9cac6fde3479..e523dc8d30e0 100644 --- a/Makefile +++ b/Makefile @@ -578,6 +578,7 @@ ifneq ($(LLVM_IAS),1) CLANG_FLAGS += -no-integrated-as endif CLANG_FLAGS += -Werror=unknown-warning-option +CLANG_FLAGS += -fno-builtin-stpcpy KBUILD_CFLAGS += $(CLANG_FLAGS) KBUILD_AFLAGS += $(CLANG_FLAGS) export CLANG_FLAGS