From patchwork Fri Feb 28 00:22:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 11411229 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4CE9113A4 for ; Fri, 28 Feb 2020 00:25:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 24E612469F for ; Fri, 28 Feb 2020 00:25:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="GKKBvg+O"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Kf+gX5xd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 24E612469F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8VK0Kt2CF1UbuFOAcVLMEOaV3Hdk1RUqHFxFCquCwco=; b=GKKBvg+OpcSh4i Lrz2oPT7YGVvjVNhWOYP34bJidmKGbmkYhfkI/60i/bMp15o02gb4QzQDydTy04lHfy8ByfIw+2Gy roJa6dQUPhlpfrgnNjerY3TR1C8S1DWdl3T6Gw3gjy3OXa1fziB6rgQeZM39CkT5VD5ScbyNNxZcS lAYurIxkTWcx9b9IXKBOuHqB9Vuix05zgbXgDrWgYIxpilneF8nM6cKxpkJ/mJTvrRIug5GzI4n2d dKPrMtkL+fjkFYyqlij7k0zQoJGjtgOFoZgD0d23j/38spH8V/rDdVw7eEVofc2wk4njr2V5C7VRa APfDjEb30875oZqR+sgw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j7TTE-0004cw-P3; Fri, 28 Feb 2020 00:25:37 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j7TQe-00014V-Gk for linux-arm-kernel@lists.infradead.org; Fri, 28 Feb 2020 00:22:58 +0000 Received: by mail-pg1-x543.google.com with SMTP id t3so556650pgn.1 for ; Thu, 27 Feb 2020 16:22:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A992AjdJWLXJEjwtDWIJFXaA8r8Mu1S3gNtRzAo3spo=; b=Kf+gX5xddQKiKpPCh8bEqjWUqToYjUe3/Z9DWP7hzU0kpjC0HzX02FDHpmOXXOwPyC RQr5vgHl1MrkXOGQjyy45mc7XGMezFVZ2pKsfS+w2wtn0sI0CA8B9URb5ueTsQrTkFPO zN9DFPXLMUeWvltrwG3QFCbnPtEHU7Jjtr6Jo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A992AjdJWLXJEjwtDWIJFXaA8r8Mu1S3gNtRzAo3spo=; b=kUr6DZiCpVd75MkBb4fMvWSAosyITEibOoNu30TaT7ZTnDcFNDnhI8zVOKdRakoftq lG4YMdeHHnxSBiOOPkOtkfhPKv767WyymCVxtKpcYV2hdn7X5xQXz+v5+PoNLN5pLzwc WlHSRBRu2VEFD0WmAoTHT8IVwsOSemCL12e8EqAHfkjgJHOPNpJLe1lmJBYcfSQWsj98 WrTu+TBNcOZFqHljmve3xAopFHRDtZfmUZ9VVuqveCc1r6JtlYV+DjtlgWsPF8+bWW7m +7V8c0EvbRZQLXvRftAbAgloh2ThIQQ4oR1W5FLxgSMFblaMySh4y+UBg5YgcBqXuLRP gXig== X-Gm-Message-State: APjAAAVJ7aBkAQqdXX37loYks3Mz+x2ywACWyE99vqLGY0VfKCXh78YR c/P83R8OL7/kmQiJA+iqG84NYg== X-Google-Smtp-Source: APXvYqxORpz2NBO4YgeiTAddpXfXe3J/AmESIDy/gZRMg/FCrltSGt039dZiZFkPpl/Q4pPd1+W1MA== X-Received: by 2002:a63:7207:: with SMTP id n7mr1872186pgc.253.1582849375359; Thu, 27 Feb 2020 16:22:55 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id b3sm8714061pft.73.2020.02.27.16.22.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 16:22:52 -0800 (PST) From: Kees Cook To: Borislav Petkov Subject: [PATCH 5/9] Add RUNTIME_DISCARD_EXIT to generic DISCARDS Date: Thu, 27 Feb 2020 16:22:40 -0800 Message-Id: <20200228002244.15240-6-keescook@chromium.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200228002244.15240-1-keescook@chromium.org> References: <20200228002244.15240-1-keescook@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200227_162256_682804_5CC60C29 X-CRM114-Status: GOOD ( 12.92 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:543 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "H.J. Lu" , Kees Cook , Arnd Bergmann , linux-kbuild@vger.kernel.org, Peter Collingbourne , Catalin Marinas , Masahiro Yamada , x86@kernel.org, Russell King , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, James Morse , linux-arch@vger.kernel.org, Will Deacon , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: "H.J. Lu" In x86 kernel, .exit.text and .exit.data sections are discarded at runtime, not by linker. Add RUNTIME_DISCARD_EXIT to generic DISCARDS and define it in x86 kernel linker script to keep them. Signed-off-by: H.J. Lu Link: https://lore.kernel.org/r/20200130224337.4150-1-hjl.tools@gmail.com Signed-off-by: Kees Cook --- arch/x86/kernel/vmlinux.lds.S | 1 + include/asm-generic/vmlinux.lds.h | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S index 1e345f302a46..1e12c097d09b 100644 --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S @@ -21,6 +21,7 @@ #define LOAD_OFFSET __START_KERNEL_map #endif +#define RUNTIME_DISCARD_EXIT #define EMITS_PT_NOTE #define RO_EXCEPTION_TABLE_ALIGN 16 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 303597e51396..1797f2c9bb41 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -894,10 +894,16 @@ * section definitions so that such archs put those in earlier section * definitions. */ +#ifdef RUNTIME_DISCARD_EXIT +#define EXIT_DISCARDS +#else +#define EXIT_DISCARDS \ + EXIT_TEXT \ + EXIT_DATA +#endif #define DISCARDS \ /DISCARD/ : { \ - EXIT_TEXT \ - EXIT_DATA \ + EXIT_DISCARDS \ EXIT_CALL \ *(.discard) \ *(.discard.*) \