Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp936638pxa; Wed, 19 Aug 2020 20:34:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBzCvrgO6UcPO3aB62ZYl57GVXzW9dTZR74hli2P19wHBwgs9KfJk6oxGHe2+9yoouQc1E X-Received: by 2002:a05:6402:7d5:: with SMTP id u21mr1009067edy.235.1597894471624; Wed, 19 Aug 2020 20:34:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597894471; cv=none; d=google.com; s=arc-20160816; b=RwnUNzOW0217oKP/oxHoz+cgaoIydBK8ZrleolE9kYapTiQ7kQuYDwTXCeyo12LIPx 3UexYHtVwx2Fk5n9jJG/+Mc7ZKtQovGJ5PRngqAyTFezc9sDcNyXk84V4oISbLMgqRRw BfO47wIeq4UsR8I9o0Dsu7J1ZCqYkr14XEkOREi+/4DKU6EZHzIgXo+Uul53SUk22bCH nIMdFIajKsUb+3plpfUmnLPE12BvboO9pCwd4tYWE/bV8KSd8iALfaO6YYPL1pM/mgkR QygQ8K5x8LoHMyfVGnFpn/7b++z18yZyt+K7DaUNj30xxuR4CLudtOdYgPdU68+ArGgZ 1Atg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=U70M0DthPhvBPm+JwSxLRJEdOyYLX1RXRnFN4J4OreQ=; b=JQjhVipymxyou/DIy4FTRO0tYuT2sKHwPF3/PevtRAaRVvuL6cXp8bcnHD5hOvJwfQ ngqA/p8sleyYHdTHfj6EJjH2AmTif9xz+lT7HGDB7PpS/EBSCJ4+27M/j6eNB/pCfzsU ZMiIRqx1qGneboY3udGob6KDaSnVlIV+Qjfn6mxjmHkNuSWNCra56aaFMM3DlpQlCU8f 3cf7ctPgmJjCr0xsE7jYLFAPLz1EN2QLnZnj9gil4Q79sMbWSjdACHCZEOV6e443Y5cL lRs3UqijhQw6uUPagItmMqUO2hl3N/MndSub6TRRK8qSwvS59AnoloGb8kVEi5awza7T VVHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KpEwD66y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e5si467497ejq.390.2020.08.19.20.34.08; Wed, 19 Aug 2020 20:34:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@gmail.com header.s=20161025 header.b=KpEwD66y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726896AbgHTDdY (ORCPT + 99 others); Wed, 19 Aug 2020 23:33:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726872AbgHTDdW (ORCPT ); Wed, 19 Aug 2020 23:33:22 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0184CC061757; Wed, 19 Aug 2020 20:33:21 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id p4so510390qkf.0; Wed, 19 Aug 2020 20:33:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=U70M0DthPhvBPm+JwSxLRJEdOyYLX1RXRnFN4J4OreQ=; b=KpEwD66yBrruBO3QsYyaOwDCrPWzetFsZPTJHveDTAvV1wImb3iajyGumgOLMInvG7 1CqtCH/mQh0g1h+p6uDlkosEkWf6vH2BS75hPQl8PQ5k7+kZkyYFgbO7cG9y+PPErHx/ zdYz540CUfXWEFO2pCSN9B0kvqTLx5NoIDqLKqE4n+1K8Zggfon6oG3WWwlDYDQL7qq7 /WhzyMaJB6+wCB7FTbgpyEnk6t1MNmt++2xRVZ01/lA2DlkQ2tfq77V1PiHiEIyTmiML U0sbQ7Xfyksip8Kv5pqhnnuDcVTY6tf3Z64dMyGspTd6AsrkMNsPk1kLcILoMFJbHXFK mVwg== 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:content-transfer-encoding :in-reply-to; bh=U70M0DthPhvBPm+JwSxLRJEdOyYLX1RXRnFN4J4OreQ=; b=s10v2pZa5FLmZT+DGgEYckrgccI18iIceUOvZrSDIJa7jyouSLTrkVIh9SCWGWm1zq ztg7waEZvmZTqqCmwmKXpGB2Y3A0RHC9AV42Llh6vyVMesAlFCD+egeC2DK/T5jKxbzJ t3Kk9lU4K0apSMpuLFzJRifmFXEPBXYE6dlpH2dbZv4cXwBred0EoMfiNRflGDYZiVr2 9cGKTDIx++Y7cMwqqpgukrF+sbw180oJwWp/8dD7xWYFW2pBuwzjzH5OinC3PX4tS8QN SYJMcLNMO1botiEUy2dznTHUJ7hz3+9xYyJ6gne4o3Bpz9OEaC0ME8QFsRQK2y8NMi3d 4CUg== X-Gm-Message-State: AOAM532bYB8j3IWTICNwwW5TY/PmrIo0m5n9dnNoXp7Lb1zcEmGGUKQn NcR0fvldGG6GXZsusDqiUP8= X-Received: by 2002:a05:620a:12ef:: with SMTP id f15mr1079654qkl.120.1597894399877; Wed, 19 Aug 2020 20:33:19 -0700 (PDT) Received: from ubuntu-n2-xlarge-x86 ([2604:1380:45d1:2600::1]) by smtp.gmail.com with ESMTPSA id t32sm1713805qtb.3.2020.08.19.20.33.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 20:33:18 -0700 (PDT) Date: Wed, 19 Aug 2020 20:33:17 -0700 From: Nathan Chancellor To: Nick Desaulniers Cc: Masahiro Yamada , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , 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 , =?iso-8859-1?Q?D=E1vid_Bolvansk=FD?= , Eli Friedman , stable@vger.kernel.org, Sami Tolvanen Subject: Re: [PATCH v2 1/5] Makefile: add -fno-builtin-stpcpy Message-ID: <20200820033317.GA2167124@ubuntu-n2-xlarge-x86> References: <20200819191654.1130563-1-ndesaulniers@google.com> <20200819191654.1130563-2-ndesaulniers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200819191654.1130563-2-ndesaulniers@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 19, 2020 at 12:16:50PM -0700, Nick Desaulniers wrote: > 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 Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor > --- > Makefile | 1 + > 1 file changed, 1 insertion(+) > > 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 > -- > 2.28.0.297.g1956fa8f8d-goog >