From patchwork Fri Aug 21 19:43:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 11730401 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 8762E1731 for ; Fri, 21 Aug 2020 19:48:04 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 61A8220FC3 for ; Fri, 21 Aug 2020 19:48:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="p8COVmDO"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="m6myLEik"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="nMHBYCD9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 61A8220FC3 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=merlin.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=I6FgiJ7MdDyl+QGwc2sZlkKHD+YLhIQsnecr/jxVFT8=; b=p8COVmDOubQabbHAGSJuq/490 52YO8erMp+RbRLhaGiGzmYPynBtXsXzMfKjBP5R/x06MlHrcggxKeGwAK6RMOm1udFFV+KhDrUtva QfFptYPvbzJy9lcqPDqld3+FUgBo7PqmDd0DznSKkUOUlPWv66uPBXEUKu1d757rhs/6MD4eJ2wiQ GSG8ZI0x2B4zwmzM+t31YxMjHiIfy0rdJRqGku57XCsx8VHWZDCeJpVYXEdXxHx0oPbk5INyb/tMr 6eUojcl0xgutxBOCF7n1jqYPK0AjOhkHNkhOLY97haVTMmBQFgAyufXadGBBZvz0oDhO7YgCx6+/d gvJKthAOw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k9D0r-0008FJ-U8; Fri, 21 Aug 2020 19:47:46 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k9Cy2-0006g9-5a for linux-arm-kernel@merlin.infradead.org; Fri, 21 Aug 2020 19:44:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Bq/BqxHywJ//unZ/FFsOI/I3RLFn1Ht881hz0pa/nMs=; b=m6myLEikHD0+SNPITu9eBWVFrv szX1/zbHQkDSgO6uZftjTRNcu6GH7BF/WakhoimZahBFcnCBSvvjIYIobizln0SfdRkijqM/MUuLA 3Ep99y1mwxtaz7Nqmpp+Ky4dRhwwIdsbrr9IRlDOW7VmX/JwfnFsbFRwM3S9M58/kj892z4QOcUYh 0ejG5urfl07oa7mvk0kUx9z4cV/sh8M5hXgJeus9ZxosigrQRD1DeZuXCnvtH7RS1U0681IumohHz k39kZ7TQgRIdnGtTKdExwZcSp8X7IYhY+VgI+9G9le95J/n51wDKTdQ7WYGG5rjRRVBOqePnIMP13 9/4OKRBA==; Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k9Cxp-0005iB-1X for linux-arm-kernel@lists.infradead.org; Fri, 21 Aug 2020 19:44:48 +0000 Received: by mail-pf1-x441.google.com with SMTP id u128so1567601pfb.6 for ; Fri, 21 Aug 2020 12:44:36 -0700 (PDT) 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=Bq/BqxHywJ//unZ/FFsOI/I3RLFn1Ht881hz0pa/nMs=; b=nMHBYCD9syPtJ/9CNgyFfuEGCZA0qp6OIY3dAoZSUWHpHc+Q3Ev747cyfJWrxPqTaN 9e2MrjpkqhQ+CCitsRw/dNMuQKUwexmgZUVqIjnoSQr9FtrpZ8sf1wqr3WXSo/B/W8Fk h225U7BBpzt+8zMUaIT5V8sZTmMP3VxgJIx3o= 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=Bq/BqxHywJ//unZ/FFsOI/I3RLFn1Ht881hz0pa/nMs=; b=WWIegG/2ajnePAPvUc9w7reF3wyPGu4SjUT57J5rIYGUZiN4+WqADwxkE7zrSV17ac SwgF2l0ep+nIHn+F9Y4b6ISN/OchrFRqhlutcTkS+/cAGztS4UNTkG9nPhT31PI/K20s ljNRKGE45x2ZbVsS19etXOPJ0RNexeS0oVGsEoP4+d5hKVHoMFtOa5ngw9i8GMuBxP04 xkcDy2hcBJ/uWPzn9gcAcrENC2mD6viPgxpzbXldjAA6HzphWfWcQSjt6C7BXMMkCror CzoUgtj7qEDvZ0Xx8PJhYz/rTJFyMKC2SZktaX51C3uiYp/Im+XunJWwVp/QnS9m/0ir R63A== X-Gm-Message-State: AOAM5300RtkSeSInMvmuXQ61Nz5eGwK8dqky7tENj33huWOTC1bE7vkg XweuuHvpy36ZKJncVOklTVHs6A== X-Google-Smtp-Source: ABdhPJzLO9YcG4hPsntq7zaWUP4F+rgb2wZDPHFQhZoPhtEJ9GVket/dTKmqcPm1ABYBQRpoMUWFDw== X-Received: by 2002:a63:2324:: with SMTP id j36mr3471607pgj.221.1598039074103; Fri, 21 Aug 2020 12:44:34 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id 132sm3025142pgg.83.2020.08.21.12.44.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 12:44:32 -0700 (PDT) From: Kees Cook To: Ingo Molnar Subject: [PATCH v6 23/29] x86/build: Enforce an empty .got.plt section Date: Fri, 21 Aug 2020 12:43:04 -0700 Message-Id: <20200821194310.3089815-24-keescook@chromium.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821194310.3089815-1-keescook@chromium.org> References: <20200821194310.3089815-1-keescook@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200821_204437_212531_75EBFB0B X-CRM114-Status: GOOD ( 15.54 ) X-Spam-Score: -2.1 (--) X-Spam-Report: SpamAssassin version 3.4.4 on casper.infradead.org summary: Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:441 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -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 , linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, Kees Cook , Arnd Bergmann , Catalin Marinas , Masahiro Yamada , x86@kernel.org, Nick Desaulniers , Russell King , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Arvind Sankar , Ingo Molnar , James Morse , Nathan Chancellor , Borislav Petkov , Peter Collingbourne , Ard Biesheuvel , 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 The .got.plt section should always be zero (or filled only with the linker-generated lazy dispatch entry). Enforce this with an assert and mark the section as INFO. This is more sensitive than just blindly discarding the section. Signed-off-by: Kees Cook --- arch/x86/kernel/vmlinux.lds.S | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S index 0cc035cb15f1..4b1b936a6e7d 100644 --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S @@ -414,8 +414,20 @@ SECTIONS ELF_DETAILS DISCARDS -} + /* + * Make sure that the .got.plt is either completely empty or it + * contains only the lazy dispatch entries. + */ + .got.plt (INFO) : { *(.got.plt) } + ASSERT(SIZEOF(.got.plt) == 0 || +#ifdef CONFIG_X86_64 + SIZEOF(.got.plt) == 0x18, +#else + SIZEOF(.got.plt) == 0xc, +#endif + "Unexpected GOT/PLT entries detected!") +} #ifdef CONFIG_X86_32 /*