2021-04-21 10:08:52

by David Hildenbrand

[permalink] [raw]
Subject: [PATCH v1 0/3] perf/binfmt/mm: remove in-tree usage of MAP_EXECUTABLE

Stumbling over the history of MAP_EXECUTABLE, I noticed that we still
have some in-tree users that we can get rid of.

A good fit for the whole series could be Andrew's tree.

Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Alexander Viro <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Cc: Greg Ungerer <[email protected]>
Cc: Mike Rapoport <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Kevin Brodsky <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Feng Tang <[email protected]>
Cc: Don Zickus <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

David Hildenbrand (3):
perf: MAP_EXECUTABLE does not indicate VM_MAYEXEC
binfmt: remove in-tree usage of MAP_EXECUTABLE
mm: ignore MAP_EXECUTABLE in ksys_mmap_pgoff()

arch/x86/ia32/ia32_aout.c | 4 ++--
fs/binfmt_aout.c | 4 ++--
fs/binfmt_elf.c | 2 +-
fs/binfmt_elf_fdpic.c | 11 ++---------
fs/binfmt_flat.c | 2 +-
include/linux/mman.h | 2 ++
kernel/events/core.c | 2 --
mm/mmap.c | 2 +-
mm/nommu.c | 2 +-
9 files changed, 12 insertions(+), 19 deletions(-)

--
2.30.2


2021-04-22 01:21:12

by Eric W. Biederman

[permalink] [raw]
Subject: Re: [PATCH v1 0/3] perf/binfmt/mm: remove in-tree usage of MAP_EXECUTABLE

David Hildenbrand <[email protected]> writes:

> Stumbling over the history of MAP_EXECUTABLE, I noticed that we still
> have some in-tree users that we can get rid of.
>
> A good fit for the whole series could be Andrew's tree.

In general this looks like a good cleanup.

Acked-by: "Eric W. Biederman" <[email protected]>

As far as I can see we can go after MAP_DENYWRITE the same way.
Today deny_write_access in open_exec is what causes -ETXTBSY
when attempting to write to file that is current executing.

Do you have any plans to look at that?

Eric

> Cc: Thomas Gleixner <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: Borislav Petkov <[email protected]>
> Cc: "H. Peter Anvin" <[email protected]>
> Cc: Alexander Viro <[email protected]>
> Cc: Peter Zijlstra <[email protected]>
> Cc: Arnaldo Carvalho de Melo <[email protected]>
> Cc: Mark Rutland <[email protected]>
> Cc: Alexander Shishkin <[email protected]>
> Cc: Jiri Olsa <[email protected]>
> Cc: Namhyung Kim <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: Kees Cook <[email protected]>
> Cc: "Eric W. Biederman" <[email protected]>
> Cc: Greg Ungerer <[email protected]>
> Cc: Mike Rapoport <[email protected]>
> Cc: Catalin Marinas <[email protected]>
> Cc: Kevin Brodsky <[email protected]>
> Cc: Michal Hocko <[email protected]>
> Cc: Feng Tang <[email protected]>
> Cc: Don Zickus <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
>
> David Hildenbrand (3):
> perf: MAP_EXECUTABLE does not indicate VM_MAYEXEC
> binfmt: remove in-tree usage of MAP_EXECUTABLE
> mm: ignore MAP_EXECUTABLE in ksys_mmap_pgoff()
>
> arch/x86/ia32/ia32_aout.c | 4 ++--
> fs/binfmt_aout.c | 4 ++--
> fs/binfmt_elf.c | 2 +-
> fs/binfmt_elf_fdpic.c | 11 ++---------
> fs/binfmt_flat.c | 2 +-
> include/linux/mman.h | 2 ++
> kernel/events/core.c | 2 --
> mm/mmap.c | 2 +-
> mm/nommu.c | 2 +-
> 9 files changed, 12 insertions(+), 19 deletions(-)

2021-04-22 01:22:03

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH v1 0/3] perf/binfmt/mm: remove in-tree usage of MAP_EXECUTABLE

On Wed, Apr 21, 2021 at 02:03:49PM -0500, Eric W. Biederman wrote:
> David Hildenbrand <[email protected]> writes:
>
> > Stumbling over the history of MAP_EXECUTABLE, I noticed that we still
> > have some in-tree users that we can get rid of.
> >
> > A good fit for the whole series could be Andrew's tree.
>
> In general this looks like a good cleanup.
>
> Acked-by: "Eric W. Biederman" <[email protected]>

Yeah, the PROT_EXEC parts are the only piece with meaning in the exec
allocations.

Reviewed-by: Kees Cook <[email protected]>

> As far as I can see we can go after MAP_DENYWRITE the same way.
> Today deny_write_access in open_exec is what causes -ETXTBSY
> when attempting to write to file that is current executing.

Oh, interesting point. I didn't realize MAP_DENYWRITE was separate from
deny_write_access().

-Kees

--
Kees Cook

2021-04-22 01:24:36

by David Hildenbrand

[permalink] [raw]
Subject: Re: [PATCH v1 0/3] perf/binfmt/mm: remove in-tree usage of MAP_EXECUTABLE

On 21.04.21 21:03, Eric W. Biederman wrote:
> David Hildenbrand <[email protected]> writes:
>
>> Stumbling over the history of MAP_EXECUTABLE, I noticed that we still
>> have some in-tree users that we can get rid of.
>>
>> A good fit for the whole series could be Andrew's tree.
>
> In general this looks like a good cleanup.
>
> Acked-by: "Eric W. Biederman" <[email protected]>
>
> As far as I can see we can go after MAP_DENYWRITE the same way.
> Today deny_write_access in open_exec is what causes -ETXTBSY
> when attempting to write to file that is current executing.
>
> Do you have any plans to look at that?

I did have a look and thought about ripping out MAP_DENYWRITE; I'm still
in the process of connecting the pieces.

Some VM_DENYWRITE e.g., in mm/khugepaged.c still gives me a headache ,
and I'll have to double-check whether it would be okay to just fallback
on checking the actual vm->file.

--
Thanks,

David / dhildenb