From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kees Cook Subject: [PATCH v3 29/29] x86: Use INT3 instead of NOP for linker fill bytes Date: Tue, 29 Oct 2019 14:13:51 -0700 Message-ID: <20191029211351.13243-30-keescook@chromium.org> References: <20191029211351.13243-1-keescook@chromium.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=oiRcE1Mi4TeHZi5E8OLwj+ZJCIuFmdRvhtg8K+cMCDw=; b=ZB4B/Xuhgeaid3WTG8UlVvAYAg dAOCIRq/zE+n2M6wJPvh+iDc8+/L5txuj8ZGJpv0zgw/AK52U5njiBXWU3xwv2nO9iKt+ZgHJoRiZ OzdkE5a5ASE7yRCHayUhEyBDJrKlDaT7zEQL/ad7sJQUnV+Lyk1U+AE47HtWLQBXHi9fWuVR7OU4q VO408exlxx0kYTtsFkI6k8HGL5/x5pWy1PcLvcwPWldgZMxxOP6HTeJQE1t6ahKH+18O3xWESuert /F5yG6xAS35iWTtH7CK53SnOZxUx+Nl9SuVpONCFFLmjsrSJ6Z16NE48WLXa476u51cXEX9+zGdUs k6hgsqyw==; 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; bh=Wn91QvvOWXGcdAukdBFPOsAS+V9wjbJFfxE/dszqFsM=; b=e23Up0zA+FknG/wy6VhmeVSbZB8QZjiX0vsAsUiCjELXoASbot+u6O/Ejby5OAZXcC D20Gb77Tr51mlHzmSwSoKEoW2ET0UoL8WLxGdBgnuf4w6xJFYBJGnW///YPOFqwXtqCa uskFEoYIZvG0NYVP/lEJT6kwVN4SzBgoCgvaY= In-Reply-To: <20191029211351.13243-1-keescook@chromium.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: Borislav Petkov Cc: linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Michal Simek , linux-ia64@vger.kernel.org, Kees Cook , Arnd Bergmann , Michael Ellerman , Dave Hansen , Segher Boessenkool , linuxppc-dev@lists.ozlabs.org, Heiko Carstens , Yoshinori Sato , Andy Lutomirski , linux-alpha@vger.kernel.org, Rick Edgecombe , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org Instead of using 0x90 (NOP) to fill bytes between functions, which makes it easier to sloppily target functions in function pointer overwrite attacks, fill with 0xCC (INT3) to force a trap. Also drop the space between "=" and the value to better match the binutils documentation https://sourceware.org/binutils/docs/ld/Output-Section-Fill.html#Output-Section-Fill Example "objdump -d" before: ... ffffffff810001e0 : ffffffff810001e0: 48 8b 25 e1 b1 51 01 mov 0x151b1e1(%rip),%rsp # ffffffff8251b3c8 ffffffff810001e7: e9 d5 fe ff ff jmpq ffffffff810000c1 ffffffff810001ec: 90 nop ffffffff810001ed: 90 nop ffffffff810001ee: 90 nop ffffffff810001ef: 90 nop ffffffff810001f0 <__startup_64>: ... After: ... ffffffff810001e0 : ffffffff810001e0: 48 8b 25 41 79 53 01 mov 0x1537941(%rip),%rsp # ffffffff82537b28 ffffffff810001e7: e9 d5 fe ff ff jmpq ffffffff810000c1 ffffffff810001ec: cc int3 ffffffff810001ed: cc int3 ffffffff810001ee: cc int3 ffffffff810001ef: cc int3 ffffffff810001f0 <__startup_64>: ... Signed-off-by: Kees Cook --- arch/x86/kernel/vmlinux.lds.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S index b06d6e1188de..3a1a819da137 100644 --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S @@ -144,7 +144,7 @@ SECTIONS *(.text.__x86.indirect_thunk) __indirect_thunk_end = .; #endif - } :text = 0x9090 + } :text =0xcccc /* End of text section, which should occupy whole number of pages */ _etext = .; -- 2.17.1