Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4489688imm; Fri, 18 May 2018 06:04:11 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoE6d61/FzmGAElD6377u1ynGX1hE0ahTK+7xG/yac03eNVGljf5cPnzt1PhdeZvj0Mw/Q5 X-Received: by 2002:a63:9302:: with SMTP id b2-v6mr7587455pge.263.1526648650974; Fri, 18 May 2018 06:04:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526648650; cv=none; d=google.com; s=arc-20160816; b=znb6aN8oHttpFCqrTSNxZGPBue4tsEm2nQpnWHGMCuLKS2kk1QVCf4GtpHl3g9mmGi Hln2YoU6gao91BE0H6gSuXfvzw4/8HpYd0lf6oaSRjTc/eHcEWB08IYBYGVX9e6aZZ4i XZ1oLNuuJQ3hYmkTVPAKtv6UbS0CM0TCrKkd0jYNMqGgU74xsOwtnGrRjTqdCNO9Qwth PFc4fq55BwBc9d78hVj6+tq/s7mMhgWc+TNrHFPy+ml5PwCcZ8IV0ZNOEmx2LXbsVijl oqb06+nWtsG1lVc8e1y2hkq8gq8bvCDHkwo8V87OOui9V+PkT/K5mtXYq51AvTHJ46zk QM2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=1c9MeieDYL/tF0ppP7iSeq9a5PC6aCtPT9Vx1gOEuAI=; b=hr5QFdQOzfzUICZbe2dmKFd7Q5lJ0o5zQKvjsNnEbNXrJmrMdfIDb0vzhskuVVlUeu O62+4QUjKkePv+WOyq/7uEualDCJeIEJakKQGrW2zUdFBswGbHRcKCnDOwWDxwk0WdK5 i4nAYWIXU+VcZUdbwF5TkH5GLHyi/RAIp+PN3sqy23kvslDTG9zp47AO8IgQJj/U4QZx P/iFyfyZTW2InxmaFvTZXEUluqYiz6enVXRCYPMw8JZ52BGZRhhHp/aa78YO32oMFen5 jVEJwGKXwpPR7DZvK8iyaM8LFXLBaey2KZmlz8mtHWWOvFn6qO9YDN1O0zCtEmEYjmNo 7olQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y34-v6si7490837plb.17.2018.05.18.06.03.34; Fri, 18 May 2018 06:04:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752628AbeERNCk (ORCPT + 99 others); Fri, 18 May 2018 09:02:40 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33200 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752498AbeERNC2 (ORCPT ); Fri, 18 May 2018 09:02:28 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6D132CB9DE; Fri, 18 May 2018 13:02:27 +0000 (UTC) Received: from treble (ovpn-120-21.rdu2.redhat.com [10.10.120.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 26CE61116701; Fri, 18 May 2018 13:02:26 +0000 (UTC) Date: Fri, 18 May 2018 08:02:24 -0500 From: Josh Poimboeuf To: Ingo Molnar Cc: Alexey Dobriyan , tglx@linutronix.de, Peter Anvin , kernel test robot , Andrew Lutomirski , Borislav Petkov , Brian Gerst , Denys Vlasenko , Peter Zijlstra , Linux Kernel Mailing List , Peter Anvin , tipbuild@zytor.com, LKP , torvalds@linux-foundation.org, x86@kernel.org Subject: Re: [PATCH v2] x86/asm: Pad assembly functions with INT3 instructions Message-ID: <20180518130224.4bmp6s6wnjucypml@treble> References: <20180515080033.GA7714@yexl-desktop> <20180515210757.GA12225@avx2> <20180515214337.GA18021@avx2> <20180515225028.GA21902@avx2> <20180515225845.GB21902@avx2> <20180518073644.GA8593@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180518073644.GA8593@gmail.com> User-Agent: NeoMutt/20180323 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 18 May 2018 13:02:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 18 May 2018 13:02:27 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jpoimboe@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 18, 2018 at 09:36:44AM +0200, Ingo Molnar wrote: > > * Alexey Dobriyan wrote: > > > Use INT3 instead of NOP. All that padding between functions is > > an illegal area, no legitimate code should jump into it. > > > > I've checked x86_64 allyesconfig disassembly, all changes looks sane: > > INT3 is only used after RET or unconditional JMP. > > > > On i386: > > * promote ret_from_exception into ENTRY as it has corresponding END, > > * demote "resume_userspace" -- unused, > > * delete ALIGN directive in page_fault. It is leftover from x86 assembly > > cleanups. > > > > commit d211af055d0c12dc3416c2886e6fbdc6eb74a381 > > i386: get rid of the use of KPROBE_ENTRY / KPROBE_END > > > > has ALIGN directive before branch target which makes sense. > > All the code after ALIGN disappeared later. > > > > Signed-off-by: Alexey Dobriyan > > --- > > > > arch/x86/entry/entry_32.S | 6 +----- > > arch/x86/include/asm/linkage.h | 2 +- > > 2 files changed, 2 insertions(+), 6 deletions(-) > > > > --- a/arch/x86/entry/entry_32.S > > +++ b/arch/x86/entry/entry_32.S > > @@ -320,8 +320,7 @@ END(ret_from_fork) > > */ > > > > # userspace resumption stub bypassing syscall exit tracing > > - ALIGN > > -ret_from_exception: > > +ENTRY(ret_from_exception) > > preempt_stop(CLBR_ANY) > > ret_from_intr: > > #ifdef CONFIG_VM86 > > @@ -337,8 +336,6 @@ ret_from_intr: > > #endif > > cmpl $USER_RPL, %eax > > jb resume_kernel # not returning to v8086 or userspace > > - > > -ENTRY(resume_userspace) > > DISABLE_INTERRUPTS(CLBR_ANY) > > TRACE_IRQS_OFF > > movl %esp, %eax > > @@ -910,7 +907,6 @@ BUILD_INTERRUPT3(hv_stimer0_callback_vector, HYPERV_STIMER0_VECTOR, > > ENTRY(page_fault) > > ASM_CLAC > > pushl $do_page_fault > > - ALIGN > > jmp common_exception > > END(page_fault) > > > > --- a/arch/x86/include/asm/linkage.h > > +++ b/arch/x86/include/asm/linkage.h > > @@ -18,7 +18,7 @@ > > name: > > > > #if defined(CONFIG_X86_64) || defined(CONFIG_X86_ALIGNMENT_16) > > -#define __ALIGN .p2align 4, 0x90 > > +#define __ALIGN .p2align 4, 0xCC > > #define __ALIGN_STR __stringify(__ALIGN) > > #endif > > So the question is, without objtool support, how will we find INT3-padding related > crash bugs on 32-bit kernels? Is the INT3 padding really worth it, even on x86-64? What problem are we trying to solve? I've seen cases with GCC functions falling through, but with asm code, falling through could just be working as designed. -- Josh