From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0357EC433F5 for ; Wed, 20 Apr 2022 16:17:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380466AbiDTQUN (ORCPT ); Wed, 20 Apr 2022 12:20:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236364AbiDTQUM (ORCPT ); Wed, 20 Apr 2022 12:20:12 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4234C3152D for ; Wed, 20 Apr 2022 09:17:24 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id md20-20020a17090b23d400b001cb70ef790dso5372086pjb.5 for ; Wed, 20 Apr 2022 09:17:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20210112.gappssmtp.com; s=20210112; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=R3vTf19oMKRes6BtKfmN/qkhfJtJqpPYYlTIkqXViAo=; b=Sru+C6PlamA8jZ8NcDpobfoMpyR1tI0BLLOYSnhuMjMpMKwPJduh7wgA5KxBWIkND4 tKKndEm9Pa3MJV6a/uGti7n/QQJH7PPCjSLfGNQQEtc4MF8lMAWpq2K3FT1u+5vr38Ln BNE2xStACiq1NRMNOcY3icRI2T6I3qwyXUm2UenfYb0ZPkYR93Gp4eoKgOtac1dGcq9+ DzFyhDjLBEVcdvwClpFM0puu5Ylletc+nvUVSVz6qE3NjHIDs/8ydyqXukGdV6udYKOq iZCso/asGSaq+ghk4ecxZ+ndXBzExktwvz0I4Uy5D3ZiId7+XblIvx2XOwGtj48xPtfS YGOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=R3vTf19oMKRes6BtKfmN/qkhfJtJqpPYYlTIkqXViAo=; b=5Bci/AoCGq4PKDz6/V4Pjbuo8BLml6urWXB4dksPWYigvsRIqEpSFF9n02+Aab/INv KLhJFaxmY1B4ZksSVJAEoGo4nd7j2XWpQ9SmnWIURpWsIXuXE8Q/8mRecTCiKwRGKBhq Ixzf8yiRoaVvOMBZQs4+ZMyrWCog4+JgH+ddwN0dsd5EkC5a6NQ/m5RgCsuvsRjqR0J6 HrO2Lz6c7blAaqG4hHN5Ilc0rGzDzfGu06q3799wcrUkdfYCNXpwRtY/ovseO2Zpoa5l gVg6onpViRvXJMqTkkYD9LwZxvvAL541PFIt64TRf7K6UOS1il5k9Hzk7Y6KYwpkt5BJ zXow== X-Gm-Message-State: AOAM5319D9FIY767Fq3CCrSHUWXNTkdO8A9KmbpVjVtqKIY7Wa1oJY9y G/XKeKFygo022Gs5WrZRmSPtMA== X-Google-Smtp-Source: ABdhPJwthUt+XclRvJbnn9uqQazL2RR/Zs0U933iLuyatysqRD2khuenep71u0U+5+bXwtIAJPJ1rw== X-Received: by 2002:a17:90b:1b06:b0:1d1:6633:5ec2 with SMTP id nu6-20020a17090b1b0600b001d166335ec2mr5402715pjb.103.1650471443508; Wed, 20 Apr 2022 09:17:23 -0700 (PDT) Received: from localhost ([12.3.194.138]) by smtp.gmail.com with ESMTPSA id 16-20020a621410000000b0050aca5f79f5sm3374244pfu.97.2022.04.20.09.17.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 09:17:22 -0700 (PDT) Date: Wed, 20 Apr 2022 09:17:22 -0700 (PDT) X-Google-Original-Date: Wed, 20 Apr 2022 09:16:48 PDT (-0700) Subject: Re: [PATCH] binfmt_flat: Remove shared library support In-Reply-To: <87levzzts4.fsf_-_@email.froward.int.ebiederm.org> CC: keescook@chromium.org, Niklas.Cassel@wdc.com, viro@zeniv.linux.org.uk, Paul Walmsley , aou@eecs.berkeley.edu, vapier@gentoo.org, stable@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-arch@vger.kernel.org, geert@linux-m68k.org, linux-m68k@lists.linux-m68k.org, gerg@linux-m68k.org, linux-arm-kernel@lists.infradead.org, linux-sh@vger.kernel.org, ysato@users.sourceforge.jp, dalias@libc.org From: Palmer Dabbelt To: ebiederm@xmission.com, damien.lemoal@opensource.wdc.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org On Wed, 20 Apr 2022 07:58:03 PDT (-0700), ebiederm@xmission.com wrote: > > In a recent discussion[1] it was reported that the binfmt_flat library > support was only ever used on m68k and even on m68k has not been used > in a very long time. > > The structure of binfmt_flat is different from all of the other binfmt > implementations becasue of this shared library support and it made > life and code review more effort when I refactored the code in fs/exec.c. > > Since in practice the code is dead remove the binfmt_flat shared libarary > support and make maintenance of the code easier. > > [1] https://lkml.kernel.org/r/81788b56-5b15-7308-38c7-c7f2502c4e15@linux-m68k.org > Signed-off-by: "Eric W. Biederman" > --- > > Can the binfmt_flat folks please verify that the shared library support > really isn't used? I don't actually know follow the RISC-V flat support, last I heard it was still sort of just in limbo (some toolchain/userspace bugs th at needed to be sorted out). Damien would know better, though, he's already on the thread. I'll leave it up to him to ack this one, if you were even looking for anything from the RISC-V folks at all (we don't have this in any defconfigs). > Was binfmt_flat being enabled on arm and sh the mistake it looks like? > > arch/arm/configs/lpc18xx_defconfig | 1 - > arch/arm/configs/mps2_defconfig | 1 - > arch/arm/configs/stm32_defconfig | 1 - > arch/arm/configs/vf610m4_defconfig | 1 - > arch/sh/configs/rsk7201_defconfig | 1 - > arch/sh/configs/rsk7203_defconfig | 1 - > arch/sh/configs/se7206_defconfig | 1 - > fs/Kconfig.binfmt | 6 - > fs/binfmt_flat.c | 190 ++++++----------------------- > 9 files changed, 40 insertions(+), 163 deletions(-) > > diff --git a/arch/arm/configs/lpc18xx_defconfig b/arch/arm/configs/lpc18xx_defconfig > index be882ea0eee4..688c9849eec8 100644 > --- a/arch/arm/configs/lpc18xx_defconfig > +++ b/arch/arm/configs/lpc18xx_defconfig > @@ -30,7 +30,6 @@ CONFIG_ARM_APPENDED_DTB=y > # CONFIG_BLK_DEV_BSG is not set > CONFIG_BINFMT_FLAT=y > CONFIG_BINFMT_ZFLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > # CONFIG_COREDUMP is not set > CONFIG_NET=y > CONFIG_PACKET=y > diff --git a/arch/arm/configs/mps2_defconfig b/arch/arm/configs/mps2_defconfig > index 89f4a6ff30bd..c1e98e33a348 100644 > --- a/arch/arm/configs/mps2_defconfig > +++ b/arch/arm/configs/mps2_defconfig > @@ -23,7 +23,6 @@ CONFIG_PREEMPT_VOLUNTARY=y > CONFIG_ZBOOT_ROM_TEXT=0x0 > CONFIG_ZBOOT_ROM_BSS=0x0 > CONFIG_BINFMT_FLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > # CONFIG_COREDUMP is not set > # CONFIG_SUSPEND is not set > CONFIG_NET=y > diff --git a/arch/arm/configs/stm32_defconfig b/arch/arm/configs/stm32_defconfig > index 551db328009d..71d6bfcf4551 100644 > --- a/arch/arm/configs/stm32_defconfig > +++ b/arch/arm/configs/stm32_defconfig > @@ -28,7 +28,6 @@ CONFIG_ZBOOT_ROM_BSS=0x0 > CONFIG_XIP_KERNEL=y > CONFIG_XIP_PHYS_ADDR=0x08008000 > CONFIG_BINFMT_FLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > # CONFIG_COREDUMP is not set > CONFIG_DEVTMPFS=y > CONFIG_DEVTMPFS_MOUNT=y > diff --git a/arch/arm/configs/vf610m4_defconfig b/arch/arm/configs/vf610m4_defconfig > index a89f035c3b01..70fdbfd83484 100644 > --- a/arch/arm/configs/vf610m4_defconfig > +++ b/arch/arm/configs/vf610m4_defconfig > @@ -18,7 +18,6 @@ CONFIG_XIP_KERNEL=y > CONFIG_XIP_PHYS_ADDR=0x0f000080 > CONFIG_BINFMT_FLAT=y > CONFIG_BINFMT_ZFLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > # CONFIG_SUSPEND is not set > # CONFIG_UEVENT_HELPER is not set > # CONFIG_STANDALONE is not set > diff --git a/arch/sh/configs/rsk7201_defconfig b/arch/sh/configs/rsk7201_defconfig > index e41526120be1..619c18699459 100644 > --- a/arch/sh/configs/rsk7201_defconfig > +++ b/arch/sh/configs/rsk7201_defconfig > @@ -25,7 +25,6 @@ CONFIG_CMDLINE_OVERWRITE=y > CONFIG_CMDLINE="console=ttySC0,115200 earlyprintk=serial ignore_loglevel" > CONFIG_BINFMT_FLAT=y > CONFIG_BINFMT_ZFLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > CONFIG_PM=y > CONFIG_CPU_IDLE=y > # CONFIG_STANDALONE is not set > diff --git a/arch/sh/configs/rsk7203_defconfig b/arch/sh/configs/rsk7203_defconfig > index 6af08fa1ddf8..5a54e2b883f0 100644 > --- a/arch/sh/configs/rsk7203_defconfig > +++ b/arch/sh/configs/rsk7203_defconfig > @@ -30,7 +30,6 @@ CONFIG_CMDLINE_OVERWRITE=y > CONFIG_CMDLINE="console=ttySC0,115200 earlyprintk=serial ignore_loglevel" > CONFIG_BINFMT_FLAT=y > CONFIG_BINFMT_ZFLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > CONFIG_PM=y > CONFIG_CPU_IDLE=y > CONFIG_NET=y > diff --git a/arch/sh/configs/se7206_defconfig b/arch/sh/configs/se7206_defconfig > index 601d062250d1..122216123e63 100644 > --- a/arch/sh/configs/se7206_defconfig > +++ b/arch/sh/configs/se7206_defconfig > @@ -40,7 +40,6 @@ CONFIG_CMDLINE_OVERWRITE=y > CONFIG_CMDLINE="console=ttySC3,115200 ignore_loglevel earlyprintk=serial" > CONFIG_BINFMT_FLAT=y > CONFIG_BINFMT_ZFLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > CONFIG_BINFMT_MISC=y > CONFIG_NET=y > CONFIG_PACKET=y > diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt > index 21c6332fa785..32dff7ba3dda 100644 > --- a/fs/Kconfig.binfmt > +++ b/fs/Kconfig.binfmt > @@ -142,12 +142,6 @@ config BINFMT_ZFLAT > help > Support FLAT format compressed binaries > > -config BINFMT_SHARED_FLAT > - bool "Enable shared FLAT support" > - depends on BINFMT_FLAT > - help > - Support FLAT shared libraries > - > config HAVE_AOUT > def_bool n > > diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c > index 0ad2c7bbaddd..82e4412a9665 100644 > --- a/fs/binfmt_flat.c > +++ b/fs/binfmt_flat.c > @@ -68,11 +68,7 @@ > #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 > +#define MAX_SHARED_LIBS (1) > > #ifdef CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET > #define DATA_START_OFFSET_WORDS (0) > @@ -92,10 +88,6 @@ struct lib_info { > } lib_list[MAX_SHARED_LIBS]; > }; > > -#ifdef CONFIG_BINFMT_SHARED_FLAT > -static int load_flat_shared_library(int id, struct lib_info *p); > -#endif > - > static int load_flat_binary(struct linux_binprm *); > > static struct linux_binfmt flat_format = { > @@ -307,51 +299,18 @@ static int decompress_exec(struct linux_binprm *bprm, loff_t fpos, char *dst, > /****************************************************************************/ > > static unsigned long > -calc_reloc(unsigned long r, struct lib_info *p, int curid, int internalp) > +calc_reloc(unsigned long r, struct lib_info *p) > { > unsigned long addr; > - int id; > unsigned long start_brk; > unsigned long start_data; > unsigned long text_len; > unsigned long start_code; > > -#ifdef CONFIG_BINFMT_SHARED_FLAT > - if (r == 0) > - id = curid; /* Relocs of 0 are always self referring */ > - else { > - id = (r >> 24) & 0xff; /* Find ID for this reloc */ > - r &= 0x00ffffff; /* Trim ID off here */ > - } > - if (id >= MAX_SHARED_LIBS) { > - pr_err("reference 0x%lx to shared library %d", r, id); > - goto failed; > - } > - if (curid != id) { > - if (internalp) { > - pr_err("reloc address 0x%lx not in same module " > - "(%d != %d)", r, curid, id); > - goto failed; > - } else if (!p->lib_list[id].loaded && > - load_flat_shared_library(id, p) < 0) { > - pr_err("failed to load library %d", id); > - goto failed; > - } > - /* Check versioning information (i.e. time stamps) */ > - if (p->lib_list[id].build_date && p->lib_list[curid].build_date && > - p->lib_list[curid].build_date < p->lib_list[id].build_date) { > - pr_err("library %d is younger than %d", id, curid); > - goto failed; > - } > - } > -#else > - id = 0; > -#endif > - > - start_brk = p->lib_list[id].start_brk; > - start_data = p->lib_list[id].start_data; > - start_code = p->lib_list[id].start_code; > - text_len = p->lib_list[id].text_len; > + start_brk = p->lib_list[0].start_brk; > + start_data = p->lib_list[0].start_data; > + start_code = p->lib_list[0].start_code; > + text_len = p->lib_list[0].text_len; > > if (r > start_brk - start_data + text_len) { > pr_err("reloc outside program 0x%lx (0 - 0x%lx/0x%lx)", > @@ -419,7 +378,7 @@ static void old_reloc(unsigned long rl) > /****************************************************************************/ > > static int load_flat_file(struct linux_binprm *bprm, > - struct lib_info *libinfo, int id, unsigned long *extra_stack) > + struct lib_info *libinfo, unsigned long *extra_stack) > { > struct flat_hdr *hdr; > unsigned long textpos, datapos, realdatastart; > @@ -471,14 +430,6 @@ static int load_flat_file(struct linux_binprm *bprm, > goto err; > } > > - /* Don't allow old format executables to use shared libraries */ > - if (rev == OLD_FLAT_VERSION && id != 0) { > - pr_err("shared libraries are not available before rev 0x%lx\n", > - FLAT_VERSION); > - ret = -ENOEXEC; > - goto err; > - } > - > /* > * fix up the flags for the older format, there were all kinds > * of endian hacks, this only works for the simple cases > @@ -529,15 +480,13 @@ static int load_flat_file(struct linux_binprm *bprm, > } > > /* Flush all traces of the currently running executable */ > - if (id == 0) { > - ret = begin_new_exec(bprm); > - if (ret) > - goto err; > + ret = begin_new_exec(bprm); > + if (ret) > + goto err; > > - /* OK, This is the point of no return */ > - set_personality(PER_LINUX_32BIT); > - setup_new_exec(bprm); > - } > + /* OK, This is the point of no return */ > + set_personality(PER_LINUX_32BIT); > + setup_new_exec(bprm); > > /* > * calculate the extra space we need to map in > @@ -717,42 +666,40 @@ static int load_flat_file(struct linux_binprm *bprm, > text_len -= sizeof(struct flat_hdr); /* the real code len */ > > /* The main program needs a little extra setup in the task structure */ > - if (id == 0) { > - current->mm->start_code = start_code; > - current->mm->end_code = end_code; > - current->mm->start_data = datapos; > - current->mm->end_data = datapos + data_len; > - /* > - * set up the brk stuff, uses any slack left in data/bss/stack > - * allocation. We put the brk after the bss (between the bss > - * and stack) like other platforms. > - * Userspace code relies on the stack pointer starting out at > - * an address right at the end of a page. > - */ > - current->mm->start_brk = datapos + data_len + bss_len; > - current->mm->brk = (current->mm->start_brk + 3) & ~3; > + current->mm->start_code = start_code; > + current->mm->end_code = end_code; > + current->mm->start_data = datapos; > + current->mm->end_data = datapos + data_len; > + /* > + * set up the brk stuff, uses any slack left in data/bss/stack > + * allocation. We put the brk after the bss (between the bss > + * and stack) like other platforms. > + * Userspace code relies on the stack pointer starting out at > + * an address right at the end of a page. > + */ > + current->mm->start_brk = datapos + data_len + bss_len; > + current->mm->brk = (current->mm->start_brk + 3) & ~3; > #ifndef CONFIG_MMU > - current->mm->context.end_brk = memp + memp_size - stack_len; > + current->mm->context.end_brk = memp + memp_size - stack_len; > #endif > - } > > if (flags & FLAT_FLAG_KTRACE) { > pr_info("Mapping is %lx, Entry point is %x, data_start is %x\n", > textpos, 0x00ffffff&ntohl(hdr->entry), ntohl(hdr->data_start)); > pr_info("%s %s: TEXT=%lx-%lx DATA=%lx-%lx BSS=%lx-%lx\n", > - id ? "Lib" : "Load", bprm->filename, > + "Load", bprm->filename, > start_code, end_code, datapos, datapos + data_len, > datapos + data_len, (datapos + data_len + bss_len + 3) & ~3); > } > > /* Store the current module values into the global library structure */ > - libinfo->lib_list[id].start_code = start_code; > - libinfo->lib_list[id].start_data = datapos; > - libinfo->lib_list[id].start_brk = datapos + data_len + bss_len; > - libinfo->lib_list[id].text_len = text_len; > - libinfo->lib_list[id].loaded = 1; > - libinfo->lib_list[id].entry = (0x00ffffff & ntohl(hdr->entry)) + textpos; > - libinfo->lib_list[id].build_date = ntohl(hdr->build_date); > + libinfo->lib_list[0].start_code = start_code; > + libinfo->lib_list[0].start_data = datapos; > + libinfo->lib_list[0].start_brk = datapos + data_len + bss_len; > + libinfo->lib_list[0].text_len = text_len; > + libinfo->lib_list[0].loaded = 1; > + libinfo->lib_list[0].entry = (0x00ffffff & ntohl(hdr->entry)) + textpos; > + libinfo->lib_list[0].build_date = ntohl(hdr->build_date); > > /* > * We just load the allocations into some temporary memory to > @@ -774,7 +721,7 @@ static int load_flat_file(struct linux_binprm *bprm, > if (rp_val == 0xffffffff) > break; > if (rp_val) { > - addr = calc_reloc(rp_val, libinfo, id, 0); > + addr = calc_reloc(rp_val, libinfo); > if (addr == RELOC_FAILED) { > ret = -ENOEXEC; > goto err; > @@ -810,7 +757,7 @@ static int load_flat_file(struct linux_binprm *bprm, > return -EFAULT; > relval = ntohl(tmp); > addr = flat_get_relocate_addr(relval); > - rp = (u32 __user *)calc_reloc(addr, libinfo, id, 1); > + rp = (u32 __user *)calc_reloc(addr, libinfo); > if (rp == (u32 __user *)RELOC_FAILED) { > ret = -ENOEXEC; > goto err; > @@ -833,7 +780,7 @@ static int load_flat_file(struct linux_binprm *bprm, > */ > addr = ntohl((__force __be32)addr); > } > - addr = calc_reloc(addr, libinfo, id, 0); > + addr = calc_reloc(addr, libinfo); > if (addr == RELOC_FAILED) { > ret = -ENOEXEC; > goto err; > @@ -861,7 +808,7 @@ static int load_flat_file(struct linux_binprm *bprm, > /* zero the BSS, BRK and stack areas */ > if (clear_user((void __user *)(datapos + data_len), bss_len + > (memp + memp_size - stack_len - /* end brk */ > - libinfo->lib_list[id].start_brk) + /* start brk */ > + libinfo->lib_list[0].start_brk) + /* start brk */ > stack_len)) > return -EFAULT; > > @@ -871,49 +818,6 @@ static int load_flat_file(struct linux_binprm *bprm, > } > > > -/****************************************************************************/ > -#ifdef CONFIG_BINFMT_SHARED_FLAT > - > -/* > - * Load a shared library into memory. The library gets its own data > - * segment (including bss) but not argv/argc/environ. > - */ > - > -static int load_flat_shared_library(int id, struct lib_info *libs) > -{ > - /* > - * This is a fake bprm struct; only the members "buf", "file" and > - * "filename" are actually used. > - */ > - struct linux_binprm bprm; > - int res; > - char buf[16]; > - loff_t pos = 0; > - > - memset(&bprm, 0, sizeof(bprm)); > - > - /* Create the file name */ > - sprintf(buf, "/lib/lib%d.so", id); > - > - /* Open the file up */ > - bprm.filename = buf; > - bprm.file = open_exec(bprm.filename); > - res = PTR_ERR(bprm.file); > - if (IS_ERR(bprm.file)) > - return res; > - > - res = kernel_read(bprm.file, bprm.buf, BINPRM_BUF_SIZE, &pos); > - > - if (res >= 0) > - res = load_flat_file(&bprm, libs, id, NULL); > - > - allow_write_access(bprm.file); > - fput(bprm.file); > - > - return res; > -} > - > -#endif /* CONFIG_BINFMT_SHARED_FLAT */ > /****************************************************************************/ > > /* > @@ -946,7 +850,7 @@ static int load_flat_binary(struct linux_binprm *bprm) > stack_len += (bprm->envc + 1) * sizeof(char *); /* the envp array */ > stack_len = ALIGN(stack_len, FLAT_STACK_ALIGN); > > - res = load_flat_file(bprm, &libinfo, 0, &stack_len); > + res = load_flat_file(bprm, &libinfo, &stack_len); > if (res < 0) > return res; > > @@ -991,20 +895,6 @@ static int load_flat_binary(struct linux_binprm *bprm) > */ > start_addr = libinfo.lib_list[0].entry; > > -#ifdef CONFIG_BINFMT_SHARED_FLAT > - for (i = MAX_SHARED_LIBS-1; i > 0; i--) { > - if (libinfo.lib_list[i].loaded) { > - /* Push previos first to call address */ > - unsigned long __user *sp; > - current->mm->start_stack -= sizeof(unsigned long); > - sp = (unsigned long __user *)current->mm->start_stack; > - if (put_user(start_addr, sp)) > - return -EFAULT; > - start_addr = libinfo.lib_list[i].entry; > - } > - } > -#endif > - > #ifdef FLAT_PLAT_INIT > FLAT_PLAT_INIT(regs); > #endif From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9E88EC433F5 for ; Wed, 20 Apr 2022 16:17:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Mime-Version:Message-ID:To:From:CC:In-Reply-To: Subject:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References:List-Owner; bh=saFGle9zpoPTb4M7/qsfxBBxz4iF5PV1XbowTP9bFVk=; b=CcSpR6WwvH2OfIzDYx5OtE7FhR NidBlM3jjM1T1tnrRvCgNcbttbWfujZ8HwQvC+MMH/TV4MWi9DcXcUwKvVEjJMruJfrNSNeOz/p5s 9S6DGn55DAlI/CDU4QykmrDEal0zhCfmqXS9dEZuoA9g4oergBfcGS8kBSRmk7Oy6Zk/x6REXrmJw RaLFEli0SGO86TZ4oBND6jlMP169cHPIB+92E436jcmiGTQUfMv/oveGyeBPL6EtitwtbI3ieUaau X5ZxRDVjemSipAEERjaZI8EwkTygR3RoUx/5GitosM4r6RKtbqOQ3Rhp4kmQUuBonG1XsyVZR6Vjg rl+HQEOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhD1G-009f05-Bk; Wed, 20 Apr 2022 16:17:30 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhD1B-009eyk-C2 for linux-riscv@lists.infradead.org; Wed, 20 Apr 2022 16:17:28 +0000 Received: by mail-pj1-x102d.google.com with SMTP id mp16-20020a17090b191000b001cb5efbcab6so5372521pjb.4 for ; Wed, 20 Apr 2022 09:17:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20210112.gappssmtp.com; s=20210112; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=R3vTf19oMKRes6BtKfmN/qkhfJtJqpPYYlTIkqXViAo=; b=Sru+C6PlamA8jZ8NcDpobfoMpyR1tI0BLLOYSnhuMjMpMKwPJduh7wgA5KxBWIkND4 tKKndEm9Pa3MJV6a/uGti7n/QQJH7PPCjSLfGNQQEtc4MF8lMAWpq2K3FT1u+5vr38Ln BNE2xStACiq1NRMNOcY3icRI2T6I3qwyXUm2UenfYb0ZPkYR93Gp4eoKgOtac1dGcq9+ DzFyhDjLBEVcdvwClpFM0puu5Ylletc+nvUVSVz6qE3NjHIDs/8ydyqXukGdV6udYKOq iZCso/asGSaq+ghk4ecxZ+ndXBzExktwvz0I4Uy5D3ZiId7+XblIvx2XOwGtj48xPtfS YGOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=R3vTf19oMKRes6BtKfmN/qkhfJtJqpPYYlTIkqXViAo=; b=Jp04O1YUYtDe+/dqysFxFcnYvKopmRpVMdNBV+wuuHRfu5u3iZV6II2cRRNeGyGXbu tsneKLEKuGml54DQr0dXMun6GcszDNHIY1IEmKKlK/y15YV6G8t8eQgieTCpCy05Lyu1 //ENaF5EFkq9A6O0UOo7MGZcLKLuc2cAhOGOrUlmDDXY+Tb283Qka5D6DOQoJPbrz7+s YkPDdQCd8ViDxpzwvHIOkHk6wBviwECe4qCJjohGlAaPdZmj11c00ZKRTI/IQKiHPJd2 aPFHg/eViFTHgRHiGZJ5Yjl48MWvQ4W3BRNOFt+5SaN0ZdXk8o2eXFowUd/fnr/RhGpS cXag== X-Gm-Message-State: AOAM530rwr2Hw5XL0KGI0ULT3WiDDICZ8iA4iwYYUDCySAx40ZDV/724 KUwjOz52A46LuyVUcJ7M7ck9QA== X-Google-Smtp-Source: ABdhPJwthUt+XclRvJbnn9uqQazL2RR/Zs0U933iLuyatysqRD2khuenep71u0U+5+bXwtIAJPJ1rw== X-Received: by 2002:a17:90b:1b06:b0:1d1:6633:5ec2 with SMTP id nu6-20020a17090b1b0600b001d166335ec2mr5402715pjb.103.1650471443508; Wed, 20 Apr 2022 09:17:23 -0700 (PDT) Received: from localhost ([12.3.194.138]) by smtp.gmail.com with ESMTPSA id 16-20020a621410000000b0050aca5f79f5sm3374244pfu.97.2022.04.20.09.17.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 09:17:22 -0700 (PDT) Date: Wed, 20 Apr 2022 09:17:22 -0700 (PDT) X-Google-Original-Date: Wed, 20 Apr 2022 09:16:48 PDT (-0700) Subject: Re: [PATCH] binfmt_flat: Remove shared library support In-Reply-To: <87levzzts4.fsf_-_@email.froward.int.ebiederm.org> CC: keescook@chromium.org, Niklas.Cassel@wdc.com, viro@zeniv.linux.org.uk, Paul Walmsley , aou@eecs.berkeley.edu, vapier@gentoo.org, stable@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-arch@vger.kernel.org, geert@linux-m68k.org, linux-m68k@lists.linux-m68k.org, gerg@linux-m68k.org, linux-arm-kernel@lists.infradead.org, linux-sh@vger.kernel.org, ysato@users.sourceforge.jp, dalias@libc.org From: Palmer Dabbelt To: ebiederm@xmission.com, damien.lemoal@opensource.wdc.com Message-ID: Mime-Version: 1.0 (MHng) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220420_091725_645929_DF3372B1 X-CRM114-Status: GOOD ( 44.56 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Wed, 20 Apr 2022 07:58:03 PDT (-0700), ebiederm@xmission.com wrote: > > In a recent discussion[1] it was reported that the binfmt_flat library > support was only ever used on m68k and even on m68k has not been used > in a very long time. > > The structure of binfmt_flat is different from all of the other binfmt > implementations becasue of this shared library support and it made > life and code review more effort when I refactored the code in fs/exec.c. > > Since in practice the code is dead remove the binfmt_flat shared libarary > support and make maintenance of the code easier. > > [1] https://lkml.kernel.org/r/81788b56-5b15-7308-38c7-c7f2502c4e15@linux-m68k.org > Signed-off-by: "Eric W. Biederman" > --- > > Can the binfmt_flat folks please verify that the shared library support > really isn't used? I don't actually know follow the RISC-V flat support, last I heard it was still sort of just in limbo (some toolchain/userspace bugs th at needed to be sorted out). Damien would know better, though, he's already on the thread. I'll leave it up to him to ack this one, if you were even looking for anything from the RISC-V folks at all (we don't have this in any defconfigs). > Was binfmt_flat being enabled on arm and sh the mistake it looks like? > > arch/arm/configs/lpc18xx_defconfig | 1 - > arch/arm/configs/mps2_defconfig | 1 - > arch/arm/configs/stm32_defconfig | 1 - > arch/arm/configs/vf610m4_defconfig | 1 - > arch/sh/configs/rsk7201_defconfig | 1 - > arch/sh/configs/rsk7203_defconfig | 1 - > arch/sh/configs/se7206_defconfig | 1 - > fs/Kconfig.binfmt | 6 - > fs/binfmt_flat.c | 190 ++++++----------------------- > 9 files changed, 40 insertions(+), 163 deletions(-) > > diff --git a/arch/arm/configs/lpc18xx_defconfig b/arch/arm/configs/lpc18xx_defconfig > index be882ea0eee4..688c9849eec8 100644 > --- a/arch/arm/configs/lpc18xx_defconfig > +++ b/arch/arm/configs/lpc18xx_defconfig > @@ -30,7 +30,6 @@ CONFIG_ARM_APPENDED_DTB=y > # CONFIG_BLK_DEV_BSG is not set > CONFIG_BINFMT_FLAT=y > CONFIG_BINFMT_ZFLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > # CONFIG_COREDUMP is not set > CONFIG_NET=y > CONFIG_PACKET=y > diff --git a/arch/arm/configs/mps2_defconfig b/arch/arm/configs/mps2_defconfig > index 89f4a6ff30bd..c1e98e33a348 100644 > --- a/arch/arm/configs/mps2_defconfig > +++ b/arch/arm/configs/mps2_defconfig > @@ -23,7 +23,6 @@ CONFIG_PREEMPT_VOLUNTARY=y > CONFIG_ZBOOT_ROM_TEXT=0x0 > CONFIG_ZBOOT_ROM_BSS=0x0 > CONFIG_BINFMT_FLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > # CONFIG_COREDUMP is not set > # CONFIG_SUSPEND is not set > CONFIG_NET=y > diff --git a/arch/arm/configs/stm32_defconfig b/arch/arm/configs/stm32_defconfig > index 551db328009d..71d6bfcf4551 100644 > --- a/arch/arm/configs/stm32_defconfig > +++ b/arch/arm/configs/stm32_defconfig > @@ -28,7 +28,6 @@ CONFIG_ZBOOT_ROM_BSS=0x0 > CONFIG_XIP_KERNEL=y > CONFIG_XIP_PHYS_ADDR=0x08008000 > CONFIG_BINFMT_FLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > # CONFIG_COREDUMP is not set > CONFIG_DEVTMPFS=y > CONFIG_DEVTMPFS_MOUNT=y > diff --git a/arch/arm/configs/vf610m4_defconfig b/arch/arm/configs/vf610m4_defconfig > index a89f035c3b01..70fdbfd83484 100644 > --- a/arch/arm/configs/vf610m4_defconfig > +++ b/arch/arm/configs/vf610m4_defconfig > @@ -18,7 +18,6 @@ CONFIG_XIP_KERNEL=y > CONFIG_XIP_PHYS_ADDR=0x0f000080 > CONFIG_BINFMT_FLAT=y > CONFIG_BINFMT_ZFLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > # CONFIG_SUSPEND is not set > # CONFIG_UEVENT_HELPER is not set > # CONFIG_STANDALONE is not set > diff --git a/arch/sh/configs/rsk7201_defconfig b/arch/sh/configs/rsk7201_defconfig > index e41526120be1..619c18699459 100644 > --- a/arch/sh/configs/rsk7201_defconfig > +++ b/arch/sh/configs/rsk7201_defconfig > @@ -25,7 +25,6 @@ CONFIG_CMDLINE_OVERWRITE=y > CONFIG_CMDLINE="console=ttySC0,115200 earlyprintk=serial ignore_loglevel" > CONFIG_BINFMT_FLAT=y > CONFIG_BINFMT_ZFLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > CONFIG_PM=y > CONFIG_CPU_IDLE=y > # CONFIG_STANDALONE is not set > diff --git a/arch/sh/configs/rsk7203_defconfig b/arch/sh/configs/rsk7203_defconfig > index 6af08fa1ddf8..5a54e2b883f0 100644 > --- a/arch/sh/configs/rsk7203_defconfig > +++ b/arch/sh/configs/rsk7203_defconfig > @@ -30,7 +30,6 @@ CONFIG_CMDLINE_OVERWRITE=y > CONFIG_CMDLINE="console=ttySC0,115200 earlyprintk=serial ignore_loglevel" > CONFIG_BINFMT_FLAT=y > CONFIG_BINFMT_ZFLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > CONFIG_PM=y > CONFIG_CPU_IDLE=y > CONFIG_NET=y > diff --git a/arch/sh/configs/se7206_defconfig b/arch/sh/configs/se7206_defconfig > index 601d062250d1..122216123e63 100644 > --- a/arch/sh/configs/se7206_defconfig > +++ b/arch/sh/configs/se7206_defconfig > @@ -40,7 +40,6 @@ CONFIG_CMDLINE_OVERWRITE=y > CONFIG_CMDLINE="console=ttySC3,115200 ignore_loglevel earlyprintk=serial" > CONFIG_BINFMT_FLAT=y > CONFIG_BINFMT_ZFLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > CONFIG_BINFMT_MISC=y > CONFIG_NET=y > CONFIG_PACKET=y > diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt > index 21c6332fa785..32dff7ba3dda 100644 > --- a/fs/Kconfig.binfmt > +++ b/fs/Kconfig.binfmt > @@ -142,12 +142,6 @@ config BINFMT_ZFLAT > help > Support FLAT format compressed binaries > > -config BINFMT_SHARED_FLAT > - bool "Enable shared FLAT support" > - depends on BINFMT_FLAT > - help > - Support FLAT shared libraries > - > config HAVE_AOUT > def_bool n > > diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c > index 0ad2c7bbaddd..82e4412a9665 100644 > --- a/fs/binfmt_flat.c > +++ b/fs/binfmt_flat.c > @@ -68,11 +68,7 @@ > #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 > +#define MAX_SHARED_LIBS (1) > > #ifdef CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET > #define DATA_START_OFFSET_WORDS (0) > @@ -92,10 +88,6 @@ struct lib_info { > } lib_list[MAX_SHARED_LIBS]; > }; > > -#ifdef CONFIG_BINFMT_SHARED_FLAT > -static int load_flat_shared_library(int id, struct lib_info *p); > -#endif > - > static int load_flat_binary(struct linux_binprm *); > > static struct linux_binfmt flat_format = { > @@ -307,51 +299,18 @@ static int decompress_exec(struct linux_binprm *bprm, loff_t fpos, char *dst, > /****************************************************************************/ > > static unsigned long > -calc_reloc(unsigned long r, struct lib_info *p, int curid, int internalp) > +calc_reloc(unsigned long r, struct lib_info *p) > { > unsigned long addr; > - int id; > unsigned long start_brk; > unsigned long start_data; > unsigned long text_len; > unsigned long start_code; > > -#ifdef CONFIG_BINFMT_SHARED_FLAT > - if (r == 0) > - id = curid; /* Relocs of 0 are always self referring */ > - else { > - id = (r >> 24) & 0xff; /* Find ID for this reloc */ > - r &= 0x00ffffff; /* Trim ID off here */ > - } > - if (id >= MAX_SHARED_LIBS) { > - pr_err("reference 0x%lx to shared library %d", r, id); > - goto failed; > - } > - if (curid != id) { > - if (internalp) { > - pr_err("reloc address 0x%lx not in same module " > - "(%d != %d)", r, curid, id); > - goto failed; > - } else if (!p->lib_list[id].loaded && > - load_flat_shared_library(id, p) < 0) { > - pr_err("failed to load library %d", id); > - goto failed; > - } > - /* Check versioning information (i.e. time stamps) */ > - if (p->lib_list[id].build_date && p->lib_list[curid].build_date && > - p->lib_list[curid].build_date < p->lib_list[id].build_date) { > - pr_err("library %d is younger than %d", id, curid); > - goto failed; > - } > - } > -#else > - id = 0; > -#endif > - > - start_brk = p->lib_list[id].start_brk; > - start_data = p->lib_list[id].start_data; > - start_code = p->lib_list[id].start_code; > - text_len = p->lib_list[id].text_len; > + start_brk = p->lib_list[0].start_brk; > + start_data = p->lib_list[0].start_data; > + start_code = p->lib_list[0].start_code; > + text_len = p->lib_list[0].text_len; > > if (r > start_brk - start_data + text_len) { > pr_err("reloc outside program 0x%lx (0 - 0x%lx/0x%lx)", > @@ -419,7 +378,7 @@ static void old_reloc(unsigned long rl) > /****************************************************************************/ > > static int load_flat_file(struct linux_binprm *bprm, > - struct lib_info *libinfo, int id, unsigned long *extra_stack) > + struct lib_info *libinfo, unsigned long *extra_stack) > { > struct flat_hdr *hdr; > unsigned long textpos, datapos, realdatastart; > @@ -471,14 +430,6 @@ static int load_flat_file(struct linux_binprm *bprm, > goto err; > } > > - /* Don't allow old format executables to use shared libraries */ > - if (rev == OLD_FLAT_VERSION && id != 0) { > - pr_err("shared libraries are not available before rev 0x%lx\n", > - FLAT_VERSION); > - ret = -ENOEXEC; > - goto err; > - } > - > /* > * fix up the flags for the older format, there were all kinds > * of endian hacks, this only works for the simple cases > @@ -529,15 +480,13 @@ static int load_flat_file(struct linux_binprm *bprm, > } > > /* Flush all traces of the currently running executable */ > - if (id == 0) { > - ret = begin_new_exec(bprm); > - if (ret) > - goto err; > + ret = begin_new_exec(bprm); > + if (ret) > + goto err; > > - /* OK, This is the point of no return */ > - set_personality(PER_LINUX_32BIT); > - setup_new_exec(bprm); > - } > + /* OK, This is the point of no return */ > + set_personality(PER_LINUX_32BIT); > + setup_new_exec(bprm); > > /* > * calculate the extra space we need to map in > @@ -717,42 +666,40 @@ static int load_flat_file(struct linux_binprm *bprm, > text_len -= sizeof(struct flat_hdr); /* the real code len */ > > /* The main program needs a little extra setup in the task structure */ > - if (id == 0) { > - current->mm->start_code = start_code; > - current->mm->end_code = end_code; > - current->mm->start_data = datapos; > - current->mm->end_data = datapos + data_len; > - /* > - * set up the brk stuff, uses any slack left in data/bss/stack > - * allocation. We put the brk after the bss (between the bss > - * and stack) like other platforms. > - * Userspace code relies on the stack pointer starting out at > - * an address right at the end of a page. > - */ > - current->mm->start_brk = datapos + data_len + bss_len; > - current->mm->brk = (current->mm->start_brk + 3) & ~3; > + current->mm->start_code = start_code; > + current->mm->end_code = end_code; > + current->mm->start_data = datapos; > + current->mm->end_data = datapos + data_len; > + /* > + * set up the brk stuff, uses any slack left in data/bss/stack > + * allocation. We put the brk after the bss (between the bss > + * and stack) like other platforms. > + * Userspace code relies on the stack pointer starting out at > + * an address right at the end of a page. > + */ > + current->mm->start_brk = datapos + data_len + bss_len; > + current->mm->brk = (current->mm->start_brk + 3) & ~3; > #ifndef CONFIG_MMU > - current->mm->context.end_brk = memp + memp_size - stack_len; > + current->mm->context.end_brk = memp + memp_size - stack_len; > #endif > - } > > if (flags & FLAT_FLAG_KTRACE) { > pr_info("Mapping is %lx, Entry point is %x, data_start is %x\n", > textpos, 0x00ffffff&ntohl(hdr->entry), ntohl(hdr->data_start)); > pr_info("%s %s: TEXT=%lx-%lx DATA=%lx-%lx BSS=%lx-%lx\n", > - id ? "Lib" : "Load", bprm->filename, > + "Load", bprm->filename, > start_code, end_code, datapos, datapos + data_len, > datapos + data_len, (datapos + data_len + bss_len + 3) & ~3); > } > > /* Store the current module values into the global library structure */ > - libinfo->lib_list[id].start_code = start_code; > - libinfo->lib_list[id].start_data = datapos; > - libinfo->lib_list[id].start_brk = datapos + data_len + bss_len; > - libinfo->lib_list[id].text_len = text_len; > - libinfo->lib_list[id].loaded = 1; > - libinfo->lib_list[id].entry = (0x00ffffff & ntohl(hdr->entry)) + textpos; > - libinfo->lib_list[id].build_date = ntohl(hdr->build_date); > + libinfo->lib_list[0].start_code = start_code; > + libinfo->lib_list[0].start_data = datapos; > + libinfo->lib_list[0].start_brk = datapos + data_len + bss_len; > + libinfo->lib_list[0].text_len = text_len; > + libinfo->lib_list[0].loaded = 1; > + libinfo->lib_list[0].entry = (0x00ffffff & ntohl(hdr->entry)) + textpos; > + libinfo->lib_list[0].build_date = ntohl(hdr->build_date); > > /* > * We just load the allocations into some temporary memory to > @@ -774,7 +721,7 @@ static int load_flat_file(struct linux_binprm *bprm, > if (rp_val == 0xffffffff) > break; > if (rp_val) { > - addr = calc_reloc(rp_val, libinfo, id, 0); > + addr = calc_reloc(rp_val, libinfo); > if (addr == RELOC_FAILED) { > ret = -ENOEXEC; > goto err; > @@ -810,7 +757,7 @@ static int load_flat_file(struct linux_binprm *bprm, > return -EFAULT; > relval = ntohl(tmp); > addr = flat_get_relocate_addr(relval); > - rp = (u32 __user *)calc_reloc(addr, libinfo, id, 1); > + rp = (u32 __user *)calc_reloc(addr, libinfo); > if (rp == (u32 __user *)RELOC_FAILED) { > ret = -ENOEXEC; > goto err; > @@ -833,7 +780,7 @@ static int load_flat_file(struct linux_binprm *bprm, > */ > addr = ntohl((__force __be32)addr); > } > - addr = calc_reloc(addr, libinfo, id, 0); > + addr = calc_reloc(addr, libinfo); > if (addr == RELOC_FAILED) { > ret = -ENOEXEC; > goto err; > @@ -861,7 +808,7 @@ static int load_flat_file(struct linux_binprm *bprm, > /* zero the BSS, BRK and stack areas */ > if (clear_user((void __user *)(datapos + data_len), bss_len + > (memp + memp_size - stack_len - /* end brk */ > - libinfo->lib_list[id].start_brk) + /* start brk */ > + libinfo->lib_list[0].start_brk) + /* start brk */ > stack_len)) > return -EFAULT; > > @@ -871,49 +818,6 @@ static int load_flat_file(struct linux_binprm *bprm, > } > > > -/****************************************************************************/ > -#ifdef CONFIG_BINFMT_SHARED_FLAT > - > -/* > - * Load a shared library into memory. The library gets its own data > - * segment (including bss) but not argv/argc/environ. > - */ > - > -static int load_flat_shared_library(int id, struct lib_info *libs) > -{ > - /* > - * This is a fake bprm struct; only the members "buf", "file" and > - * "filename" are actually used. > - */ > - struct linux_binprm bprm; > - int res; > - char buf[16]; > - loff_t pos = 0; > - > - memset(&bprm, 0, sizeof(bprm)); > - > - /* Create the file name */ > - sprintf(buf, "/lib/lib%d.so", id); > - > - /* Open the file up */ > - bprm.filename = buf; > - bprm.file = open_exec(bprm.filename); > - res = PTR_ERR(bprm.file); > - if (IS_ERR(bprm.file)) > - return res; > - > - res = kernel_read(bprm.file, bprm.buf, BINPRM_BUF_SIZE, &pos); > - > - if (res >= 0) > - res = load_flat_file(&bprm, libs, id, NULL); > - > - allow_write_access(bprm.file); > - fput(bprm.file); > - > - return res; > -} > - > -#endif /* CONFIG_BINFMT_SHARED_FLAT */ > /****************************************************************************/ > > /* > @@ -946,7 +850,7 @@ static int load_flat_binary(struct linux_binprm *bprm) > stack_len += (bprm->envc + 1) * sizeof(char *); /* the envp array */ > stack_len = ALIGN(stack_len, FLAT_STACK_ALIGN); > > - res = load_flat_file(bprm, &libinfo, 0, &stack_len); > + res = load_flat_file(bprm, &libinfo, &stack_len); > if (res < 0) > return res; > > @@ -991,20 +895,6 @@ static int load_flat_binary(struct linux_binprm *bprm) > */ > start_addr = libinfo.lib_list[0].entry; > > -#ifdef CONFIG_BINFMT_SHARED_FLAT > - for (i = MAX_SHARED_LIBS-1; i > 0; i--) { > - if (libinfo.lib_list[i].loaded) { > - /* Push previos first to call address */ > - unsigned long __user *sp; > - current->mm->start_stack -= sizeof(unsigned long); > - sp = (unsigned long __user *)current->mm->start_stack; > - if (put_user(start_addr, sp)) > - return -EFAULT; > - start_addr = libinfo.lib_list[i].entry; > - } > - } > -#endif > - > #ifdef FLAT_PLAT_INIT > FLAT_PLAT_INIT(regs); > #endif _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 31AF4C433F5 for ; Wed, 20 Apr 2022 16:18:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Mime-Version:Message-ID:To:From:CC:In-Reply-To: Subject:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References:List-Owner; bh=e2xI1+dot9XGlgNUib2Q/ymO4D8l+kG7Wr/sz3w2zcg=; b=QsGbX+2aBtvBc+x+L67OX4w5hV ELdgu9wB4lj58/LWxD89lvPYI2G8enm5RkvrbAYJSK2nEGUa2/phnlZX92/UlUEFpGLWjuHRxw+Fr 4/DtzVs+UQbIgIW3hJAEPsjUpWI3AfrqziYFKP+gWUMhzBFQJjzJC+TQ/g9Wv1Dd3yBi6kY0TXQZE BCXjlWlsTjk3alvHe6vYTc7DNbc6F5UVYN7sRge48jF3DJbxAgYOPQ065C4CnSGCHrdLbEnmHm6wX 3J5geKxR9Lt7B6uH1CT7VlNgGKQ/9D4MaRsxP/0p0VbfdsQDgxEalweTjVch3rgJgAbkPpUi5pE4x pS/B/18Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhD1I-009f0Q-Co; Wed, 20 Apr 2022 16:17:32 +0000 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhD1C-009eyl-9X for linux-arm-kernel@lists.infradead.org; Wed, 20 Apr 2022 16:17:29 +0000 Received: by mail-pj1-x1029.google.com with SMTP id i24-20020a17090adc1800b001cd5529465aso5423790pjv.0 for ; Wed, 20 Apr 2022 09:17:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20210112.gappssmtp.com; s=20210112; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=R3vTf19oMKRes6BtKfmN/qkhfJtJqpPYYlTIkqXViAo=; b=Sru+C6PlamA8jZ8NcDpobfoMpyR1tI0BLLOYSnhuMjMpMKwPJduh7wgA5KxBWIkND4 tKKndEm9Pa3MJV6a/uGti7n/QQJH7PPCjSLfGNQQEtc4MF8lMAWpq2K3FT1u+5vr38Ln BNE2xStACiq1NRMNOcY3icRI2T6I3qwyXUm2UenfYb0ZPkYR93Gp4eoKgOtac1dGcq9+ DzFyhDjLBEVcdvwClpFM0puu5Ylletc+nvUVSVz6qE3NjHIDs/8ydyqXukGdV6udYKOq iZCso/asGSaq+ghk4ecxZ+ndXBzExktwvz0I4Uy5D3ZiId7+XblIvx2XOwGtj48xPtfS YGOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=R3vTf19oMKRes6BtKfmN/qkhfJtJqpPYYlTIkqXViAo=; b=uKcOaB2JLfER7b8JSl5eOEwjkGEGJtF8M+q95uGN44bDpcvtDJNynhSkT9M4Dt112n iGrHfuuh+6nCT8OnvTlhlmvWktuXwav+8M15UQX86zfBOVIkt7QENkUgvmywe4UBWCDH J9tW+oS9VgXr9LICg4+/HE2JxzCdnzKXFbzRbp8I/tBL514QYizLoWqeFL+CSmQiIwiZ sTGWk7WQk6rtaFXK0SjlRAl3FTN5/XTHQCkOgfEK9VuoYsbf3XdFIqpNc83oRUW5/rK6 OO9PkUgBnXKdM+SwHWkS2RoW+E3Uk9XKFLmdk0OT1e6T4tWbAFPoZKu/mQX0VFj5L5/Y H+yQ== X-Gm-Message-State: AOAM533wmHzfggxZnWPRxE82Ax8HPZK8uj2WCZMGorh796izajGWl/sa avmS9SnE+8FTYpOkpMS0+jt80A== X-Google-Smtp-Source: ABdhPJwthUt+XclRvJbnn9uqQazL2RR/Zs0U933iLuyatysqRD2khuenep71u0U+5+bXwtIAJPJ1rw== X-Received: by 2002:a17:90b:1b06:b0:1d1:6633:5ec2 with SMTP id nu6-20020a17090b1b0600b001d166335ec2mr5402715pjb.103.1650471443508; Wed, 20 Apr 2022 09:17:23 -0700 (PDT) Received: from localhost ([12.3.194.138]) by smtp.gmail.com with ESMTPSA id 16-20020a621410000000b0050aca5f79f5sm3374244pfu.97.2022.04.20.09.17.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 09:17:22 -0700 (PDT) Date: Wed, 20 Apr 2022 09:17:22 -0700 (PDT) X-Google-Original-Date: Wed, 20 Apr 2022 09:16:48 PDT (-0700) Subject: Re: [PATCH] binfmt_flat: Remove shared library support In-Reply-To: <87levzzts4.fsf_-_@email.froward.int.ebiederm.org> CC: keescook@chromium.org, Niklas.Cassel@wdc.com, viro@zeniv.linux.org.uk, Paul Walmsley , aou@eecs.berkeley.edu, vapier@gentoo.org, stable@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-arch@vger.kernel.org, geert@linux-m68k.org, linux-m68k@lists.linux-m68k.org, gerg@linux-m68k.org, linux-arm-kernel@lists.infradead.org, linux-sh@vger.kernel.org, ysato@users.sourceforge.jp, dalias@libc.org From: Palmer Dabbelt To: ebiederm@xmission.com, damien.lemoal@opensource.wdc.com Message-ID: Mime-Version: 1.0 (MHng) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220420_091726_372761_748C8F72 X-CRM114-Status: GOOD ( 46.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 20 Apr 2022 07:58:03 PDT (-0700), ebiederm@xmission.com wrote: > > In a recent discussion[1] it was reported that the binfmt_flat library > support was only ever used on m68k and even on m68k has not been used > in a very long time. > > The structure of binfmt_flat is different from all of the other binfmt > implementations becasue of this shared library support and it made > life and code review more effort when I refactored the code in fs/exec.c. > > Since in practice the code is dead remove the binfmt_flat shared libarary > support and make maintenance of the code easier. > > [1] https://lkml.kernel.org/r/81788b56-5b15-7308-38c7-c7f2502c4e15@linux-m68k.org > Signed-off-by: "Eric W. Biederman" > --- > > Can the binfmt_flat folks please verify that the shared library support > really isn't used? I don't actually know follow the RISC-V flat support, last I heard it was still sort of just in limbo (some toolchain/userspace bugs th at needed to be sorted out). Damien would know better, though, he's already on the thread. I'll leave it up to him to ack this one, if you were even looking for anything from the RISC-V folks at all (we don't have this in any defconfigs). > Was binfmt_flat being enabled on arm and sh the mistake it looks like? > > arch/arm/configs/lpc18xx_defconfig | 1 - > arch/arm/configs/mps2_defconfig | 1 - > arch/arm/configs/stm32_defconfig | 1 - > arch/arm/configs/vf610m4_defconfig | 1 - > arch/sh/configs/rsk7201_defconfig | 1 - > arch/sh/configs/rsk7203_defconfig | 1 - > arch/sh/configs/se7206_defconfig | 1 - > fs/Kconfig.binfmt | 6 - > fs/binfmt_flat.c | 190 ++++++----------------------- > 9 files changed, 40 insertions(+), 163 deletions(-) > > diff --git a/arch/arm/configs/lpc18xx_defconfig b/arch/arm/configs/lpc18xx_defconfig > index be882ea0eee4..688c9849eec8 100644 > --- a/arch/arm/configs/lpc18xx_defconfig > +++ b/arch/arm/configs/lpc18xx_defconfig > @@ -30,7 +30,6 @@ CONFIG_ARM_APPENDED_DTB=y > # CONFIG_BLK_DEV_BSG is not set > CONFIG_BINFMT_FLAT=y > CONFIG_BINFMT_ZFLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > # CONFIG_COREDUMP is not set > CONFIG_NET=y > CONFIG_PACKET=y > diff --git a/arch/arm/configs/mps2_defconfig b/arch/arm/configs/mps2_defconfig > index 89f4a6ff30bd..c1e98e33a348 100644 > --- a/arch/arm/configs/mps2_defconfig > +++ b/arch/arm/configs/mps2_defconfig > @@ -23,7 +23,6 @@ CONFIG_PREEMPT_VOLUNTARY=y > CONFIG_ZBOOT_ROM_TEXT=0x0 > CONFIG_ZBOOT_ROM_BSS=0x0 > CONFIG_BINFMT_FLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > # CONFIG_COREDUMP is not set > # CONFIG_SUSPEND is not set > CONFIG_NET=y > diff --git a/arch/arm/configs/stm32_defconfig b/arch/arm/configs/stm32_defconfig > index 551db328009d..71d6bfcf4551 100644 > --- a/arch/arm/configs/stm32_defconfig > +++ b/arch/arm/configs/stm32_defconfig > @@ -28,7 +28,6 @@ CONFIG_ZBOOT_ROM_BSS=0x0 > CONFIG_XIP_KERNEL=y > CONFIG_XIP_PHYS_ADDR=0x08008000 > CONFIG_BINFMT_FLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > # CONFIG_COREDUMP is not set > CONFIG_DEVTMPFS=y > CONFIG_DEVTMPFS_MOUNT=y > diff --git a/arch/arm/configs/vf610m4_defconfig b/arch/arm/configs/vf610m4_defconfig > index a89f035c3b01..70fdbfd83484 100644 > --- a/arch/arm/configs/vf610m4_defconfig > +++ b/arch/arm/configs/vf610m4_defconfig > @@ -18,7 +18,6 @@ CONFIG_XIP_KERNEL=y > CONFIG_XIP_PHYS_ADDR=0x0f000080 > CONFIG_BINFMT_FLAT=y > CONFIG_BINFMT_ZFLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > # CONFIG_SUSPEND is not set > # CONFIG_UEVENT_HELPER is not set > # CONFIG_STANDALONE is not set > diff --git a/arch/sh/configs/rsk7201_defconfig b/arch/sh/configs/rsk7201_defconfig > index e41526120be1..619c18699459 100644 > --- a/arch/sh/configs/rsk7201_defconfig > +++ b/arch/sh/configs/rsk7201_defconfig > @@ -25,7 +25,6 @@ CONFIG_CMDLINE_OVERWRITE=y > CONFIG_CMDLINE="console=ttySC0,115200 earlyprintk=serial ignore_loglevel" > CONFIG_BINFMT_FLAT=y > CONFIG_BINFMT_ZFLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > CONFIG_PM=y > CONFIG_CPU_IDLE=y > # CONFIG_STANDALONE is not set > diff --git a/arch/sh/configs/rsk7203_defconfig b/arch/sh/configs/rsk7203_defconfig > index 6af08fa1ddf8..5a54e2b883f0 100644 > --- a/arch/sh/configs/rsk7203_defconfig > +++ b/arch/sh/configs/rsk7203_defconfig > @@ -30,7 +30,6 @@ CONFIG_CMDLINE_OVERWRITE=y > CONFIG_CMDLINE="console=ttySC0,115200 earlyprintk=serial ignore_loglevel" > CONFIG_BINFMT_FLAT=y > CONFIG_BINFMT_ZFLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > CONFIG_PM=y > CONFIG_CPU_IDLE=y > CONFIG_NET=y > diff --git a/arch/sh/configs/se7206_defconfig b/arch/sh/configs/se7206_defconfig > index 601d062250d1..122216123e63 100644 > --- a/arch/sh/configs/se7206_defconfig > +++ b/arch/sh/configs/se7206_defconfig > @@ -40,7 +40,6 @@ CONFIG_CMDLINE_OVERWRITE=y > CONFIG_CMDLINE="console=ttySC3,115200 ignore_loglevel earlyprintk=serial" > CONFIG_BINFMT_FLAT=y > CONFIG_BINFMT_ZFLAT=y > -CONFIG_BINFMT_SHARED_FLAT=y > CONFIG_BINFMT_MISC=y > CONFIG_NET=y > CONFIG_PACKET=y > diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt > index 21c6332fa785..32dff7ba3dda 100644 > --- a/fs/Kconfig.binfmt > +++ b/fs/Kconfig.binfmt > @@ -142,12 +142,6 @@ config BINFMT_ZFLAT > help > Support FLAT format compressed binaries > > -config BINFMT_SHARED_FLAT > - bool "Enable shared FLAT support" > - depends on BINFMT_FLAT > - help > - Support FLAT shared libraries > - > config HAVE_AOUT > def_bool n > > diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c > index 0ad2c7bbaddd..82e4412a9665 100644 > --- a/fs/binfmt_flat.c > +++ b/fs/binfmt_flat.c > @@ -68,11 +68,7 @@ > #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 > +#define MAX_SHARED_LIBS (1) > > #ifdef CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET > #define DATA_START_OFFSET_WORDS (0) > @@ -92,10 +88,6 @@ struct lib_info { > } lib_list[MAX_SHARED_LIBS]; > }; > > -#ifdef CONFIG_BINFMT_SHARED_FLAT > -static int load_flat_shared_library(int id, struct lib_info *p); > -#endif > - > static int load_flat_binary(struct linux_binprm *); > > static struct linux_binfmt flat_format = { > @@ -307,51 +299,18 @@ static int decompress_exec(struct linux_binprm *bprm, loff_t fpos, char *dst, > /****************************************************************************/ > > static unsigned long > -calc_reloc(unsigned long r, struct lib_info *p, int curid, int internalp) > +calc_reloc(unsigned long r, struct lib_info *p) > { > unsigned long addr; > - int id; > unsigned long start_brk; > unsigned long start_data; > unsigned long text_len; > unsigned long start_code; > > -#ifdef CONFIG_BINFMT_SHARED_FLAT > - if (r == 0) > - id = curid; /* Relocs of 0 are always self referring */ > - else { > - id = (r >> 24) & 0xff; /* Find ID for this reloc */ > - r &= 0x00ffffff; /* Trim ID off here */ > - } > - if (id >= MAX_SHARED_LIBS) { > - pr_err("reference 0x%lx to shared library %d", r, id); > - goto failed; > - } > - if (curid != id) { > - if (internalp) { > - pr_err("reloc address 0x%lx not in same module " > - "(%d != %d)", r, curid, id); > - goto failed; > - } else if (!p->lib_list[id].loaded && > - load_flat_shared_library(id, p) < 0) { > - pr_err("failed to load library %d", id); > - goto failed; > - } > - /* Check versioning information (i.e. time stamps) */ > - if (p->lib_list[id].build_date && p->lib_list[curid].build_date && > - p->lib_list[curid].build_date < p->lib_list[id].build_date) { > - pr_err("library %d is younger than %d", id, curid); > - goto failed; > - } > - } > -#else > - id = 0; > -#endif > - > - start_brk = p->lib_list[id].start_brk; > - start_data = p->lib_list[id].start_data; > - start_code = p->lib_list[id].start_code; > - text_len = p->lib_list[id].text_len; > + start_brk = p->lib_list[0].start_brk; > + start_data = p->lib_list[0].start_data; > + start_code = p->lib_list[0].start_code; > + text_len = p->lib_list[0].text_len; > > if (r > start_brk - start_data + text_len) { > pr_err("reloc outside program 0x%lx (0 - 0x%lx/0x%lx)", > @@ -419,7 +378,7 @@ static void old_reloc(unsigned long rl) > /****************************************************************************/ > > static int load_flat_file(struct linux_binprm *bprm, > - struct lib_info *libinfo, int id, unsigned long *extra_stack) > + struct lib_info *libinfo, unsigned long *extra_stack) > { > struct flat_hdr *hdr; > unsigned long textpos, datapos, realdatastart; > @@ -471,14 +430,6 @@ static int load_flat_file(struct linux_binprm *bprm, > goto err; > } > > - /* Don't allow old format executables to use shared libraries */ > - if (rev == OLD_FLAT_VERSION && id != 0) { > - pr_err("shared libraries are not available before rev 0x%lx\n", > - FLAT_VERSION); > - ret = -ENOEXEC; > - goto err; > - } > - > /* > * fix up the flags for the older format, there were all kinds > * of endian hacks, this only works for the simple cases > @@ -529,15 +480,13 @@ static int load_flat_file(struct linux_binprm *bprm, > } > > /* Flush all traces of the currently running executable */ > - if (id == 0) { > - ret = begin_new_exec(bprm); > - if (ret) > - goto err; > + ret = begin_new_exec(bprm); > + if (ret) > + goto err; > > - /* OK, This is the point of no return */ > - set_personality(PER_LINUX_32BIT); > - setup_new_exec(bprm); > - } > + /* OK, This is the point of no return */ > + set_personality(PER_LINUX_32BIT); > + setup_new_exec(bprm); > > /* > * calculate the extra space we need to map in > @@ -717,42 +666,40 @@ static int load_flat_file(struct linux_binprm *bprm, > text_len -= sizeof(struct flat_hdr); /* the real code len */ > > /* The main program needs a little extra setup in the task structure */ > - if (id == 0) { > - current->mm->start_code = start_code; > - current->mm->end_code = end_code; > - current->mm->start_data = datapos; > - current->mm->end_data = datapos + data_len; > - /* > - * set up the brk stuff, uses any slack left in data/bss/stack > - * allocation. We put the brk after the bss (between the bss > - * and stack) like other platforms. > - * Userspace code relies on the stack pointer starting out at > - * an address right at the end of a page. > - */ > - current->mm->start_brk = datapos + data_len + bss_len; > - current->mm->brk = (current->mm->start_brk + 3) & ~3; > + current->mm->start_code = start_code; > + current->mm->end_code = end_code; > + current->mm->start_data = datapos; > + current->mm->end_data = datapos + data_len; > + /* > + * set up the brk stuff, uses any slack left in data/bss/stack > + * allocation. We put the brk after the bss (between the bss > + * and stack) like other platforms. > + * Userspace code relies on the stack pointer starting out at > + * an address right at the end of a page. > + */ > + current->mm->start_brk = datapos + data_len + bss_len; > + current->mm->brk = (current->mm->start_brk + 3) & ~3; > #ifndef CONFIG_MMU > - current->mm->context.end_brk = memp + memp_size - stack_len; > + current->mm->context.end_brk = memp + memp_size - stack_len; > #endif > - } > > if (flags & FLAT_FLAG_KTRACE) { > pr_info("Mapping is %lx, Entry point is %x, data_start is %x\n", > textpos, 0x00ffffff&ntohl(hdr->entry), ntohl(hdr->data_start)); > pr_info("%s %s: TEXT=%lx-%lx DATA=%lx-%lx BSS=%lx-%lx\n", > - id ? "Lib" : "Load", bprm->filename, > + "Load", bprm->filename, > start_code, end_code, datapos, datapos + data_len, > datapos + data_len, (datapos + data_len + bss_len + 3) & ~3); > } > > /* Store the current module values into the global library structure */ > - libinfo->lib_list[id].start_code = start_code; > - libinfo->lib_list[id].start_data = datapos; > - libinfo->lib_list[id].start_brk = datapos + data_len + bss_len; > - libinfo->lib_list[id].text_len = text_len; > - libinfo->lib_list[id].loaded = 1; > - libinfo->lib_list[id].entry = (0x00ffffff & ntohl(hdr->entry)) + textpos; > - libinfo->lib_list[id].build_date = ntohl(hdr->build_date); > + libinfo->lib_list[0].start_code = start_code; > + libinfo->lib_list[0].start_data = datapos; > + libinfo->lib_list[0].start_brk = datapos + data_len + bss_len; > + libinfo->lib_list[0].text_len = text_len; > + libinfo->lib_list[0].loaded = 1; > + libinfo->lib_list[0].entry = (0x00ffffff & ntohl(hdr->entry)) + textpos; > + libinfo->lib_list[0].build_date = ntohl(hdr->build_date); > > /* > * We just load the allocations into some temporary memory to > @@ -774,7 +721,7 @@ static int load_flat_file(struct linux_binprm *bprm, > if (rp_val == 0xffffffff) > break; > if (rp_val) { > - addr = calc_reloc(rp_val, libinfo, id, 0); > + addr = calc_reloc(rp_val, libinfo); > if (addr == RELOC_FAILED) { > ret = -ENOEXEC; > goto err; > @@ -810,7 +757,7 @@ static int load_flat_file(struct linux_binprm *bprm, > return -EFAULT; > relval = ntohl(tmp); > addr = flat_get_relocate_addr(relval); > - rp = (u32 __user *)calc_reloc(addr, libinfo, id, 1); > + rp = (u32 __user *)calc_reloc(addr, libinfo); > if (rp == (u32 __user *)RELOC_FAILED) { > ret = -ENOEXEC; > goto err; > @@ -833,7 +780,7 @@ static int load_flat_file(struct linux_binprm *bprm, > */ > addr = ntohl((__force __be32)addr); > } > - addr = calc_reloc(addr, libinfo, id, 0); > + addr = calc_reloc(addr, libinfo); > if (addr == RELOC_FAILED) { > ret = -ENOEXEC; > goto err; > @@ -861,7 +808,7 @@ static int load_flat_file(struct linux_binprm *bprm, > /* zero the BSS, BRK and stack areas */ > if (clear_user((void __user *)(datapos + data_len), bss_len + > (memp + memp_size - stack_len - /* end brk */ > - libinfo->lib_list[id].start_brk) + /* start brk */ > + libinfo->lib_list[0].start_brk) + /* start brk */ > stack_len)) > return -EFAULT; > > @@ -871,49 +818,6 @@ static int load_flat_file(struct linux_binprm *bprm, > } > > > -/****************************************************************************/ > -#ifdef CONFIG_BINFMT_SHARED_FLAT > - > -/* > - * Load a shared library into memory. The library gets its own data > - * segment (including bss) but not argv/argc/environ. > - */ > - > -static int load_flat_shared_library(int id, struct lib_info *libs) > -{ > - /* > - * This is a fake bprm struct; only the members "buf", "file" and > - * "filename" are actually used. > - */ > - struct linux_binprm bprm; > - int res; > - char buf[16]; > - loff_t pos = 0; > - > - memset(&bprm, 0, sizeof(bprm)); > - > - /* Create the file name */ > - sprintf(buf, "/lib/lib%d.so", id); > - > - /* Open the file up */ > - bprm.filename = buf; > - bprm.file = open_exec(bprm.filename); > - res = PTR_ERR(bprm.file); > - if (IS_ERR(bprm.file)) > - return res; > - > - res = kernel_read(bprm.file, bprm.buf, BINPRM_BUF_SIZE, &pos); > - > - if (res >= 0) > - res = load_flat_file(&bprm, libs, id, NULL); > - > - allow_write_access(bprm.file); > - fput(bprm.file); > - > - return res; > -} > - > -#endif /* CONFIG_BINFMT_SHARED_FLAT */ > /****************************************************************************/ > > /* > @@ -946,7 +850,7 @@ static int load_flat_binary(struct linux_binprm *bprm) > stack_len += (bprm->envc + 1) * sizeof(char *); /* the envp array */ > stack_len = ALIGN(stack_len, FLAT_STACK_ALIGN); > > - res = load_flat_file(bprm, &libinfo, 0, &stack_len); > + res = load_flat_file(bprm, &libinfo, &stack_len); > if (res < 0) > return res; > > @@ -991,20 +895,6 @@ static int load_flat_binary(struct linux_binprm *bprm) > */ > start_addr = libinfo.lib_list[0].entry; > > -#ifdef CONFIG_BINFMT_SHARED_FLAT > - for (i = MAX_SHARED_LIBS-1; i > 0; i--) { > - if (libinfo.lib_list[i].loaded) { > - /* Push previos first to call address */ > - unsigned long __user *sp; > - current->mm->start_stack -= sizeof(unsigned long); > - sp = (unsigned long __user *)current->mm->start_stack; > - if (put_user(start_addr, sp)) > - return -EFAULT; > - start_addr = libinfo.lib_list[i].entry; > - } > - } > -#endif > - > #ifdef FLAT_PLAT_INIT > FLAT_PLAT_INIT(regs); > #endif _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel