From: David Howells <dhowells@redhat.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: dhowells@redhat.com, Christoph Hellwig <hch@lst.de>,
Jie Zhang <jie.zhang@analog.com>,
Mike Frysinger <vapier@gentoo.org>,
linux-arch <linux-arch@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: CONFIG_* symbols in UAPI headers?
Date: Tue, 09 Apr 2019 19:17:25 +0100 [thread overview]
Message-ID: <3479.1554833845@warthog.procyon.org.uk> (raw)
In-Reply-To: <CAK8P3a13NVbkJzzoZG_7HrDT9qGPR5ptbRUL=xH1oZ1a+5ksHw@mail.gmail.com>
Arnd Bergmann <arnd@arndb.de> wrote:
> > I just stumbled over the MAP_UNINITIALIZED defintion, initially
> > added by:
> >
> > commit ea637639591def87a54cea811cbac796980cb30d
> > Author: Jie Zhang <jie.zhang@analog.com>
> > Date: Mon Dec 14 18:00:02 2009 -0800
> >
> > nommu: fix malloc performance by adding uninitialized flag
> >
> > The defintion depends on CONFIG_MMAP_ALLOW_UNINITIALIZED, which
> > will never be set by userspace. How is this supposed to work?
> >
> > Shoudn't we define the symbol unconditionally and just turn it
> > into a no-op in the implementation?
Yes.
> Right, good catch. That should work. It can probably be done
> by adding another check before the conditional, like:
>
> /* clear anonymous mappings that don't ask for uninitialized data */
> if (!vma->vm_file &&
> !(IS_ENABLED(CONFIG_MMAP_ALLOW_UNINITIALIZED) &&
> (flags & MAP_UNINITIALIZED))
> memset((void *)region->vm_start, 0,
> region->vm_end - region->vm_start);
Sounds good.
> > There are a few similar issues, like struct elf_prstatus having
> > a different layout depending on CONFIG_BINFMT_ELF_FDPIC, or
> > MAX_SHARED_LIBS defending on CONFIG_BINFMT_SHARED_FLAT.
Because the kernel code uses that header and that struct too, so you'd break
compilation of binfmt_elf_fdpic.c. There is a way round it - and that's to
copy the struct into the non-UAPI backing header and delete the conditional
section from the UAPI one. You'd have to stop the non-UAPI header from
#including the UAPI header, though, and you'd have to hope that no one is
trying to set it in userspace (gdb doesn't).
David
next prev parent reply other threads:[~2019-04-09 18:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-08 12:46 CONFIG_* symbols in UAPI headers? Christoph Hellwig
2019-04-08 13:58 ` Arnd Bergmann
2019-04-09 18:17 ` David Howells [this message]
2019-04-09 19:11 ` Paul Bolle
2019-04-09 20:54 ` Paul Bolle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3479.1554833845@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=arnd@arndb.de \
--cc=hch@lst.de \
--cc=jie.zhang@analog.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vapier@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox