From patchwork Mon Jun 10 21:20:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10985475 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 96DFF14C0 for ; Mon, 10 Jun 2019 21:21:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8707D20182 for ; Mon, 10 Jun 2019 21:21:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B4ED28712; Mon, 10 Jun 2019 21:21:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SUSPICIOUS_RECIPS autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 132B520182 for ; Mon, 10 Jun 2019 21:21:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389571AbfFJVU0 (ORCPT ); Mon, 10 Jun 2019 17:20:26 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:36762 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388642AbfFJVU0 (ORCPT ); Mon, 10 Jun 2019 17:20:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=g0IwcQvIyqL3tsx078/NiWA7dtMhIrKr9WJTKTcAruU=; b=HKSjnXpXMEzG8SwWHqMqP4qXQe RyXxhHYvlSNqS5VwKqhBm7QCrPna0l8e2qZL2ZCqTG/1eX/OnFTA+aG0dTPHkwMkBSUnx1qTmwY0j b+6UgPWz07I1hlRWSzW3xdBDMF+aMPCTyrrD8YZe75vP/Z17CajosDFFOLK7DHo2eR0vGSZ2tpAbm 3RBlctUmWmZkCQ9VJJpZX5NDycqeWDlm0fvo+S9JNB/ZDxiBzdMN3dcw6AJ2QcwDfmKIw/hOz9+A9 CLXMzn2AgoiTr2WUYDEhV4G7w8lBIg7zqjTu33Kk+nGs90iKrnZV0D4RzLG//41m/G/2ywofcf9EX NODrvffg==; Received: from 089144193064.atnat0002.highway.a1.net ([89.144.193.64] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1haRiG-0000Jd-GY; Mon, 10 Jun 2019 21:20:20 +0000 From: Christoph Hellwig To: Greg Ungerer Cc: Michal Simek , linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, uclinux-h8-devel@lists.sourceforge.jp, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/15] binfmt_flat: remove flat_reloc_valid Date: Mon, 10 Jun 2019 23:20:01 +0200 Message-Id: <20190610212015.9157-2-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190610212015.9157-1-hch@lst.de> References: <20190610212015.9157-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This helper is the same for all architectures, open code it in the only caller. Signed-off-by: Christoph Hellwig Tested-by: Vladimir Murzin Reviewed-by: Vladimir Murzin --- arch/arm/include/asm/flat.h | 1 - arch/c6x/include/asm/flat.h | 1 - arch/h8300/include/asm/flat.h | 1 - arch/m68k/include/asm/flat.h | 1 - arch/microblaze/include/asm/flat.h | 1 - arch/sh/include/asm/flat.h | 1 - arch/xtensa/include/asm/flat.h | 1 - fs/binfmt_flat.c | 2 +- 8 files changed, 1 insertion(+), 8 deletions(-) diff --git a/arch/arm/include/asm/flat.h b/arch/arm/include/asm/flat.h index f0c75ddeea23..10cce9ecf151 100644 --- a/arch/arm/include/asm/flat.h +++ b/arch/arm/include/asm/flat.h @@ -10,7 +10,6 @@ #define flat_argvp_envp_on_stack() 1 #define flat_old_ram_flag(flags) (flags) -#define flat_reloc_valid(reloc, size) ((reloc) <= (size)) static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, u32 *addr, u32 *persistent) diff --git a/arch/c6x/include/asm/flat.h b/arch/c6x/include/asm/flat.h index 76fd0bb962a3..ecc6aea6606c 100644 --- a/arch/c6x/include/asm/flat.h +++ b/arch/c6x/include/asm/flat.h @@ -6,7 +6,6 @@ #define flat_argvp_envp_on_stack() 0 #define flat_old_ram_flag(flags) (flags) -#define flat_reloc_valid(reloc, size) ((reloc) <= (size)) static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, u32 *addr, u32 *persistent) { diff --git a/arch/h8300/include/asm/flat.h b/arch/h8300/include/asm/flat.h index f4cdfcbdd2ba..dcc7775115dd 100644 --- a/arch/h8300/include/asm/flat.h +++ b/arch/h8300/include/asm/flat.h @@ -10,7 +10,6 @@ #define flat_argvp_envp_on_stack() 1 #define flat_old_ram_flag(flags) 1 -#define flat_reloc_valid(reloc, size) ((reloc) <= (size)) #define flat_set_persistent(relval, p) 0 /* diff --git a/arch/m68k/include/asm/flat.h b/arch/m68k/include/asm/flat.h index 4f1d1e373420..a631caf5e18f 100644 --- a/arch/m68k/include/asm/flat.h +++ b/arch/m68k/include/asm/flat.h @@ -10,7 +10,6 @@ #define flat_argvp_envp_on_stack() 1 #define flat_old_ram_flag(flags) (flags) -#define flat_reloc_valid(reloc, size) ((reloc) <= (size)) static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, u32 *addr, u32 *persistent) { diff --git a/arch/microblaze/include/asm/flat.h b/arch/microblaze/include/asm/flat.h index 3d2747d4c967..34be5ed011be 100644 --- a/arch/microblaze/include/asm/flat.h +++ b/arch/microblaze/include/asm/flat.h @@ -15,7 +15,6 @@ #define flat_argvp_envp_on_stack() 0 #define flat_old_ram_flag(flags) (flags) -#define flat_reloc_valid(reloc, size) ((reloc) <= (size)) #define flat_set_persistent(relval, p) 0 /* diff --git a/arch/sh/include/asm/flat.h b/arch/sh/include/asm/flat.h index 843d458b8329..8f2929b32f2e 100644 --- a/arch/sh/include/asm/flat.h +++ b/arch/sh/include/asm/flat.h @@ -13,7 +13,6 @@ #define flat_argvp_envp_on_stack() 0 #define flat_old_ram_flag(flags) (flags) -#define flat_reloc_valid(reloc, size) ((reloc) <= (size)) static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, u32 *addr, u32 *persistent) { diff --git a/arch/xtensa/include/asm/flat.h b/arch/xtensa/include/asm/flat.h index b8532d7877b3..6ee5a35eb0ec 100644 --- a/arch/xtensa/include/asm/flat.h +++ b/arch/xtensa/include/asm/flat.h @@ -6,7 +6,6 @@ #define flat_argvp_envp_on_stack() 0 #define flat_old_ram_flag(flags) (flags) -#define flat_reloc_valid(reloc, size) ((reloc) <= (size)) static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, u32 *addr, u32 *persistent) { diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index 82a48e830018..afddea583999 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c @@ -345,7 +345,7 @@ calc_reloc(unsigned long r, struct lib_info *p, int curid, int internalp) start_code = p->lib_list[id].start_code; text_len = p->lib_list[id].text_len; - if (!flat_reloc_valid(r, start_brk - start_data + text_len)) { + if (r > start_brk - start_data + text_len) { pr_err("reloc outside program 0x%lx (0 - 0x%lx/0x%lx)", r, start_brk-start_data+text_len, text_len); goto failed; From patchwork Mon Jun 10 21:20:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10985437 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 768B276 for ; Mon, 10 Jun 2019 21:20:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66229283E7 for ; Mon, 10 Jun 2019 21:20:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59D412860C; Mon, 10 Jun 2019 21:20:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SUSPICIOUS_RECIPS autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B490D2843C for ; Mon, 10 Jun 2019 21:20:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389952AbfFJVU2 (ORCPT ); Mon, 10 Jun 2019 17:20:28 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:36886 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389891AbfFJVU1 (ORCPT ); Mon, 10 Jun 2019 17:20:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=9AIYqz1Pwx6TcvoVrCxVnK+ZGfRroyAflQcKomX0rXA=; b=Qx6pRf3yV9qSLFdbzDw1aPCHsP ibw02J10vXi5l6E98BcvwMtzXtinJyUGEev1nk/DrZgz8u/Gl/FDOMRuV+ffiZtk3WV7/XZoveJa4 0bDjayikXc6Xf+wC33Ikw6qqiXtLeNEj80YKV12cXT7mWc972sXFjYqsCJTLZLqyirRrA3KJkKLYn iORzN7edsQ3Wnx9/uxR+VghgDqQqGiYqMMv7xS+5R3nNPzr4Csf3+0uxewa5JdkhkFPA35vp1xYO4 Xwf/2BlCvruRyBrSdeuZumXZ4M8qMdWyfw0qm63/D3qfHxeZo/MW0/sLue8a7rCnWIgXIs583Blkq 9hPUcyDA==; Received: from 089144193064.atnat0002.highway.a1.net ([89.144.193.64] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1haRiI-0000KJ-Ub; Mon, 10 Jun 2019 21:20:23 +0000 From: Christoph Hellwig To: Greg Ungerer Cc: Michal Simek , linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, uclinux-h8-devel@lists.sourceforge.jp, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/15] binfmt_flat: remove flat_set_persistent Date: Mon, 10 Jun 2019 23:20:02 +0200 Message-Id: <20190610212015.9157-3-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190610212015.9157-1-hch@lst.de> References: <20190610212015.9157-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This helper is a no-op on all architectures, remove it. Signed-off-by: Christoph Hellwig Tested-by: Vladimir Murzin Reviewed-by: Vladimir Murzin --- arch/arm/include/asm/flat.h | 1 - arch/c6x/include/asm/flat.h | 1 - arch/h8300/include/asm/flat.h | 1 - arch/m68k/include/asm/flat.h | 5 ----- arch/microblaze/include/asm/flat.h | 1 - arch/sh/include/asm/flat.h | 1 - arch/xtensa/include/asm/flat.h | 1 - fs/binfmt_flat.c | 2 -- 8 files changed, 13 deletions(-) diff --git a/arch/arm/include/asm/flat.h b/arch/arm/include/asm/flat.h index 10cce9ecf151..576241d74704 100644 --- a/arch/arm/include/asm/flat.h +++ b/arch/arm/include/asm/flat.h @@ -31,6 +31,5 @@ static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel) } #define flat_get_relocate_addr(rel) (rel) -#define flat_set_persistent(relval, p) 0 #endif /* __ARM_FLAT_H__ */ diff --git a/arch/c6x/include/asm/flat.h b/arch/c6x/include/asm/flat.h index ecc6aea6606c..ac87368efad1 100644 --- a/arch/c6x/include/asm/flat.h +++ b/arch/c6x/include/asm/flat.h @@ -18,6 +18,5 @@ static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel) return 0; } #define flat_get_relocate_addr(rel) (rel) -#define flat_set_persistent(relval, p) 0 #endif /* __ASM_C6X_FLAT_H */ diff --git a/arch/h8300/include/asm/flat.h b/arch/h8300/include/asm/flat.h index dcc7775115dd..7ef7eefded3d 100644 --- a/arch/h8300/include/asm/flat.h +++ b/arch/h8300/include/asm/flat.h @@ -10,7 +10,6 @@ #define flat_argvp_envp_on_stack() 1 #define flat_old_ram_flag(flags) 1 -#define flat_set_persistent(relval, p) 0 /* * on the H8 a couple of the relocations have an instruction in the diff --git a/arch/m68k/include/asm/flat.h b/arch/m68k/include/asm/flat.h index a631caf5e18f..955617bb937b 100644 --- a/arch/m68k/include/asm/flat.h +++ b/arch/m68k/include/asm/flat.h @@ -30,11 +30,6 @@ static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel) } #define flat_get_relocate_addr(rel) (rel) -static inline int flat_set_persistent(u32 relval, u32 *persistent) -{ - return 0; -} - #define FLAT_PLAT_INIT(regs) \ do { \ if (current->mm) \ diff --git a/arch/microblaze/include/asm/flat.h b/arch/microblaze/include/asm/flat.h index 34be5ed011be..846084fa7f04 100644 --- a/arch/microblaze/include/asm/flat.h +++ b/arch/microblaze/include/asm/flat.h @@ -15,7 +15,6 @@ #define flat_argvp_envp_on_stack() 0 #define flat_old_ram_flag(flags) (flags) -#define flat_set_persistent(relval, p) 0 /* * Microblaze works a little differently from other arches, because diff --git a/arch/sh/include/asm/flat.h b/arch/sh/include/asm/flat.h index 8f2929b32f2e..6f3b18679a98 100644 --- a/arch/sh/include/asm/flat.h +++ b/arch/sh/include/asm/flat.h @@ -25,7 +25,6 @@ static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel) return 0; } #define flat_get_relocate_addr(rel) (rel) -#define flat_set_persistent(relval, p) ({ (void)p; 0; }) #define FLAT_PLAT_INIT(_r) \ do { _r->regs[0]=0; _r->regs[1]=0; _r->regs[2]=0; _r->regs[3]=0; \ diff --git a/arch/xtensa/include/asm/flat.h b/arch/xtensa/include/asm/flat.h index 6ee5a35eb0ec..b1bc0d9a8d4e 100644 --- a/arch/xtensa/include/asm/flat.h +++ b/arch/xtensa/include/asm/flat.h @@ -18,6 +18,5 @@ static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel) return 0; } #define flat_get_relocate_addr(rel) (rel) -#define flat_set_persistent(relval, p) 0 #endif /* __ASM_XTENSA_FLAT_H */ diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index afddea583999..a4c0b245ab1f 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c @@ -787,8 +787,6 @@ static int load_flat_file(struct linux_binprm *bprm, if (get_user(relval, reloc + i)) return -EFAULT; relval = ntohl(relval); - if (flat_set_persistent(relval, &persistent)) - continue; addr = flat_get_relocate_addr(relval); rp = (u32 __user *)calc_reloc(addr, libinfo, id, 1); if (rp == (u32 __user *)RELOC_FAILED) { From patchwork Mon Jun 10 21:20:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10985471 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 803E014DB for ; Mon, 10 Jun 2019 21:21:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7012720182 for ; Mon, 10 Jun 2019 21:21:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6439F28712; Mon, 10 Jun 2019 21:21:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SUSPICIOUS_RECIPS autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2C4E20182 for ; Mon, 10 Jun 2019 21:21:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390080AbfFJVUf (ORCPT ); Mon, 10 Jun 2019 17:20:35 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:37382 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389891AbfFJVUe (ORCPT ); Mon, 10 Jun 2019 17:20:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=gK/Yvf8faVmrh63U+btuZjl3JBVDnWKA1ZT84y942oU=; b=RHjJBaxBkB5IiWj3V3fPdq4m/K EjuJORZAFiVm6d4mdhDs4JLDsl6wUJO3nR5o4pJIgKrh+pJq3AEcq3NdqQuCpmBYhSpDDbtToqctZ iyByb/RPV0OPCQzpDK9f289ecsGhvalnq1DgVFv55KHwjvXQKe3leewYe3N2n5N2gd6/RMmnpt8cf S9a2af7b1zrQX9Zy2HZagfWdwZwkpkmBtLa8BtUe2jCIuT4qgfSCNTRRK+X4H1f9MEdzbrupeeHj4 rQ3ifXtcYCwiFaTj/Dkx3g/p+orYj0csWFJvUsitLlEFAw/fF6csL7BX6LIkkdqqEByJPP9zEjTvS wYEiTTnQ==; Received: from 089144193064.atnat0002.highway.a1.net ([89.144.193.64] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1haRiL-0000Me-FJ; Mon, 10 Jun 2019 21:20:25 +0000 From: Christoph Hellwig To: Greg Ungerer Cc: Michal Simek , linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, uclinux-h8-devel@lists.sourceforge.jp, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/15] binfmt_flat: provide a default version of flat_get_relocate_addr Date: Mon, 10 Jun 2019 23:20:03 +0200 Message-Id: <20190610212015.9157-4-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190610212015.9157-1-hch@lst.de> References: <20190610212015.9157-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This way only the two architectures that do masking need to provide the helper. Signed-off-by: Christoph Hellwig Tested-by: Vladimir Murzin Reviewed-by: Vladimir Murzin --- arch/arm/include/asm/flat.h | 2 -- arch/c6x/include/asm/flat.h | 1 - arch/m68k/include/asm/flat.h | 1 - arch/sh/include/asm/flat.h | 1 - arch/xtensa/include/asm/flat.h | 1 - fs/binfmt_flat.c | 4 ++++ 6 files changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/arm/include/asm/flat.h b/arch/arm/include/asm/flat.h index 576241d74704..a185fe023b60 100644 --- a/arch/arm/include/asm/flat.h +++ b/arch/arm/include/asm/flat.h @@ -30,6 +30,4 @@ static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel) #endif } -#define flat_get_relocate_addr(rel) (rel) - #endif /* __ARM_FLAT_H__ */ diff --git a/arch/c6x/include/asm/flat.h b/arch/c6x/include/asm/flat.h index ac87368efad1..c4d703b454c6 100644 --- a/arch/c6x/include/asm/flat.h +++ b/arch/c6x/include/asm/flat.h @@ -17,6 +17,5 @@ static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel) put_unaligned(addr, (__force u32 *)rp); return 0; } -#define flat_get_relocate_addr(rel) (rel) #endif /* __ASM_C6X_FLAT_H */ diff --git a/arch/m68k/include/asm/flat.h b/arch/m68k/include/asm/flat.h index 955617bb937b..217fa89c8e34 100644 --- a/arch/m68k/include/asm/flat.h +++ b/arch/m68k/include/asm/flat.h @@ -28,7 +28,6 @@ static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel) return put_user(addr, rp); #endif } -#define flat_get_relocate_addr(rel) (rel) #define FLAT_PLAT_INIT(regs) \ do { \ diff --git a/arch/sh/include/asm/flat.h b/arch/sh/include/asm/flat.h index 6f3b18679a98..0d520b4cc5ea 100644 --- a/arch/sh/include/asm/flat.h +++ b/arch/sh/include/asm/flat.h @@ -24,7 +24,6 @@ static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel) put_unaligned(addr, (__force u32 *)rp); return 0; } -#define flat_get_relocate_addr(rel) (rel) #define FLAT_PLAT_INIT(_r) \ do { _r->regs[0]=0; _r->regs[1]=0; _r->regs[2]=0; _r->regs[3]=0; \ diff --git a/arch/xtensa/include/asm/flat.h b/arch/xtensa/include/asm/flat.h index b1bc0d9a8d4e..a1d88aa3ef8a 100644 --- a/arch/xtensa/include/asm/flat.h +++ b/arch/xtensa/include/asm/flat.h @@ -17,6 +17,5 @@ static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel) put_unaligned(addr, (__force u32 *)rp); return 0; } -#define flat_get_relocate_addr(rel) (rel) #endif /* __ASM_XTENSA_FLAT_H */ diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index a4c0b245ab1f..c0e4535dc1ec 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c @@ -43,6 +43,10 @@ #include #include +#ifndef flat_get_relocate_addr +#define flat_get_relocate_addr(rel) (rel) +#endif + /****************************************************************************/ /* From patchwork Mon Jun 10 21:20:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10985467 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2427714C0 for ; Mon, 10 Jun 2019 21:21:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1404220182 for ; Mon, 10 Jun 2019 21:21:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0752628716; Mon, 10 Jun 2019 21:21:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SUSPICIOUS_RECIPS autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 714A920182 for ; Mon, 10 Jun 2019 21:21:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389891AbfFJVUg (ORCPT ); Mon, 10 Jun 2019 17:20:36 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:37444 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390074AbfFJVUf (ORCPT ); Mon, 10 Jun 2019 17:20:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=jzhuFJyutEd4Klc1zDqg9CjjQcxV5ZLJVdTWaw679qk=; b=UNNZsNuY3vULON92hzCaU4vaxl ApjJ1BxYHasQ+8Z/Nof9zTZuRn70w7RiE+8a1+2hM6DGe/YolLpC25qG8PQx57rCWEVtEWxEpLp8Z 61J2c0DEZL1uAmvI8PJFeuR9io4VLTCzMqmulf6J8dWs5BZ50BPreLSz7P8udVdPdQWc0g4nSta20 qZ/4J/1LAJYxNyt/El+JnIJRzIOFI5It2uDxanozjtKDtM7eFhWq36ezNMmDMfmYOROZWC1sLC4wn hftHpzyU/Dkr9MBnnG1iGhFATjfqa1gM9ycyOt589wjAMcCB6UGU1m/dXs39nWr5/P5w1xmGZUDaf DeKuNkGg==; Received: from 089144193064.atnat0002.highway.a1.net ([89.144.193.64] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1haRiO-0000PP-Co; Mon, 10 Jun 2019 21:20:29 +0000 From: Christoph Hellwig To: Greg Ungerer Cc: Michal Simek , linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, uclinux-h8-devel@lists.sourceforge.jp, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/15] binfmt_flat: remove flat_old_ram_flag Date: Mon, 10 Jun 2019 23:20:04 +0200 Message-Id: <20190610212015.9157-5-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190610212015.9157-1-hch@lst.de> References: <20190610212015.9157-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead add a Kconfig variable that only h8300 selects. Signed-off-by: Christoph Hellwig Tested-by: Vladimir Murzin Reviewed-by: Vladimir Murzin --- arch/arm/include/asm/flat.h | 1 - arch/c6x/include/asm/flat.h | 1 - arch/h8300/Kconfig | 1 + arch/h8300/include/asm/flat.h | 1 - arch/m68k/include/asm/flat.h | 1 - arch/microblaze/include/asm/flat.h | 1 - arch/sh/include/asm/flat.h | 1 - arch/xtensa/include/asm/flat.h | 1 - fs/Kconfig.binfmt | 3 +++ fs/binfmt_flat.c | 3 ++- 10 files changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/arm/include/asm/flat.h b/arch/arm/include/asm/flat.h index a185fe023b60..acf162111ee2 100644 --- a/arch/arm/include/asm/flat.h +++ b/arch/arm/include/asm/flat.h @@ -9,7 +9,6 @@ #include #define flat_argvp_envp_on_stack() 1 -#define flat_old_ram_flag(flags) (flags) static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, u32 *addr, u32 *persistent) diff --git a/arch/c6x/include/asm/flat.h b/arch/c6x/include/asm/flat.h index c4d703b454c6..353e4d06e8c0 100644 --- a/arch/c6x/include/asm/flat.h +++ b/arch/c6x/include/asm/flat.h @@ -5,7 +5,6 @@ #include #define flat_argvp_envp_on_stack() 0 -#define flat_old_ram_flag(flags) (flags) static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, u32 *addr, u32 *persistent) { diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig index ecfc4b4b6373..d30e8727b02d 100644 --- a/arch/h8300/Kconfig +++ b/arch/h8300/Kconfig @@ -2,6 +2,7 @@ config H8300 def_bool y select ARCH_32BIT_OFF_T + select BINFMT_FLAT_OLD_ALWAYS_RAM select GENERIC_ATOMIC64 select HAVE_UID16 select VIRT_TO_BUS diff --git a/arch/h8300/include/asm/flat.h b/arch/h8300/include/asm/flat.h index 7ef7eefded3d..14cc928d5478 100644 --- a/arch/h8300/include/asm/flat.h +++ b/arch/h8300/include/asm/flat.h @@ -9,7 +9,6 @@ #include #define flat_argvp_envp_on_stack() 1 -#define flat_old_ram_flag(flags) 1 /* * on the H8 a couple of the relocations have an instruction in the diff --git a/arch/m68k/include/asm/flat.h b/arch/m68k/include/asm/flat.h index 217fa89c8e34..7b1fb5c2809e 100644 --- a/arch/m68k/include/asm/flat.h +++ b/arch/m68k/include/asm/flat.h @@ -9,7 +9,6 @@ #include #define flat_argvp_envp_on_stack() 1 -#define flat_old_ram_flag(flags) (flags) static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, u32 *addr, u32 *persistent) { diff --git a/arch/microblaze/include/asm/flat.h b/arch/microblaze/include/asm/flat.h index 846084fa7f04..1cd8d7f4cf12 100644 --- a/arch/microblaze/include/asm/flat.h +++ b/arch/microblaze/include/asm/flat.h @@ -14,7 +14,6 @@ #include #define flat_argvp_envp_on_stack() 0 -#define flat_old_ram_flag(flags) (flags) /* * Microblaze works a little differently from other arches, because diff --git a/arch/sh/include/asm/flat.h b/arch/sh/include/asm/flat.h index 0d520b4cc5ea..015678d7b771 100644 --- a/arch/sh/include/asm/flat.h +++ b/arch/sh/include/asm/flat.h @@ -12,7 +12,6 @@ #include #define flat_argvp_envp_on_stack() 0 -#define flat_old_ram_flag(flags) (flags) static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, u32 *addr, u32 *persistent) { diff --git a/arch/xtensa/include/asm/flat.h b/arch/xtensa/include/asm/flat.h index a1d88aa3ef8a..b215c1e66958 100644 --- a/arch/xtensa/include/asm/flat.h +++ b/arch/xtensa/include/asm/flat.h @@ -5,7 +5,6 @@ #include #define flat_argvp_envp_on_stack() 0 -#define flat_old_ram_flag(flags) (flags) static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, u32 *addr, u32 *persistent) { diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt index f87ddd1b6d72..5658e12ad944 100644 --- a/fs/Kconfig.binfmt +++ b/fs/Kconfig.binfmt @@ -97,6 +97,9 @@ config BINFMT_FLAT help Support uClinux FLAT format binaries. +config BINFMT_FLAT_OLD_ALWAYS_RAM + bool + config BINFMT_ZFLAT bool "Enable ZFLAT support" depends on BINFMT_FLAT diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index c0e4535dc1ec..18d82fd5f57c 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c @@ -488,7 +488,8 @@ static int load_flat_file(struct linux_binprm *bprm, * fix up the flags for the older format, there were all kinds * of endian hacks, this only works for the simple cases */ - if (rev == OLD_FLAT_VERSION && flat_old_ram_flag(flags)) + if (IS_ENABLED(CONFIG_BINFMT_FLAT_OLD_ALWAYS_RAM) && + rev == OLD_FLAT_VERSION) flags = FLAT_FLAG_RAM; #ifndef CONFIG_BINFMT_ZFLAT From patchwork Mon Jun 10 21:20:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10985439 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 297DC76 for ; Mon, 10 Jun 2019 21:20:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19EE920182 for ; Mon, 10 Jun 2019 21:20:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E73E2843C; Mon, 10 Jun 2019 21:20:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SUSPICIOUS_RECIPS autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7039A20182 for ; Mon, 10 Jun 2019 21:20:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390129AbfFJVUj (ORCPT ); Mon, 10 Jun 2019 17:20:39 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:37654 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390074AbfFJVUi (ORCPT ); Mon, 10 Jun 2019 17:20:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=DbUlZjM3WkHKSRgWQVbEnv+zhYk/WrrKQ76XLW7eA94=; b=gLq0KCN0tsx25jqwSpHSOHvXbk iIgIv3sKIis+PnGq8PDoXI9A6HDS/afT5feMl3R2b117Nd5ZHEnfqBcAOINuBjTS8n9BEB6c7szzi lg8KUdPfxV58oCtBAQJlWIGXWEtMhfj3QYM+vhtoJAguDnByJxgKZdKc85uBjSYJ3Zjs84RhzLpW/ CsNqSmsy1cDoWNvFsusTE5LMkzieC+Kg2eCmD0cCiRL8xQLwmU2wfAzUnH0ZoHVl3Wsfc4r8exfiD MWXZpg1D+4sRmKikBFPnwxE6sEll2nJaDHdWLlyXLzfJlUly9EvgR8Tp2rKN29x1NexEjahgmt+HC SDX3QkKg==; Received: from 089144193064.atnat0002.highway.a1.net ([89.144.193.64] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1haRiR-0000SJ-AZ; Mon, 10 Jun 2019 21:20:31 +0000 From: Christoph Hellwig To: Greg Ungerer Cc: Michal Simek , linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, uclinux-h8-devel@lists.sourceforge.jp, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/15] binfmt_flat: replace flat_argvp_envp_on_stack with a Kconfig variable Date: Mon, 10 Jun 2019 23:20:05 +0200 Message-Id: <20190610212015.9157-6-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190610212015.9157-1-hch@lst.de> References: <20190610212015.9157-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This will eventually allow us to kill the need for an for many cases. Signed-off-by: Christoph Hellwig Tested-by: Vladimir Murzin Reviewed-by: Vladimir Murzin --- arch/arm/Kconfig | 1 + arch/arm/include/asm/flat.h | 2 -- arch/c6x/include/asm/flat.h | 1 - arch/h8300/Kconfig | 1 + arch/h8300/include/asm/flat.h | 2 -- arch/m68k/Kconfig | 1 + arch/m68k/include/asm/flat.h | 1 - arch/microblaze/include/asm/flat.h | 2 -- arch/sh/include/asm/flat.h | 1 - arch/xtensa/include/asm/flat.h | 1 - fs/Kconfig.binfmt | 3 +++ fs/binfmt_flat.c | 5 +++-- 12 files changed, 9 insertions(+), 12 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 8869742a85df..b1b48c0bde76 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -30,6 +30,7 @@ config ARM select ARCH_USE_BUILTIN_BSWAP select ARCH_USE_CMPXCHG_LOCKREF select ARCH_WANT_IPC_PARSE_VERSION + select BINFMT_FLAT_ARGVP_ENVP_ON_STACK select BUILDTIME_EXTABLE_SORT if MMU select CLONE_BACKWARDS select CPU_PM if SUSPEND || CPU_IDLE diff --git a/arch/arm/include/asm/flat.h b/arch/arm/include/asm/flat.h index acf162111ee2..bbc27901446f 100644 --- a/arch/arm/include/asm/flat.h +++ b/arch/arm/include/asm/flat.h @@ -8,8 +8,6 @@ #include -#define flat_argvp_envp_on_stack() 1 - static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, u32 *addr, u32 *persistent) { diff --git a/arch/c6x/include/asm/flat.h b/arch/c6x/include/asm/flat.h index 353e4d06e8c0..2d57a9204d21 100644 --- a/arch/c6x/include/asm/flat.h +++ b/arch/c6x/include/asm/flat.h @@ -4,7 +4,6 @@ #include -#define flat_argvp_envp_on_stack() 0 static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, u32 *addr, u32 *persistent) { diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig index d30e8727b02d..7457f190caaa 100644 --- a/arch/h8300/Kconfig +++ b/arch/h8300/Kconfig @@ -2,6 +2,7 @@ config H8300 def_bool y select ARCH_32BIT_OFF_T + select BINFMT_FLAT_ARGVP_ENVP_ON_STACK select BINFMT_FLAT_OLD_ALWAYS_RAM select GENERIC_ATOMIC64 select HAVE_UID16 diff --git a/arch/h8300/include/asm/flat.h b/arch/h8300/include/asm/flat.h index 14cc928d5478..4683146f0e9e 100644 --- a/arch/h8300/include/asm/flat.h +++ b/arch/h8300/include/asm/flat.h @@ -8,8 +8,6 @@ #include -#define flat_argvp_envp_on_stack() 1 - /* * on the H8 a couple of the relocations have an instruction in the * top byte. As there can only be 24bits of address space, we just diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index 218e037ef901..fd69ee5ad6ab 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -7,6 +7,7 @@ config M68K select ARCH_MIGHT_HAVE_PC_PARPORT if ISA select ARCH_NO_COHERENT_DMA_MMAP if !MMU select ARCH_NO_PREEMPT if !COLDFIRE + select BINFMT_FLAT_ARGVP_ENVP_ON_STACK select HAVE_IDE select HAVE_AOUT if MMU select HAVE_DEBUG_BUGVERBOSE diff --git a/arch/m68k/include/asm/flat.h b/arch/m68k/include/asm/flat.h index 7b1fb5c2809e..d7102fcd43eb 100644 --- a/arch/m68k/include/asm/flat.h +++ b/arch/m68k/include/asm/flat.h @@ -8,7 +8,6 @@ #include -#define flat_argvp_envp_on_stack() 1 static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, u32 *addr, u32 *persistent) { diff --git a/arch/microblaze/include/asm/flat.h b/arch/microblaze/include/asm/flat.h index 1cd8d7f4cf12..9e3d8e01d294 100644 --- a/arch/microblaze/include/asm/flat.h +++ b/arch/microblaze/include/asm/flat.h @@ -13,8 +13,6 @@ #include -#define flat_argvp_envp_on_stack() 0 - /* * Microblaze works a little differently from other arches, because * of the MICROBLAZE_64 reloc type. Here, a 32 bit address is split diff --git a/arch/sh/include/asm/flat.h b/arch/sh/include/asm/flat.h index 015678d7b771..1002343dd84a 100644 --- a/arch/sh/include/asm/flat.h +++ b/arch/sh/include/asm/flat.h @@ -11,7 +11,6 @@ #include -#define flat_argvp_envp_on_stack() 0 static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, u32 *addr, u32 *persistent) { diff --git a/arch/xtensa/include/asm/flat.h b/arch/xtensa/include/asm/flat.h index b215c1e66958..3d357371b28b 100644 --- a/arch/xtensa/include/asm/flat.h +++ b/arch/xtensa/include/asm/flat.h @@ -4,7 +4,6 @@ #include -#define flat_argvp_envp_on_stack() 0 static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, u32 *addr, u32 *persistent) { diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt index 5658e12ad944..82f7d7f234f3 100644 --- a/fs/Kconfig.binfmt +++ b/fs/Kconfig.binfmt @@ -97,6 +97,9 @@ config BINFMT_FLAT help Support uClinux FLAT format binaries. +config BINFMT_FLAT_ARGVP_ENVP_ON_STACK + bool + config BINFMT_FLAT_OLD_ALWAYS_RAM bool diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index 18d82fd5f57c..c09651087eda 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c @@ -124,14 +124,15 @@ static int create_flat_tables(struct linux_binprm *bprm, unsigned long arg_start sp -= bprm->envc + 1; sp -= bprm->argc + 1; - sp -= flat_argvp_envp_on_stack() ? 2 : 0; + if (IS_ENABLED(CONFIG_BINFMT_FLAT_ARGVP_ENVP_ON_STACK)) + sp -= 2; /* argvp + envp */ sp -= 1; /* &argc */ current->mm->start_stack = (unsigned long)sp & -FLAT_STACK_ALIGN; sp = (unsigned long __user *)current->mm->start_stack; __put_user(bprm->argc, sp++); - if (flat_argvp_envp_on_stack()) { + if (IS_ENABLED(CONFIG_BINFMT_FLAT_ARGVP_ENVP_ON_STACK)) { unsigned long argv, envp; argv = (unsigned long)(sp + 2); envp = (unsigned long)(sp + 2 + bprm->argc + 1); From patchwork Mon Jun 10 21:20:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10985441 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F4F114BB for ; Mon, 10 Jun 2019 21:20:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E0B827F85 for ; Mon, 10 Jun 2019 21:20:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41E96283E7; Mon, 10 Jun 2019 21:20:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SUSPICIOUS_RECIPS autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AA342835B for ; Mon, 10 Jun 2019 21:20:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390136AbfFJVUk (ORCPT ); Mon, 10 Jun 2019 17:20:40 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:37672 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390127AbfFJVUj (ORCPT ); Mon, 10 Jun 2019 17:20:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=OLqEwqcQdKiJLl2M9TmN5lTWvVtrhUb8Z35dqhzeL58=; b=bbZzfdlGlG93uqA9gUEJtstdXl AK8eyCmHJ7h+V8dBqWTibKBrSs6QSluOGj7gjlzLvnTuifrO/Sdz8/PtIu8O+TYwCyNm5XdBhiQb1 uTx7tI+RhQ1eowr5eNrmZ3Sn1tpFJ5Raog9Lt8locEHkslQ54Mdp4MIp5wYs5Yw8sXnhzICxnZie0 KUwt4gqSYV57mxIB7GfQYYNtfA+uG7YO8AKIIjET8RfAA7ICz2FismWdP3PQGFsv3Vt0RlS9SOjcn mOB8UkVbFz+FkUX9/oPfZUvHfQ90Uysr30jg5ONDQbZ2SeCyNI5ZElaTapuM+Oz+iHyAYCB8MtfrW xmnIYofw==; Received: from 089144193064.atnat0002.highway.a1.net ([89.144.193.64] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1haRiU-0000Ur-3A; Mon, 10 Jun 2019 21:20:34 +0000 From: Christoph Hellwig To: Greg Ungerer Cc: Michal Simek , linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, uclinux-h8-devel@lists.sourceforge.jp, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/15] binfmt_flat: remove the uapi header Date: Mon, 10 Jun 2019 23:20:06 +0200 Message-Id: <20190610212015.9157-7-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190610212015.9157-1-hch@lst.de> References: <20190610212015.9157-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The split between the two flat.h files is completely arbitrary, and the uapi version even contains CONFIG_ ifdefs that can't work in userspace. The only userspace program known to use the header is elf2flt, and it ships with its own version of the combined header. Use the chance to move the inclusion out of this file, as it is in no way needed for the format defintion, but just for the binfmt implementation. Signed-off-by: Christoph Hellwig Reviewed-by: Vladimir Murzin --- fs/binfmt_flat.c | 1 + include/linux/flat.h | 45 ++++++++++++++++++++++++++--- include/uapi/linux/flat.h | 59 --------------------------------------- 3 files changed, 42 insertions(+), 63 deletions(-) delete mode 100644 include/uapi/linux/flat.h diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index c09651087eda..6ae0f9af3fc9 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c @@ -42,6 +42,7 @@ #include #include #include +#include #ifndef flat_get_relocate_addr #define flat_get_relocate_addr(rel) (rel) diff --git a/include/linux/flat.h b/include/linux/flat.h index 569b67d64d5c..21d901ba191b 100644 --- a/include/linux/flat.h +++ b/include/linux/flat.h @@ -10,8 +10,47 @@ #ifndef _LINUX_FLAT_H #define _LINUX_FLAT_H -#include -#include +#define FLAT_VERSION 0x00000004L + +#ifdef CONFIG_BINFMT_SHARED_FLAT +#define MAX_SHARED_LIBS (4) +#else +#define MAX_SHARED_LIBS (1) +#endif + +/* + * To make everything easier to port and manage cross platform + * development, all fields are in network byte order. + */ + +struct flat_hdr { + char magic[4]; + unsigned long rev; /* version (as above) */ + unsigned long entry; /* Offset of first executable instruction + with text segment from beginning of file */ + unsigned long data_start; /* Offset of data segment from beginning of + file */ + unsigned long data_end; /* Offset of end of data segment + from beginning of file */ + unsigned long bss_end; /* Offset of end of bss segment from beginning + of file */ + + /* (It is assumed that data_end through bss_end forms the bss segment.) */ + + unsigned long stack_size; /* Size of stack, in bytes */ + unsigned long reloc_start; /* Offset of relocation records from + beginning of file */ + unsigned long reloc_count; /* Number of relocation records */ + unsigned long flags; + unsigned long build_date; /* When the program/library was built */ + unsigned long filler[5]; /* Reservered, set to zero */ +}; + +#define FLAT_FLAG_RAM 0x0001 /* load program entirely into RAM */ +#define FLAT_FLAG_GOTPIC 0x0002 /* program is PIC with GOT */ +#define FLAT_FLAG_GZIP 0x0004 /* all but the header is compressed */ +#define FLAT_FLAG_GZDATA 0x0008 /* only data/relocs are compressed (for XIP) */ +#define FLAT_FLAG_KTRACE 0x0010 /* output useful kernel trace for debugging */ /* * While it would be nice to keep this header clean, users of older @@ -22,8 +61,6 @@ * with the format above, except to fix bugs with old format support. */ -#include - #define OLD_FLAT_VERSION 0x00000002L #define OLD_FLAT_RELOC_TYPE_TEXT 0 #define OLD_FLAT_RELOC_TYPE_DATA 1 diff --git a/include/uapi/linux/flat.h b/include/uapi/linux/flat.h deleted file mode 100644 index 27e595e44fb7..000000000000 --- a/include/uapi/linux/flat.h +++ /dev/null @@ -1,59 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -/* - * Copyright (C) 2002-2003 David McCullough - * Copyright (C) 1998 Kenneth Albanowski - * The Silver Hammer Group, Ltd. - * - * This file provides the definitions and structures needed to - * support uClinux flat-format executables. - */ - -#ifndef _UAPI_LINUX_FLAT_H -#define _UAPI_LINUX_FLAT_H - - -#define FLAT_VERSION 0x00000004L - -#ifdef CONFIG_BINFMT_SHARED_FLAT -#define MAX_SHARED_LIBS (4) -#else -#define MAX_SHARED_LIBS (1) -#endif - -/* - * To make everything easier to port and manage cross platform - * development, all fields are in network byte order. - */ - -struct flat_hdr { - char magic[4]; - unsigned long rev; /* version (as above) */ - unsigned long entry; /* Offset of first executable instruction - with text segment from beginning of file */ - unsigned long data_start; /* Offset of data segment from beginning of - file */ - unsigned long data_end; /* Offset of end of data segment - from beginning of file */ - unsigned long bss_end; /* Offset of end of bss segment from beginning - of file */ - - /* (It is assumed that data_end through bss_end forms the bss segment.) */ - - unsigned long stack_size; /* Size of stack, in bytes */ - unsigned long reloc_start; /* Offset of relocation records from - beginning of file */ - unsigned long reloc_count; /* Number of relocation records */ - unsigned long flags; - unsigned long build_date; /* When the program/library was built */ - unsigned long filler[5]; /* Reservered, set to zero */ -}; - -#define FLAT_FLAG_RAM 0x0001 /* load program entirely into RAM */ -#define FLAT_FLAG_GOTPIC 0x0002 /* program is PIC with GOT */ -#define FLAT_FLAG_GZIP 0x0004 /* all but the header is compressed */ -#define FLAT_FLAG_GZDATA 0x0008 /* only data/relocs are compressed (for XIP) */ -#define FLAT_FLAG_KTRACE 0x0010 /* output useful kernel trace for debugging */ - - - -#endif /* _UAPI_LINUX_FLAT_H */ From patchwork Mon Jun 10 21:20:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10985443 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0A66614BB for ; Mon, 10 Jun 2019 21:20:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF51B20182 for ; Mon, 10 Jun 2019 21:20:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E39852835B; Mon, 10 Jun 2019 21:20:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SUSPICIOUS_RECIPS autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 751C220182 for ; Mon, 10 Jun 2019 21:20:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390174AbfFJVUm (ORCPT ); Mon, 10 Jun 2019 17:20:42 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:37866 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390157AbfFJVUl (ORCPT ); Mon, 10 Jun 2019 17:20:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=HU6kHTNFa+R10seSyyeXaLI/u/CE3GjB+DCIYQwe6ww=; b=JqZQbuDCovZhJ4IBx1qsE+p2ND 3TvQWbUKInHoY+mqZdgwEG8GKanRtU1iJfnl+w0hzvtJS1pQmXPUIJq/2dxgfAlAaTzrtURsr54JW 021XQkikQMjm45CWhrxBAVt8eUNmsovcrAYCS2XEXCB9Cz8vRsufCTlP984e1Xye70+opSXQ3frBL sxAqar8ACYKvI2xR6IFt0i2ka5O1Y8VGlgZzwuoJjVQCulkCN/iLE6Y6MVFt6O3BCwpOlqB61mCh3 5rqpWGvfa3+XVZ9Ri2svg3pSfVWXfsFWUTVxL6eBgPk+NTEMr1fTcx1NteHX3EjihFOkhWY63PJKT Bj5HQK7A==; Received: from 089144193064.atnat0002.highway.a1.net ([89.144.193.64] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1haRiW-0000XW-Qp; Mon, 10 Jun 2019 21:20:37 +0000 From: Christoph Hellwig To: Greg Ungerer Cc: Michal Simek , linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, uclinux-h8-devel@lists.sourceforge.jp, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/15] binfmt_flat: use __be32 for the on-disk format Date: Mon, 10 Jun 2019 23:20:07 +0200 Message-Id: <20190610212015.9157-8-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190610212015.9157-1-hch@lst.de> References: <20190610212015.9157-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP So far binfmt_flat has onl been supported on 32-bit platforms, so the variable size of the fields didn't matter. But the upcoming RISC-V nommu port supports 64-bit CPUs, and we now have a conflict between the elf2flt creation tool that always uses 32-bit fields and the kernel that uses (unsigned) long field. Switch to the userspace view as the rest of the binfmt_flat format is completely architecture neutral, and binfmt_flat isn't the right binary format for huge executables to start with. While we're at it also ensure these fields are using __be types as they big endian and are byteswapped when loaded. Signed-off-by: Christoph Hellwig wip Reviewed-by: Vladimir Murzin --- include/linux/flat.h | 48 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/include/linux/flat.h b/include/linux/flat.h index 21d901ba191b..59e892d5fadb 100644 --- a/include/linux/flat.h +++ b/include/linux/flat.h @@ -24,26 +24,26 @@ */ struct flat_hdr { - char magic[4]; - unsigned long rev; /* version (as above) */ - unsigned long entry; /* Offset of first executable instruction - with text segment from beginning of file */ - unsigned long data_start; /* Offset of data segment from beginning of - file */ - unsigned long data_end; /* Offset of end of data segment - from beginning of file */ - unsigned long bss_end; /* Offset of end of bss segment from beginning - of file */ + char magic[4]; + __be32 rev; /* version (as above) */ + __be32 entry; /* Offset of first executable instruction + with text segment from beginning of file */ + __be32 data_start; /* Offset of data segment from beginning of + file */ + __be32 data_end; /* Offset of end of data segment from beginning + of file */ + __be32 bss_end; /* Offset of end of bss segment from beginning + of file */ /* (It is assumed that data_end through bss_end forms the bss segment.) */ - unsigned long stack_size; /* Size of stack, in bytes */ - unsigned long reloc_start; /* Offset of relocation records from - beginning of file */ - unsigned long reloc_count; /* Number of relocation records */ - unsigned long flags; - unsigned long build_date; /* When the program/library was built */ - unsigned long filler[5]; /* Reservered, set to zero */ + __be32 stack_size; /* Size of stack, in bytes */ + __be32 reloc_start; /* Offset of relocation records from beginning of + file */ + __be32 reloc_count; /* Number of relocation records */ + __be32 flags; + __be32 build_date; /* When the program/library was built */ + __u32 filler[5]; /* Reservered, set to zero */ }; #define FLAT_FLAG_RAM 0x0001 /* load program entirely into RAM */ @@ -67,19 +67,19 @@ struct flat_hdr { #define OLD_FLAT_RELOC_TYPE_BSS 2 typedef union { - unsigned long value; + u32 value; struct { # if defined(mc68000) && !defined(CONFIG_COLDFIRE) - signed long offset : 30; - unsigned long type : 2; + s32 offset : 30; + u32 type : 2; # define OLD_FLAT_FLAG_RAM 0x1 /* load program entirely into RAM */ # elif defined(__BIG_ENDIAN_BITFIELD) - unsigned long type : 2; - signed long offset : 30; + u32 type : 2; + s32 offset : 30; # define OLD_FLAT_FLAG_RAM 0x1 /* load program entirely into RAM */ # elif defined(__LITTLE_ENDIAN_BITFIELD) - signed long offset : 30; - unsigned long type : 2; + s32 offset : 30; + u32 type : 2; # define OLD_FLAT_FLAG_RAM 0x1 /* load program entirely into RAM */ # else # error "Unknown bitfield order for flat files." From patchwork Mon Jun 10 21:20:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10985465 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D56714DB for ; Mon, 10 Jun 2019 21:21:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DCB120182 for ; Mon, 10 Jun 2019 21:21:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 320E128712; Mon, 10 Jun 2019 21:21:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SUSPICIOUS_RECIPS autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C240320182 for ; Mon, 10 Jun 2019 21:21:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390199AbfFJVUo (ORCPT ); Mon, 10 Jun 2019 17:20:44 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38024 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390184AbfFJVUo (ORCPT ); Mon, 10 Jun 2019 17:20:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=hGQgwRV1eNL4J8F+4meQGtmLL8M3JcwulArYLNjpMJ8=; b=HrY0Qmw4UWxKsjKqwlGOY2rvJG UK7OXPg1aHe65+DyhhWcTojLokTJuiKlgU8nm8jMKBk33aAczqlY4M+sdNWN96cA1i1qGwkYqXF+V mCCACQ9yMyyfq6db7oCILXsO6ILPJDp8AViRTldak/C0s2Q+zPIUJabe3/tFNnTwTOEz+OuFBun19 ho/e6SH9Qkxm1v5kl1uQmzMtKLsQ/oxe0W9JwbPLuSzebhJKB+R1lyA/+996cue4125f5nczqXmKp K9NVnDSnmA+fj0Q4Df69lnzNSX9zx4U7lbSdN1vKmwJhVe6BPKUnobOt/MEYHA34xgJbug9+IHAmX 4w7EhwmA==; Received: from 089144193064.atnat0002.highway.a1.net ([89.144.193.64] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1haRiZ-0000Zd-Af; Mon, 10 Jun 2019 21:20:40 +0000 From: Christoph Hellwig To: Greg Ungerer Cc: Michal Simek , linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, uclinux-h8-devel@lists.sourceforge.jp, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/15] binfmt_flat: add endianess annotations Date: Mon, 10 Jun 2019 23:20:08 +0200 Message-Id: <20190610212015.9157-9-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190610212015.9157-1-hch@lst.de> References: <20190610212015.9157-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Most binfmt_flat on-disk fields are big endian. Use the proper __be32 type where applicable. Signed-off-by: Christoph Hellwig Tested-by: Vladimir Murzin Reviewed-by: Vladimir Murzin --- fs/binfmt_flat.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index 6ae0f9af3fc9..6c1848dee724 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c @@ -421,7 +421,8 @@ static int load_flat_file(struct linux_binprm *bprm, unsigned long textpos, datapos, realdatastart; u32 text_len, data_len, bss_len, stack_len, full_data, flags; unsigned long len, memp, memp_size, extra, rlim; - u32 __user *reloc, *rp; + __be32 __user *reloc; + u32 __user *rp; struct inode *inode; int i, rev, relocs; loff_t fpos; @@ -594,7 +595,7 @@ static int load_flat_file(struct linux_binprm *bprm, goto err; } - reloc = (u32 __user *) + reloc = (__be32 __user *) (datapos + (ntohl(hdr->reloc_start) - text_len)); memp = realdatastart; memp_size = len; @@ -619,7 +620,7 @@ static int load_flat_file(struct linux_binprm *bprm, MAX_SHARED_LIBS * sizeof(u32), FLAT_DATA_ALIGN); - reloc = (u32 __user *) + reloc = (__be32 __user *) (datapos + (ntohl(hdr->reloc_start) - text_len)); memp = textpos; memp_size = len; @@ -785,15 +786,16 @@ static int load_flat_file(struct linux_binprm *bprm, u32 __maybe_unused persistent = 0; for (i = 0; i < relocs; i++) { u32 addr, relval; + __be32 tmp; /* * Get the address of the pointer to be * relocated (of course, the address has to be * relocated first). */ - if (get_user(relval, reloc + i)) + if (get_user(tmp, reloc + i)) return -EFAULT; - relval = ntohl(relval); + relval = ntohl(tmp); addr = flat_get_relocate_addr(relval); rp = (u32 __user *)calc_reloc(addr, libinfo, id, 1); if (rp == (u32 __user *)RELOC_FAILED) { @@ -812,8 +814,13 @@ static int load_flat_file(struct linux_binprm *bprm, * Do the relocation. PIC relocs in the data section are * already in target order */ - if ((flags & FLAT_FLAG_GOTPIC) == 0) - addr = ntohl(addr); + if ((flags & FLAT_FLAG_GOTPIC) == 0) { + /* + * Meh, the same value can have a different + * byte order based on a flag.. + */ + addr = ntohl((__force __be32)addr); + } addr = calc_reloc(addr, libinfo, id, 0); if (addr == RELOC_FAILED) { ret = -ENOEXEC; @@ -828,11 +835,10 @@ static int load_flat_file(struct linux_binprm *bprm, } } else { for (i = 0; i < relocs; i++) { - u32 relval; + __be32 relval; if (get_user(relval, reloc + i)) return -EFAULT; - relval = ntohl(relval); - old_reloc(relval); + old_reloc(ntohl(relval)); } } From patchwork Mon Jun 10 21:20:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10985463 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2472014DB for ; Mon, 10 Jun 2019 21:21:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1160620182 for ; Mon, 10 Jun 2019 21:21:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02BD428712; Mon, 10 Jun 2019 21:21:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SUSPICIOUS_RECIPS autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FDA120182 for ; Mon, 10 Jun 2019 21:21:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390226AbfFJVUs (ORCPT ); Mon, 10 Jun 2019 17:20:48 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38264 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390184AbfFJVUr (ORCPT ); Mon, 10 Jun 2019 17:20:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=1jVYMx/arZAqs3yuKoy0cJPUA3vC+BJxP8Rm0Qe6EP0=; b=RLeDGOFuoEZIU9Yz3L63IZUUz5 dMkmwauB0/YGOaKSByq48/Po0fjYbOpKaT2U5m6IsGlvf80ujBTEc4ShK/FrfLnQBAtVz+s9/5NwH 2OcXoPeCABwy6MXhqnLwhl1y6ffF+r7nA+a6FDl06pRqMso7LCdeA1DVEX+i5Ptxhs6XMA1RbIJ2+ Ch7L+/809ketnOVB2AYZfg4ylqI/N+LRd/HF6NTQ69H9fvrY3oGAg5suKEzMBhwqdrKNjjYzYGCDn SG/ryasHhHqXAhnDDEAIrXpKu/HWWQvfkljoPukucA0zTwcjXn8KEkkc/9BTehqzpG4SOi5mnwCkP gs3Bsz0w==; Received: from 089144193064.atnat0002.highway.a1.net ([89.144.193.64] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1haRic-0000bq-Co; Mon, 10 Jun 2019 21:20:42 +0000 From: Christoph Hellwig To: Greg Ungerer Cc: Michal Simek , linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, uclinux-h8-devel@lists.sourceforge.jp, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/15] binfmt_flat: add a ARCH_HAS_BINFMT_FLAT option Date: Mon, 10 Jun 2019 23:20:09 +0200 Message-Id: <20190610212015.9157-10-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190610212015.9157-1-hch@lst.de> References: <20190610212015.9157-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allow architectures to opt into ARCH_HAS_BINFMT_FLAT support instead of assuming that all nommu ports support the format. Signed-off-by: Christoph Hellwig Reviewed-by: Vladimir Murzin --- arch/arm/Kconfig | 1 + arch/c6x/Kconfig | 1 + arch/h8300/Kconfig | 1 + arch/m68k/Kconfig | 1 + arch/microblaze/Kconfig | 1 + arch/sh/Kconfig | 1 + arch/xtensa/Kconfig | 1 + fs/Kconfig.binfmt | 5 ++++- 8 files changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index b1b48c0bde76..695a26c68064 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -4,6 +4,7 @@ config ARM default y select ARCH_32BIT_OFF_T select ARCH_CLOCKSOURCE_DATA + select ARCH_HAS_BINFMT_FLAT select ARCH_HAS_DEBUG_VIRTUAL if MMU select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAS_ELF_RANDOMIZE diff --git a/arch/c6x/Kconfig b/arch/c6x/Kconfig index eeb0471268a0..78dfe186d708 100644 --- a/arch/c6x/Kconfig +++ b/arch/c6x/Kconfig @@ -7,6 +7,7 @@ config C6X def_bool y select ARCH_32BIT_OFF_T + select ARCH_HAS_BINFMT_FLAT select ARCH_HAS_SYNC_DMA_FOR_CPU select ARCH_HAS_SYNC_DMA_FOR_DEVICE select CLKDEV_LOOKUP diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig index 7457f190caaa..ec800e9d5aad 100644 --- a/arch/h8300/Kconfig +++ b/arch/h8300/Kconfig @@ -2,6 +2,7 @@ config H8300 def_bool y select ARCH_32BIT_OFF_T + select ARCH_HAS_BINFMT_FLAT select BINFMT_FLAT_ARGVP_ENVP_ON_STACK select BINFMT_FLAT_OLD_ALWAYS_RAM select GENERIC_ATOMIC64 diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index fd69ee5ad6ab..c0c43c624afa 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -3,6 +3,7 @@ config M68K bool default y select ARCH_32BIT_OFF_T + select ARCH_HAS_BINFMT_FLAT select ARCH_HAS_SYNC_DMA_FOR_DEVICE if HAS_DMA select ARCH_MIGHT_HAVE_PC_PARPORT if ISA select ARCH_NO_COHERENT_DMA_MMAP if !MMU diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index f11433daab4a..d411de05b628 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig @@ -3,6 +3,7 @@ config MICROBLAZE def_bool y select ARCH_32BIT_OFF_T select ARCH_NO_SWAP + select ARCH_HAS_BINFMT_FLAT if !MMU select ARCH_HAS_DMA_COHERENT_TO_PFN if MMU select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_SYNC_DMA_FOR_CPU diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index b77f512bb176..df3e6215b78c 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 config SUPERH def_bool y + select ARCH_HAS_BINFMT_FLAT if !MMU select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_MIGHT_HAVE_PC_PARPORT diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index 6ec1b75eabc5..ebc135bda921 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -2,6 +2,7 @@ config XTENSA def_bool y select ARCH_32BIT_OFF_T + select ARCH_HAS_BINFMT_FLAT if !MMU select ARCH_HAS_SYNC_DMA_FOR_CPU select ARCH_HAS_SYNC_DMA_FOR_DEVICE select ARCH_NO_COHERENT_DMA_MMAP if !MMU diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt index 82f7d7f234f3..286b425b30b9 100644 --- a/fs/Kconfig.binfmt +++ b/fs/Kconfig.binfmt @@ -91,9 +91,12 @@ config BINFMT_SCRIPT Most systems will not boot if you say M or N here. If unsure, say Y. +config ARCH_HAS_BINFMT_FLAT + bool + config BINFMT_FLAT bool "Kernel support for flat binaries" - depends on !MMU || ARM || M68K + depends on ARCH_HAS_BINFMT_FLAT help Support uClinux FLAT format binaries. From patchwork Mon Jun 10 21:20:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10985447 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8345676 for ; Mon, 10 Jun 2019 21:20:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7348B20182 for ; Mon, 10 Jun 2019 21:20:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 676412835B; Mon, 10 Jun 2019 21:20:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SUSPICIOUS_RECIPS autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF46220182 for ; Mon, 10 Jun 2019 21:20:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390252AbfFJVUv (ORCPT ); Mon, 10 Jun 2019 17:20:51 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38468 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390184AbfFJVUu (ORCPT ); Mon, 10 Jun 2019 17:20:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=MpfWK/0vENKyxeud9UpYn1xqE4+sty9MPUJubwIq9q0=; b=XGMTXBKR2of90n9B9Kzp92+BDO CS8Gu0mx2mY9f3eJUqh313R3OHs5pBRP0q1QUopJi3xN9/YNSiWsaJZuMl61TAAviIAvGUqrsh8Pd a82jZFkiViwQudyH1dgdtBvxk4VO3CClvhRFz2hkZ//zUITcfWL2/EHu+RqUNpeduhKKLkfyE23p1 2vnoefGssodvFrK2kOpet/e9ye9Zqr0JxvicVLF4XgXwX0sDQueo4Lo89u36ErVUZQbwQx7jPqL9J FhNWYS3cuEOEPR1PHdy58rbF6nA9J/B+gmjyH+rqaJLorKPtLgmQVuxPBnNh713kKADOP018fywCF e4RHBn0Q==; Received: from 089144193064.atnat0002.highway.a1.net ([89.144.193.64] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1haRif-0000eX-46; Mon, 10 Jun 2019 21:20:45 +0000 From: Christoph Hellwig To: Greg Ungerer Cc: Michal Simek , linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, uclinux-h8-devel@lists.sourceforge.jp, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/15] binfmt_flat: make support for old format binaries optional Date: Mon, 10 Jun 2019 23:20:10 +0200 Message-Id: <20190610212015.9157-11-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190610212015.9157-1-hch@lst.de> References: <20190610212015.9157-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP No need to carry the extra code around, given that systems using flat binaries are generally very resource constrained. Signed-off-by: Christoph Hellwig --- fs/Kconfig.binfmt | 7 +++++++ fs/binfmt_flat.c | 29 +++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt index 286b425b30b9..62dc4f577ba1 100644 --- a/fs/Kconfig.binfmt +++ b/fs/Kconfig.binfmt @@ -106,6 +106,13 @@ config BINFMT_FLAT_ARGVP_ENVP_ON_STACK config BINFMT_FLAT_OLD_ALWAYS_RAM bool +config BINFMT_FLAT_OLD + bool "Enable support for very old legacy flat binaries" + depends on BINFMT_FLAT + help + Support decade old uClinux FLAT format binaries. Unless you know + you have some of those say N here. + config BINFMT_ZFLAT bool "Enable ZFLAT support" depends on BINFMT_FLAT diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index 6c1848dee724..ed7d969593d2 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c @@ -374,6 +374,7 @@ calc_reloc(unsigned long r, struct lib_info *p, int curid, int internalp) /****************************************************************************/ +#ifdef CONFIG_BINFMT_FLAT_OLD static void old_reloc(unsigned long rl) { static const char *segment[] = { "TEXT", "DATA", "BSS", "*UNKNOWN*" }; @@ -411,6 +412,7 @@ static void old_reloc(unsigned long rl) pr_debug("Relocation became %lx\n", val); } +#endif /* CONFIG_BINFMT_FLAT_OLD */ /****************************************************************************/ @@ -461,6 +463,7 @@ static int load_flat_file(struct linux_binprm *bprm, if (flags & FLAT_FLAG_KTRACE) pr_info("Loading file: %s\n", bprm->filename); +#ifdef CONFIG_BINFMT_FLAT_OLD if (rev != FLAT_VERSION && rev != OLD_FLAT_VERSION) { pr_err("bad flat file version 0x%x (supported 0x%lx and 0x%lx)\n", rev, FLAT_VERSION, OLD_FLAT_VERSION); @@ -476,6 +479,22 @@ static int load_flat_file(struct linux_binprm *bprm, goto err; } + /* + * fix up the flags for the older format, there were all kinds + * of endian hacks, this only works for the simple cases + */ + if (IS_ENABLED(CONFIG_BINFMT_FLAT_OLD_ALWAYS_RAM) && + rev == OLD_FLAT_VERSION) + flags = FLAT_FLAG_RAM; +#else /* CONFIG_BINFMT_FLAT_OLD */ + if (rev != FLAT_VERSION) { + pr_err("bad flat file version 0x%x (supported 0x%lx)\n", + rev, FLAT_VERSION); + ret = -ENOEXEC; + goto err; + } +#endif /* !CONFIG_BINFMT_FLAT_OLD */ + /* * Make sure the header params are sane. * 28 bits (256 MB) is way more than reasonable in this case. @@ -487,14 +506,6 @@ static int load_flat_file(struct linux_binprm *bprm, goto err; } - /* - * fix up the flags for the older format, there were all kinds - * of endian hacks, this only works for the simple cases - */ - if (IS_ENABLED(CONFIG_BINFMT_FLAT_OLD_ALWAYS_RAM) && - rev == OLD_FLAT_VERSION) - flags = FLAT_FLAG_RAM; - #ifndef CONFIG_BINFMT_ZFLAT if (flags & (FLAT_FLAG_GZIP|FLAT_FLAG_GZDATA)) { pr_err("Support for ZFLAT executables is not enabled.\n"); @@ -833,6 +844,7 @@ static int load_flat_file(struct linux_binprm *bprm, goto err; } } +#ifdef CONFIG_BINFMT_FLAT_OLD } else { for (i = 0; i < relocs; i++) { __be32 relval; @@ -840,6 +852,7 @@ static int load_flat_file(struct linux_binprm *bprm, return -EFAULT; old_reloc(ntohl(relval)); } +#endif /* CONFIG_BINFMT_FLAT_OLD */ } flush_icache_range(start_code, end_code); From patchwork Mon Jun 10 21:20:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10985449 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3787476 for ; Mon, 10 Jun 2019 21:21:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23BD528716 for ; Mon, 10 Jun 2019 21:21:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F81120182; Mon, 10 Jun 2019 21:21:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SUSPICIOUS_RECIPS autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B29920182 for ; Mon, 10 Jun 2019 21:21:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390287AbfFJVUz (ORCPT ); Mon, 10 Jun 2019 17:20:55 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38634 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390258AbfFJVUx (ORCPT ); Mon, 10 Jun 2019 17:20:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=T1XcVoygN5yZ8Kqai2i6+5m7CKaZdW1Ll8tjH35qZ4M=; b=WBKcPpc/Dav6TOWP4BMEmxfR3n zHLZwSwW0GJDfalVhp2jH7ZBm8FTfw1W9/rmfu+9sbKnXahDK52YZA6S5HXxEpEBzZ3M/JrBIxY+Y ONvNcnj921s43jY530ju+U2UHzDmeevWLFyJB6ldA2425CMitugaMuUaCsfwWqFmwnI0vUE3+94oM X0vWeS3vV3F55oj+Tbwt7byTH9lDOo1do96JGs7GIAry5hQenySfuT8jmXKsd1gH3DZgbliX0D/5+ 8D9+/WjhceuIKvFRcQH+80ZVDhiuwTpd9STtBHkuO4uQnPxuY5PAMiag/PTOiaS6YIGLYoilUMDmL jem9xwUw==; Received: from 089144193064.atnat0002.highway.a1.net ([89.144.193.64] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1haRih-0000h3-Np; Mon, 10 Jun 2019 21:20:48 +0000 From: Christoph Hellwig To: Greg Ungerer Cc: Michal Simek , linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, uclinux-h8-devel@lists.sourceforge.jp, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/15] binfmt_flat: provide an asm-generic/flat.h Date: Mon, 10 Jun 2019 23:20:11 +0200 Message-Id: <20190610212015.9157-12-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190610212015.9157-1-hch@lst.de> References: <20190610212015.9157-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This file implements the flat get/put reloc helpers for architectures that do not need to overload the relocs by simply using get_user/put_user. Note that many nommu architectures currently use {get,put}_unaligned, which looks a little bogus and should probably later be switched over to this version as well. Signed-off-by: Christoph Hellwig Reviewed-by: Vladimir Murzin --- arch/arm/include/asm/Kbuild | 1 + arch/m68k/include/asm/flat.h | 21 +------------------ .../asm => include/asm-generic}/flat.h | 12 ++++------- 3 files changed, 6 insertions(+), 28 deletions(-) rename {arch/arm/include/asm => include/asm-generic}/flat.h (73%) diff --git a/arch/arm/include/asm/Kbuild b/arch/arm/include/asm/Kbuild index a8f149ab45b8..6b2dc15b6dff 100644 --- a/arch/arm/include/asm/Kbuild +++ b/arch/arm/include/asm/Kbuild @@ -5,6 +5,7 @@ generic-y += early_ioremap.h generic-y += emergency-restart.h generic-y += exec.h generic-y += extable.h +generic-y += flat.h generic-y += irq_regs.h generic-y += kdebug.h generic-y += local.h diff --git a/arch/m68k/include/asm/flat.h b/arch/m68k/include/asm/flat.h index d7102fcd43eb..46379e08cdd6 100644 --- a/arch/m68k/include/asm/flat.h +++ b/arch/m68k/include/asm/flat.h @@ -6,26 +6,7 @@ #ifndef __M68KNOMMU_FLAT_H__ #define __M68KNOMMU_FLAT_H__ -#include - -static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, - u32 *addr, u32 *persistent) -{ -#ifdef CONFIG_CPU_HAS_NO_UNALIGNED - return copy_from_user(addr, rp, 4) ? -EFAULT : 0; -#else - return get_user(*addr, rp); -#endif -} - -static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel) -{ -#ifdef CONFIG_CPU_HAS_NO_UNALIGNED - return copy_to_user(rp, &addr, 4) ? -EFAULT : 0; -#else - return put_user(addr, rp); -#endif -} +#include #define FLAT_PLAT_INIT(regs) \ do { \ diff --git a/arch/arm/include/asm/flat.h b/include/asm-generic/flat.h similarity index 73% rename from arch/arm/include/asm/flat.h rename to include/asm-generic/flat.h index bbc27901446f..fcd2b45c0735 100644 --- a/arch/arm/include/asm/flat.h +++ b/include/asm-generic/flat.h @@ -1,15 +1,11 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* - * arch/arm/include/asm/flat.h -- uClinux flat-format executables - */ - -#ifndef __ARM_FLAT_H__ -#define __ARM_FLAT_H__ +#ifndef _ASM_GENERIC_FLAT_H +#define _ASM_GENERIC_FLAT_H #include static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, - u32 *addr, u32 *persistent) + u32 *addr, u32 *persistent) { #ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS return copy_from_user(addr, rp, 4) ? -EFAULT : 0; @@ -27,4 +23,4 @@ static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel) #endif } -#endif /* __ARM_FLAT_H__ */ +#endif /* _ASM_GENERIC_FLAT_H */ From patchwork Mon Jun 10 21:20:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10985453 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A795518A6 for ; Mon, 10 Jun 2019 21:21:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 966B020182 for ; Mon, 10 Jun 2019 21:21:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A08528635; Mon, 10 Jun 2019 21:21:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SUSPICIOUS_RECIPS autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B69D28712 for ; Mon, 10 Jun 2019 21:21:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390333AbfFJVVA (ORCPT ); Mon, 10 Jun 2019 17:21:00 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38774 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390184AbfFJVUz (ORCPT ); Mon, 10 Jun 2019 17:20:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=IfIvobHhliD7MEqdCKHlxMFprSvdnhezPdaASrVUoiA=; b=TZJSapzBw06TNQ4xs5DbJla2hU +cKo6J9E6Bz8PsAduKmvq7yvziGEydc0eWhfFWF7Cv+F4pZhxeuNOoGlnQ5juEJQYuSGQ/oBMRmts qTwijAzWQ3XGKiEPn2gENofBOwR9k1KtrINV8WXspsGcLJ/Jzkxr64pK3W0SuJhEjkJpC6wOWuA4s 2RY2Ypj/TyMwCZHF5oQHzNWZ2otu+X5KbEy39aq7uESdv12ErZIvYnh7NemzknnRKPkdRxX/8sh5p vlq4flIQDxvUPbdr9feyljIzrzLZlOdCLwJ0KtRTWSgHYqF7e8Wd3pOPF9u5KZlDYJaaAkDj3ldbW 0sVSeXtw==; Received: from 089144193064.atnat0002.highway.a1.net ([89.144.193.64] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1haRik-0000k2-Fb; Mon, 10 Jun 2019 21:20:51 +0000 From: Christoph Hellwig To: Greg Ungerer Cc: Michal Simek , linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, uclinux-h8-devel@lists.sourceforge.jp, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/15] binfmt_flat: remove the persistent argument from flat_get_addr_from_rp Date: Mon, 10 Jun 2019 23:20:12 +0200 Message-Id: <20190610212015.9157-13-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190610212015.9157-1-hch@lst.de> References: <20190610212015.9157-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The argument is never used. Signed-off-by: Christoph Hellwig --- arch/c6x/include/asm/flat.h | 2 +- arch/h8300/include/asm/flat.h | 2 +- arch/microblaze/include/asm/flat.h | 2 +- arch/sh/include/asm/flat.h | 2 +- arch/xtensa/include/asm/flat.h | 2 +- fs/binfmt_flat.c | 4 +--- include/asm-generic/flat.h | 2 +- 7 files changed, 7 insertions(+), 9 deletions(-) diff --git a/arch/c6x/include/asm/flat.h b/arch/c6x/include/asm/flat.h index 2d57a9204d21..9e6544b51386 100644 --- a/arch/c6x/include/asm/flat.h +++ b/arch/c6x/include/asm/flat.h @@ -5,7 +5,7 @@ #include static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, - u32 *addr, u32 *persistent) + u32 *addr) { *addr = get_unaligned((__force u32 *)rp); return 0; diff --git a/arch/h8300/include/asm/flat.h b/arch/h8300/include/asm/flat.h index 4683146f0e9e..78070f924177 100644 --- a/arch/h8300/include/asm/flat.h +++ b/arch/h8300/include/asm/flat.h @@ -17,7 +17,7 @@ #define flat_get_relocate_addr(rel) (rel & ~0x00000001) static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, - u32 *addr, u32 *persistent) + u32 *addr) { u32 val = get_unaligned((__force u32 *)rp); if (!(flags & FLAT_FLAG_GOTPIC)) diff --git a/arch/microblaze/include/asm/flat.h b/arch/microblaze/include/asm/flat.h index 9e3d8e01d294..1ab86770eaee 100644 --- a/arch/microblaze/include/asm/flat.h +++ b/arch/microblaze/include/asm/flat.h @@ -28,7 +28,7 @@ */ static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, - u32 *addr, u32 *persistent) + u32 *addr) { u32 *p = (__force u32 *)rp; diff --git a/arch/sh/include/asm/flat.h b/arch/sh/include/asm/flat.h index 1002343dd84a..fee4f25555cb 100644 --- a/arch/sh/include/asm/flat.h +++ b/arch/sh/include/asm/flat.h @@ -12,7 +12,7 @@ #include static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, - u32 *addr, u32 *persistent) + u32 *addr) { *addr = get_unaligned((__force u32 *)rp); return 0; diff --git a/arch/xtensa/include/asm/flat.h b/arch/xtensa/include/asm/flat.h index 3d357371b28b..ed5870c779f9 100644 --- a/arch/xtensa/include/asm/flat.h +++ b/arch/xtensa/include/asm/flat.h @@ -5,7 +5,7 @@ #include static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, - u32 *addr, u32 *persistent) + u32 *addr) { *addr = get_unaligned((__force u32 *)rp); return 0; diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index ed7d969593d2..114ea225c5a5 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c @@ -794,7 +794,6 @@ static int load_flat_file(struct linux_binprm *bprm, * __start to address 4 so that is okay). */ if (rev > OLD_FLAT_VERSION) { - u32 __maybe_unused persistent = 0; for (i = 0; i < relocs; i++) { u32 addr, relval; __be32 tmp; @@ -815,8 +814,7 @@ static int load_flat_file(struct linux_binprm *bprm, } /* Get the pointer's value. */ - ret = flat_get_addr_from_rp(rp, relval, flags, - &addr, &persistent); + ret = flat_get_addr_from_rp(rp, relval, flags, &addr); if (unlikely(ret)) goto err; diff --git a/include/asm-generic/flat.h b/include/asm-generic/flat.h index fcd2b45c0735..1928a3596938 100644 --- a/include/asm-generic/flat.h +++ b/include/asm-generic/flat.h @@ -5,7 +5,7 @@ #include static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, - u32 *addr, u32 *persistent) + u32 *addr) { #ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS return copy_from_user(addr, rp, 4) ? -EFAULT : 0; From patchwork Mon Jun 10 21:20:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10985451 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 71A121850 for ; Mon, 10 Jun 2019 21:21:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F70C20182 for ; Mon, 10 Jun 2019 21:21:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B64C28716; Mon, 10 Jun 2019 21:21:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SUSPICIOUS_RECIPS autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D41C428635 for ; Mon, 10 Jun 2019 21:21:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390320AbfFJVVA (ORCPT ); Mon, 10 Jun 2019 17:21:00 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:39062 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389942AbfFJVU7 (ORCPT ); Mon, 10 Jun 2019 17:20:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=z0ABo4wszxqi3K39ZGQzfBfXvNYJFQBVr40MuiB/7Co=; b=kaB5DYj3zKrwZYQNWT3binWYEJ XfO8tNdoueeFPse0xD0uWfFT9DeX+yTgFerm/xLo2LRtnkCOAodrrXwwivkvV/ilbhCcKY05AlPYZ t+JUZuFNwrFXqiDanRldiJC5J8qeDD8oZTrnE0G4wRyXRQInG+uRVte0w7Fwy7RtmkBj6ApT1qcfH Y5Auvd5y8JQm10baXxvXYgcoxKWR65mXW/bDO7Nw0dfROixalLqUeEKloqGT6Dn4c8Gdiu7Q4xTBM KlM5qWP4cYE8QKJoUt9MeAqCD/Jd/5m84/DojVI+9yt7cCq78RjJXhbEdXKkpWSZeqyGIFxwt8peZ PQjs5UhA==; Received: from 089144193064.atnat0002.highway.a1.net ([89.144.193.64] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1haRin-0000mW-9m; Mon, 10 Jun 2019 21:20:53 +0000 From: Christoph Hellwig To: Greg Ungerer Cc: Michal Simek , linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, uclinux-h8-devel@lists.sourceforge.jp, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/15] binfmt_flat: move the MAX_SHARED_LIBS definition to binfmt_flat.c Date: Mon, 10 Jun 2019 23:20:13 +0200 Message-Id: <20190610212015.9157-14-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190610212015.9157-1-hch@lst.de> References: <20190610212015.9157-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP MAX_SHARED_LIBS is an implementation detail of the kernel loader, and should be kept away from the file format definition. Signed-off-by: Christoph Hellwig --- fs/binfmt_flat.c | 6 ++++++ include/linux/flat.h | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index 114ea225c5a5..2c7f32d5435f 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c @@ -68,6 +68,12 @@ #define RELOC_FAILED 0xff00ff01 /* Relocation incorrect somewhere */ #define UNLOADED_LIB 0x7ff000ff /* Placeholder for unused library */ +#ifdef CONFIG_BINFMT_SHARED_FLAT +#define MAX_SHARED_LIBS (4) +#else +#define MAX_SHARED_LIBS (1) +#endif + struct lib_info { struct { unsigned long start_code; /* Start of text segment */ diff --git a/include/linux/flat.h b/include/linux/flat.h index 59e892d5fadb..a2232f1bd41b 100644 --- a/include/linux/flat.h +++ b/include/linux/flat.h @@ -12,12 +12,6 @@ #define FLAT_VERSION 0x00000004L -#ifdef CONFIG_BINFMT_SHARED_FLAT -#define MAX_SHARED_LIBS (4) -#else -#define MAX_SHARED_LIBS (1) -#endif - /* * To make everything easier to port and manage cross platform * development, all fields are in network byte order. From patchwork Mon Jun 10 21:20:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10985461 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A7FB114DB for ; Mon, 10 Jun 2019 21:21:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9826220182 for ; Mon, 10 Jun 2019 21:21:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C31F28712; Mon, 10 Jun 2019 21:21:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SUSPICIOUS_RECIPS autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27FED20182 for ; Mon, 10 Jun 2019 21:21:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389983AbfFJVVQ (ORCPT ); Mon, 10 Jun 2019 17:21:16 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:39192 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390342AbfFJVVB (ORCPT ); Mon, 10 Jun 2019 17:21:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=M/oZjZKd86UGxkRYl1oTzaFRcdpwOtKgZIoGTg33tK4=; b=P9wzd+Vmog+LwRnUCtnR1Y910o R3ZVpkRWtcyNj9izlXH0SvAq6405+7KU69QeYXom7oJwUdwOx9jpJKE8dmuq7z3VWUguJ8Nt1yDO7 AboacC7p81nVVKWPpicJ+e4K9fP8GcruiBX7nDO0J2rC/Hv8vRyApo6RtRKQzDuQ0Tn+g3srFbBt1 vxtHJBDqO1hUzD6ePBxmHARkZmbHu8OSNW5SbkXgEx4E8QFzLctRkVLooaIJYeysmviVAUAsWZzZs ri90hTjLL8YqXl5S0jmkASO5WB9lCS7WncHdcL9KOwaGsK4FMUoAxNmkPP2QbHeWCbaaZpqLgUg+e UDNX7+8Q==; Received: from 089144193064.atnat0002.highway.a1.net ([89.144.193.64] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1haRip-0000p9-Vm; Mon, 10 Jun 2019 21:20:56 +0000 From: Christoph Hellwig To: Greg Ungerer Cc: Michal Simek , linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, uclinux-h8-devel@lists.sourceforge.jp, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-kernel@vger.kernel.org Subject: [PATCH 14/15] binfmt_flat: don't offset the data start Date: Mon, 10 Jun 2019 23:20:14 +0200 Message-Id: <20190610212015.9157-15-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190610212015.9157-1-hch@lst.de> References: <20190610212015.9157-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Ever since the initial commit of the binfmt_flat shared library support back in the bitkeeper days we've offset the actual in-memory .data start by one field per possible shared library, or 1 in case shared library support isn't enabled. I can't find anything in the loader that actually makes use of it, nor was it present before shared library support it. Signed-off-by: Christoph Hellwig --- fs/binfmt_flat.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index 2c7f32d5435f..e1ccc9f14150 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c @@ -572,7 +572,7 @@ static int load_flat_file(struct linux_binprm *bprm, goto err; } - len = data_len + extra + MAX_SHARED_LIBS * sizeof(unsigned long); + len = data_len + extra; len = PAGE_ALIGN(len); realdatastart = vm_mmap(NULL, 0, len, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 0); @@ -586,9 +586,7 @@ static int load_flat_file(struct linux_binprm *bprm, vm_munmap(textpos, text_len); goto err; } - datapos = ALIGN(realdatastart + - MAX_SHARED_LIBS * sizeof(unsigned long), - FLAT_DATA_ALIGN); + datapos = ALIGN(realdatastart, FLAT_DATA_ALIGN); pr_debug("Allocated data+bss+stack (%u bytes): %lx\n", data_len + bss_len + stack_len, datapos); @@ -618,7 +616,7 @@ static int load_flat_file(struct linux_binprm *bprm, memp_size = len; } else { - len = text_len + data_len + extra + MAX_SHARED_LIBS * sizeof(u32); + len = text_len + data_len + extra; len = PAGE_ALIGN(len); textpos = vm_mmap(NULL, 0, len, PROT_READ | PROT_EXEC | PROT_WRITE, MAP_PRIVATE, 0); @@ -633,9 +631,7 @@ static int load_flat_file(struct linux_binprm *bprm, } realdatastart = textpos + ntohl(hdr->data_start); - datapos = ALIGN(realdatastart + - MAX_SHARED_LIBS * sizeof(u32), - FLAT_DATA_ALIGN); + datapos = ALIGN(realdatastart, FLAT_DATA_ALIGN); reloc = (__be32 __user *) (datapos + (ntohl(hdr->reloc_start) - text_len)); @@ -652,8 +648,9 @@ static int load_flat_file(struct linux_binprm *bprm, (text_len + full_data - sizeof(struct flat_hdr)), 0); - memmove((void *) datapos, (void *) realdatastart, - full_data); + if (datapos != realdatastart) + memmove((void *)datapos, (void *)realdatastart, + full_data); #else /* * This is used on MMU systems mainly for testing. @@ -709,8 +706,7 @@ static int load_flat_file(struct linux_binprm *bprm, if (IS_ERR_VALUE(result)) { ret = result; pr_err("Unable to read code+data+bss, errno %d\n", ret); - vm_munmap(textpos, text_len + data_len + extra + - MAX_SHARED_LIBS * sizeof(u32)); + vm_munmap(textpos, text_len + data_len + extra); goto err; } } From patchwork Mon Jun 10 21:20:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10985457 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 246BF76 for ; Mon, 10 Jun 2019 21:21:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 140ED20182 for ; Mon, 10 Jun 2019 21:21:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0895F28712; Mon, 10 Jun 2019 21:21:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SUSPICIOUS_RECIPS autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACD7220182 for ; Mon, 10 Jun 2019 21:21:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390367AbfFJVVE (ORCPT ); Mon, 10 Jun 2019 17:21:04 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:39350 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390360AbfFJVVE (ORCPT ); Mon, 10 Jun 2019 17:21:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=q10pHG3ogaKOvbsSkhn8aFuqHA9X6EOL7rEdJvEUOlc=; b=k5gK2rAcRV04Sh79BrDU2YKhQn pa6mx17pxufIw+EOMbM1CvH5R8x6Qy8Wt6KORtiH5rnWqhpOEDnXx+o7Sldh7FvDKFfB/dF4a1lup LW4Zt/eDWQi3l5KziYxGcgFzzWG4CYHx1IOA7wHbpThQhByg56uuHGqCum+Hk4fuiEXPm2IaGjIbt /g/hqgKk+qk0Y62uRfswgRWcLmdYNc8Zjd+TeX/4BTsBgAYtp5J+0UboPHGsa5+DzEO7zSrMwjQIf Dzn1Vsp0m3pNLGWwFiLF/HLcjSA8sc+J1+KKyZYODym2hJdINhfrlKLZ0BKurPLAiWjDgx/2O/fKx mGfsPnuQ==; Received: from 089144193064.atnat0002.highway.a1.net ([89.144.193.64] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1haRis-0000rG-Fv; Mon, 10 Jun 2019 21:20:59 +0000 From: Christoph Hellwig To: Greg Ungerer Cc: Michal Simek , linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, uclinux-h8-devel@lists.sourceforge.jp, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-kernel@vger.kernel.org Subject: [PATCH 15/15] riscv: add binfmt_flat support Date: Mon, 10 Jun 2019 23:20:15 +0200 Message-Id: <20190610212015.9157-16-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190610212015.9157-1-hch@lst.de> References: <20190610212015.9157-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use the generic support with arguments are on the stack. Same as arm and m68k. Signed-off-by: Christoph Hellwig --- arch/riscv/Kconfig | 2 ++ arch/riscv/include/asm/Kbuild | 1 + 2 files changed, 3 insertions(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 0c4b12205632..2e3b60cdeef4 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -17,7 +17,9 @@ config RISCV select OF select OF_EARLY_FLATTREE select OF_IRQ + select ARCH_HAS_BINFMT_FLAT select ARCH_WANT_FRAME_POINTERS + select BINFMT_FLAT_ARGVP_ENVP_ON_STACK select CLONE_BACKWARDS select COMMON_CLK select GENERIC_CLOCKEVENTS diff --git a/arch/riscv/include/asm/Kbuild b/arch/riscv/include/asm/Kbuild index 5ee646619cc3..1efaeddf1e4b 100644 --- a/arch/riscv/include/asm/Kbuild +++ b/arch/riscv/include/asm/Kbuild @@ -5,6 +5,7 @@ generic-y += compat.h generic-y += device.h generic-y += div64.h generic-y += extable.h +generic-y += flat.h generic-y += dma.h generic-y += dma-contiguous.h generic-y += dma-mapping.h