Re: [PATCH v2] binfmt_misc: pass info about P flag by AT_FLAGS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Laurent Vivier <laurent@xxxxxxxxx> 于2020年1月16日周四 下午4:07写道:
>
> Le 16/01/2020 à 03:20, YunQiang Su a écrit :
> > From: YunQiang Su <ysu@xxxxxxxxxxxx>
> >
> > Currently program invoked by binfmt_misc cannot be aware about whether
> > P flag, aka preserve path is enabled.
> >
> > Some applications like qemu need to know since it has 2 use case:
> >   1. call by hand, like: qemu-mipsel-static test.app OPTION
> >      so, qemu have to assume that P option is not enabled.
> >   2. call by binfmt_misc. If qemu cannot know about whether P flag is
> >      enabled, distribution's have to set qemu without P flag, and
> >      binfmt_misc call qemu like:
> >        qemu-mipsel-static /absolute/path/to/test.app OPTION
> >      even test.app is not called by absoulute path, like
> >        ./relative/path/to/test.app
> >
> > This patch passes this information by the 3rd bits of unused AT_FLAGS.
> > Then, in qemu, we can get this info by:
> >    getauxval(AT_FLAGS) & (1<<3)
> >
> > v1->v2:
> >   not enable kdebug
> >
> > See: https://bugs.launchpad.net/qemu/+bug/1818483
> > Signed-off-by: YunQiang Su <ysu@xxxxxxxxxxxx>
> > ---
> >  fs/binfmt_elf.c         | 6 +++++-
> >  fs/binfmt_elf_fdpic.c   | 6 +++++-
> >  fs/binfmt_misc.c        | 2 ++
> >  include/linux/binfmts.h | 4 ++++
> >  4 files changed, 16 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
> > index f4713ea76e82..d33ee07d7f57 100644
> > --- a/fs/binfmt_elf.c
> > +++ b/fs/binfmt_elf.c
> > @@ -178,6 +178,7 @@ create_elf_tables(struct linux_binprm *bprm, const struct elfhdr *exec,
> >       unsigned char k_rand_bytes[16];
> >       int items;
> >       elf_addr_t *elf_info;
> > +     elf_addr_t flags = 0;
> >       int ei_index;
> >       const struct cred *cred = current_cred();
> >       struct vm_area_struct *vma;
> > @@ -252,7 +253,10 @@ create_elf_tables(struct linux_binprm *bprm, const struct elfhdr *exec,
> >       NEW_AUX_ENT(AT_PHENT, sizeof(struct elf_phdr));
> >       NEW_AUX_ENT(AT_PHNUM, exec->e_phnum);
> >       NEW_AUX_ENT(AT_BASE, interp_load_addr);
> > -     NEW_AUX_ENT(AT_FLAGS, 0);
> > +     if (bprm->interp_flags & BINPRM_FLAGS_PRESERVE_ARGV0) {
> > +             flags |= BINPRM_FLAGS_PRESERVE_ARGV0;
> > +     }
>
> Perhaps we also need a different flag in AT_FLAG than in interp_flag as
> BINPRM_FLAGS_PRESERVE_ARGV0 is also part of the internal ABI?

yep. It may be really a problem.
So, should we define a set of new macros for AT_FLAGS?

>
> Al?
>
> Thanks,
> Laurent
>



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux