Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1218897imm; Tue, 15 May 2018 16:00:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpBjq8Gkd56kAHeRtn/UQeA8i0NX3aRVv27F3PVS0WW5tcCKhM4dg4Yrm6UgelEhTQ5xeKx X-Received: by 2002:a63:6a08:: with SMTP id f8-v6mr13882549pgc.363.1526425224092; Tue, 15 May 2018 16:00:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526425224; cv=none; d=google.com; s=arc-20160816; b=nyYatIu23q8TqIvt+C+NIuFcYGlo8PUSHOp2aZLIkKdkuB+4UAmJAfUY73Fs35c/eI EdZ5NE6R5BDd6rqrddSpwlk6vwmPyGkDIP6y2Zp2jUna1NLWdQFoY4Ld1xH+klzc4gLU ywJBeNfkGHCTxVYgVkloeAS+RD5is2K2vf6fQ6d+7jOZjm9yVxtMGiL0UA/Cuv4wAj5h sMsnnJhgnduTNmg6/aDWRa553A/wxdXdFFWWgJ6qHno00weuvzlI9MHWSJSB5QzEF2nI s/OCK1DgcNrvImYhlAlDgZ8su7lKKtG1Wsb/F95vX6+9cz8T+2XOgRGDJN2TAtJdZQQN bkFA== 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:dkim-signature:arc-authentication-results; bh=kCtd10A3+gwhLyg23q3LHbtIDkcPYwT/o5/VpQqqn3g=; b=LbUHOtRfXQnJprJ95QC9HUL5mXLShoP0VIeuiUbrYfBViuD4/PjeTm7+wHzUMfttMP 0Gb7/la5QUDR+y8bRUdOV78gveN7EzMD0mBsjxK2DiZ43SDfXcAGuMBhoH3jIbwNa9TU mXwkJ/QdQeXOKOh1QiRgat06DZ7YAgcbm6sHD5tYRVFyB+QbBfaq8on5mnnLHGwP7rc4 LzLg72xHeXtiqoIe2kH7myD5YWpFq/6CEO/8qyYEDkengkFPoGiP5ZOPrcRnpC9zPNmh 8uK82Mfcz4WGrzBhkOuOrzg5w1WA0/VHYMcZWDRaasoGEG/h6wudKReVAxE4NGK03BqC sUzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lzzlpgAs; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b4-v6si984597pla.345.2018.05.15.16.00.09; Tue, 15 May 2018 16:00:24 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lzzlpgAs; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752414AbeEOW6w (ORCPT + 99 others); Tue, 15 May 2018 18:58:52 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:37414 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751953AbeEOW6t (ORCPT ); Tue, 15 May 2018 18:58:49 -0400 Received: by mail-wr0-f196.google.com with SMTP id h5-v6so1778161wrm.4 for ; Tue, 15 May 2018 15:58:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=kCtd10A3+gwhLyg23q3LHbtIDkcPYwT/o5/VpQqqn3g=; b=lzzlpgAsp8O3IM0U/2K3EwbpXnmXNVVH5Fgdc7vv/mCAMq3dS7PeWO08/cspahvJ2v x/kbSYk1UMSXLJwMFJxCheRqSkQTbR2j+xHDZTT2naZFuiitlqIJ/D42h0Kny1X05BsR LS9JP4ugM8zK9wTqnoCqnsyF4qBy6jgs9+DmtNU7mrRPnskjzSsNVakW4arrHXbgUCCK zHYZk25WGFme2IR6wOdRH3ZK9s4NvoKb7EunXVpYIj75jeNg68X06fzq+8RBSIHG+txB mlCNO+Q1ZMttUHszugbgVFY+yi3Sguqxawz91+Xuvv7vq4gJVGVp8ZjgNpinMsvkJiOw HgZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=kCtd10A3+gwhLyg23q3LHbtIDkcPYwT/o5/VpQqqn3g=; b=Uhhipspr538p8rE0u5fZyhwK7OPpFmoBzbBYot9b0nx/Ra8rYWEBavtyORppRr5D99 F2Stf1IVy2ytXmIbeAiaUc+9hH/0E7qbS4yEWDiSjND56QxNHmCmCewyfL7097DH2dCp wYA2wll6TRRHQctIIqyd7Q6jop53C10n/bHTZI/Cj1BZXvjhxZWtKB6MA1ATRpUhFC9h 1rzxH4QiSsx/t8uesa1w3Ho0WQYKNyVIaxLevFv4ciVrUCA4FB8DDNe85+9N7tv2oHDw V6xY0QJj2n1jYY9YWKXegVXN9UdyVzVFyVbPw9Hb+Kw2iIN2uPskAj63z33qIDR5jII/ Oxnw== X-Gm-Message-State: ALKqPwfJZTaRGEQWMskmI0SZUk+u6ZUJtzxlP6tqertP7anpBi9uMlK4 fmTmUZ0cKP4TvNLXMQiTrA== X-Received: by 2002:adf:8f25:: with SMTP id p34-v6mr11477668wrb.193.1526425128257; Tue, 15 May 2018 15:58:48 -0700 (PDT) Received: from avx2 (nat4-minsk-pool-46-53-177-92.telecom.by. [46.53.177.92]) by smtp.gmail.com with ESMTPSA id m69-v6sm2224631wmd.47.2018.05.15.15.58.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 May 2018 15:58:47 -0700 (PDT) Date: Wed, 16 May 2018 01:58:45 +0300 From: Alexey Dobriyan To: mingo@kernel.org, tglx@linutronix.de Cc: Peter Anvin , kernel test robot , Andrew Lutomirski , Borislav Petkov , Brian Gerst , Denys Vlasenko , Josh Poimboeuf , Peter Zijlstra , Linux Kernel Mailing List , Peter Anvin , tipbuild@zytor.com, LKP , torvalds@linux-foundation.org, x86@kernel.org Subject: [PATCH v2] x86/asm: Pad assembly functions with INT3 instructions Message-ID: <20180515225845.GB21902@avx2> References: <20180515080033.GA7714@yexl-desktop> <20180515210757.GA12225@avx2> <20180515214337.GA18021@avx2> <20180515225028.GA21902@avx2> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180515225028.GA21902@avx2> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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