Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp355373pxx; Mon, 26 Oct 2020 10:03:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzp3e3F9MoZBkrMaUj+u2ayIQBsVnq4lIGnrLl/Vtg+MO6FvTxbjbznURW0pH1/93r45EvS X-Received: by 2002:a17:906:1e04:: with SMTP id g4mr16448580ejj.72.1603731780024; Mon, 26 Oct 2020 10:03:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603731780; cv=none; d=google.com; s=arc-20160816; b=PYlZrmqRviNNxIaJ6bqbhSskEWaA0JviOu0ih4IE+Y7HfDOzoS23oZbAsCrVyg7oku q0jGgJCUOWNN3JdnZ4KRTDCTKE5F3oGKoZ8lezlHgHL/QMNEvzUtU1etQ4fVsAQMGTaF HMvgerJMwgAbiwSQbfZYhLc+qaumYbJz11geFlQE5k3knrbZX6ngTobFC8YU20IeVddA Z0lP5ie7YIoa/Yc43kdKU1bAZub5Wtlza3+zxga6QltiMVmNWYZKHO8a/lN38dqvegBr xCSJik7MhmTwQ+MUaeiOpXHOcVInfulvwT/c3i4gJlCZ3p6Dpspsbi/TbTHAnwnfHamc 78lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=fb9+gjwENfRPWJUTHHuvHRxj5wYQesZR3Xa4pqv6mps=; b=ndycNEuDN1mEQdbWseyLNsjhyFAuvhkpZdkPkGTXDDzRyO07DjZU4xL0wXPQ4IJWtK VNWjHC9ziO4M1FkBlHVUnm/hioDMeDzaKdMlhjg7icWN0jQ4j5IoyY/b4lHJ+AFLw8aR EmeSQFpp+B/UNPJXs1XHZXtad7J4rU6hyWQDWyRmV5lm5dIrZpxZSBaMDnfFZtC/Cwi3 4dv4VZOXjV87H1QfZ60VEg0z2dA1TH/5INgHrsv2tvy7l0gBZ08yL2fxqY5Hk6YGpDOc zl6WC0Yw8mglynJUKsE03/TQhBhBguMN5y+nRfMKv9oPgUHbnL8d31ZYAmWZZ5ZNXA2s UNYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=zc0oGSBY; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p16si7466043edy.362.2020.10.26.10.02.36; Mon, 26 Oct 2020 10:03:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=zc0oGSBY; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1775705AbgJZMwq (ORCPT + 99 others); Mon, 26 Oct 2020 08:52:46 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:39822 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1773153AbgJZMwj (ORCPT ); Mon, 26 Oct 2020 08:52:39 -0400 Date: Mon, 26 Oct 2020 12:52:35 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1603716756; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fb9+gjwENfRPWJUTHHuvHRxj5wYQesZR3Xa4pqv6mps=; b=zc0oGSBYswlF5B9zrfQYQwWzKVP1qGFxbXefLkza7Rw09d+eWB0NjZTMnoY8OaUUoLnhHP SmB3m+s+YcoZnWSnpQOr7mecwUXFYu5iuwQr+SsFGIgA7mkO9sIdp+rybHWjnIoL+YXa18 fQy2t4RSS5cY9B2/U9Gl9jq5ZNXRC/qH77VNxwVeD0ZY9HOYvCMUlrAbk2gnYs1554D+PF zHW/+RxT4GZ1NCmEzvheSLkn7Bs0W7KbUSpQwlvL9fc1Q6R131pD1Jc/5x1PS+FInX92xP ek+JKeU+uOkDYLmHDJYmBOzLiZId9MASshpLhtUSfWD1b+vlsa44pSNCRfE2pw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1603716756; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fb9+gjwENfRPWJUTHHuvHRxj5wYQesZR3Xa4pqv6mps=; b=IeQroH/OMF/0E+Wm8HTTvk9YBDGF3D+UJowvByV7otrOqLzIAdZHMJ6zR8N35hHDn0Wkya 38FK6FOojlH04uCw== From: "tip-bot2 for Gabriel Krisman Bertazi" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/cleanups] elf: Expose ELF header in compat_start_thread() Cc: Gabriel Krisman Bertazi , Thomas Gleixner , x86 , LKML In-Reply-To: <20201004032536.1229030-6-krisman@collabora.com> References: <20201004032536.1229030-6-krisman@collabora.com> MIME-Version: 1.0 Message-ID: <160371675542.397.5183477135451020077.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/cleanups branch of tip: Commit-ID: bc3d7bf61a9eaecccc84dc2ecc2a9a3fa4f5ec47 Gitweb: https://git.kernel.org/tip/bc3d7bf61a9eaecccc84dc2ecc2a9a3fa4f5ec47 Author: Gabriel Krisman Bertazi AuthorDate: Sat, 03 Oct 2020 23:25:31 -04:00 Committer: Thomas Gleixner CommitterDate: Mon, 26 Oct 2020 13:46:46 +01:00 elf: Expose ELF header in compat_start_thread() Like it is done for SET_PERSONALITY with x86, which requires the ELF header to select correct personality parameters, x86 requires the headers on compat_start_thread() to choose starting CS for ELF32 binaries, instead of relying on the going-away TIF_IA32/X32 flags. Add an indirection macro to ELF invocations of START_THREAD, that x86 can reimplement to receive the extra parameter just for ELF files. This requires no changes to other architectures who don't need the header information, they can continue to use the original start_thread for ELF and non-ELF binaries, and it prevents affecting non-ELF code paths for x86. Signed-off-by: Gabriel Krisman Bertazi Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20201004032536.1229030-6-krisman@collabora.com --- fs/binfmt_elf.c | 2 +- fs/compat_binfmt_elf.c | 9 +++++++-- include/linux/elf.h | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index b6b3d05..b23f755 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -1307,7 +1307,7 @@ out_free_interp: #endif finalize_exec(bprm); - start_thread(regs, elf_entry, bprm->p); + START_THREAD(elf_ex, regs, elf_entry, bprm->p); retval = 0; out: return retval; diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c index 2d24c76..12b9913 100644 --- a/fs/compat_binfmt_elf.c +++ b/fs/compat_binfmt_elf.c @@ -106,8 +106,13 @@ #endif #ifdef compat_start_thread -#undef start_thread -#define start_thread compat_start_thread +#define COMPAT_START_THREAD(ex, regs, new_ip, new_sp) \ + compat_start_thread(regs, new_ip, new_sp) +#endif + +#ifdef COMPAT_START_THREAD +#undef START_THREAD +#define START_THREAD COMPAT_START_THREAD #endif #ifdef compat_arch_setup_additional_pages diff --git a/include/linux/elf.h b/include/linux/elf.h index 5d5b032..6dbcfe7 100644 --- a/include/linux/elf.h +++ b/include/linux/elf.h @@ -22,6 +22,11 @@ SET_PERSONALITY(ex) #endif +#ifndef START_THREAD +#define START_THREAD(elf_ex, regs, elf_entry, start_stack) \ + start_thread(regs, elf_entry, start_stack) +#endif + #define ELF32_GNU_PROPERTY_ALIGN 4 #define ELF64_GNU_PROPERTY_ALIGN 8