From patchwork Mon Jun 14 10:26:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 459824 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3181735jae; Mon, 14 Jun 2021 04:11:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7Y/K/43byYfVaWlDvbZGsNkx0mOeB6tSnmFSykKiOedyYiWUN2nSy55aMe58P/i9qd/kU X-Received: by 2002:aa7:d413:: with SMTP id z19mr16584705edq.37.1623669119190; Mon, 14 Jun 2021 04:11:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623669119; cv=none; d=google.com; s=arc-20160816; b=ySo1ruskeGgA3fOAtH4GjI7CbZMfGAZy23VbKuyONXGaqCeF5BxjpDN/A78ALDYr8R cIZwEaFHAbUYPxozhV3frhuk9GSi6037/lo74lMw8d9nQb32J9ltioXkiAwvV4hZ+nHF kS4f8te65+hWRbo9ZbymbhsYR9xqLjYC/Lff6FQeuGzdZnr8G54Xm/EhPnWhPQvIVEtk Be8G+7Un5UCuVq/c6U8njYAMx2/omtt1wXg0ZGYH+jZZAMSodIwYk409hKWS1FK3P9lQ KCh0i3dxFo27+vJfz1Vgnn+G4z0qQo9Qg5kQVBcg1VE4w9Y9KfZMRritUQKj8nXiRH9L 67PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wqHp3h8ia1sBUz5uZf8K2EV8cKoAWJqbjCL3UPYEGdQ=; b=AAX67gbrtcR5noJND5xNCgzI1WH6pzBQbnfnYchv8TLcxR6Ly9eTpgRma0kurW+xfg g/pap2AQHYTDhD9H5ZfhQcnkvR06rxG9sCcuVZMcZlN+NpQDelZL4KZyGHIhy8HLiUtw JN4utmIr0FEVTCn/TpbLm+MkFlP0pNcX6Iqgg9nJO0Lz35hn+eLVcCX3iYZK/1qZejXk bs16PJOEm22SQU61wJLnWsg1MzNs46pF9116aIYGhJbWwRmiitfFCZGqhprSJ8QxjZnQ spPx8MjSRaxFx+VSJleEpSRNKNM5SR8hqVrp/oNaNxOvYSaUM6bL6lWjNBpWlHczLefS bFSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JRi6odW9; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 4si11523932ejm.546.2021.06.14.04.11.58; Mon, 14 Jun 2021 04:11:59 -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=@linuxfoundation.org header.s=korg header.b=JRi6odW9; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235398AbhFNLN6 (ORCPT + 12 others); Mon, 14 Jun 2021 07:13:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:42526 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234717AbhFNLLz (ORCPT ); Mon, 14 Jun 2021 07:11:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0FCDA61951; Mon, 14 Jun 2021 10:48:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623667684; bh=ROxKfwcxodE0zhvauAbH2Wq6lyAIhtvHimFSA8eXLvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JRi6odW9pNYr0QBFWAg7XPnCLruJIsJf04TkL+vKmZZcgScMKp1iJBXV3U28aIy9e G9tWyYVq7AFLK81jslNy4zTxp4B5MoIZOysOJun9hcgWo4ZVCoxlXArx09AwDzeYmh uoAGf6Q6Ahx+b+1bsAN5IJxrfwpiFGFDuVSaTtYw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sami Tolvanen , Candle Sun , Fangrui Song , Nick Desaulniers , Kees Cook , Sasha Levin Subject: [PATCH 5.12 035/173] Makefile: LTO: have linker check -Wframe-larger-than Date: Mon, 14 Jun 2021 12:26:07 +0200 Message-Id: <20210614102659.317088098@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210614102658.137943264@linuxfoundation.org> References: <20210614102658.137943264@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Nick Desaulniers [ Upstream commit 24845dcb170e16b3100bd49743687648c71387ae ] -Wframe-larger-than= requires stack frame information, which the frontend cannot provide. This diagnostic is emitted late during compilation once stack frame size is available. When building with LTO, the frontend simply lowers C to LLVM IR and does not have stack frame information, so it cannot emit this diagnostic. When the linker drives LTO, it restarts optimizations and lowers LLVM IR to object code. At that point, it has stack frame information but doesn't know to check for a specific max stack frame size. I consider this a bug in LLVM that we need to fix. There are some details we're working out related to LTO such as which value to use when there are multiple different values specified per TU, or how to propagate these to compiler synthesized routines properly, if at all. Until it's fixed, ensure we don't miss these. At that point we can wrap this in a compiler version guard or revert this based on the minimum support version of Clang. The error message is not generated during link: LTO vmlinux.o ld.lld: warning: stack size limit exceeded (8224) in foobarbaz Cc: Sami Tolvanen Reported-by: Candle Sun Suggested-by: Fangrui Song Signed-off-by: Nick Desaulniers Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/20210312010942.1546679-1-ndesaulniers@google.com Signed-off-by: Sasha Levin --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) -- 2.30.2 diff --git a/Makefile b/Makefile index ebc02c56db03..358a2b103de9 100644 --- a/Makefile +++ b/Makefile @@ -912,6 +912,11 @@ CC_FLAGS_LTO += -fvisibility=hidden # Limit inlining across translation units to reduce binary size KBUILD_LDFLAGS += -mllvm -import-instr-limit=5 + +# Check for frame size exceeding threshold during prolog/epilog insertion. +ifneq ($(CONFIG_FRAME_WARN),0) +KBUILD_LDFLAGS += -plugin-opt=-warn-stack-size=$(CONFIG_FRAME_WARN) +endif endif ifdef CONFIG_LTO