android_kernel_sony_sdm845/arch/mips
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Rik van Riel dd52dc737b UPSTREAM: mm,fork: introduce MADV_WIPEONFORK
Introduce MADV_WIPEONFORK semantics, which result in a VMA being empty
in the child process after fork.  This differs from MADV_DONTFORK in one
important way.

If a child process accesses memory that was MADV_WIPEONFORK, it will get
zeroes.  The address ranges are still valid, they are just empty.

If a child process accesses memory that was MADV_DONTFORK, it will get a
segmentation fault, since those address ranges are no longer valid in
the child after fork.

Since MADV_DONTFORK also seems to be used to allow very large programs
to fork in systems with strict memory overcommit restrictions, changing
the semantics of MADV_DONTFORK might break existing programs.

MADV_WIPEONFORK only works on private, anonymous VMAs.

The use case is libraries that store or cache information, and want to
know that they need to regenerate it in the child process after fork.

Examples of this would be:
 - systemd/pulseaudio API checks (fail after fork) (replacing a getpid
   check, which is too slow without a PID cache)
 - PKCS#11 API reinitialization check (mandated by specification)
 - glibc's upcoming PRNG (reseed after fork)
 - OpenSSL PRNG (reseed after fork)

The security benefits of a forking server having a re-inialized PRNG in
every child process are pretty obvious.  However, due to libraries
having all kinds of internal state, and programs getting compiled with
many different versions of each library, it is unreasonable to expect
calling programs to re-initialize everything manually after fork.

A further complication is the proliferation of clone flags, programs
bypassing glibc's functions to call clone directly, and programs calling
unshare, causing the glibc pthread_atfork hook to not get called.

It would be better to have the kernel take care of this automatically.

The patch also adds MADV_KEEPONFORK, to undo the effects of a prior
MADV_WIPEONFORK.

This is similar to the OpenBSD minherit syscall with MAP_INHERIT_ZERO:

    https://man.openbsd.org/minherit.2

[akpm@linux-foundation.org: numerically order arch/parisc/include/uapi/asm/mman.h #defines]
Link: http://lkml.kernel.org/r/20170811212829.29186-3-riel@redhat.com
Signed-off-by: Rik van Riel <riel@redhat.com>
Reported-by: Florian Weimer <fweimer@redhat.com>
Reported-by: Colm MacCártaigh <colm@allcosts.net>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Helge Deller <deller@gmx.de>
Cc: Kees Cook <keescook@chromium.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Drewry <wad@chromium.org>
Cc: <linux-api@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
2026-05-15 18:04:15 +07:00
..
alchemy MIPS: alchemy: xxs1500: add gpio-au1000.h header file 2021-06-03 08:23:33 +02:00
ar7
ath25
ath79 Revert "MIPS: perf: ath79: Fix perfcount IRQ assignment" 2019-06-11 12:22:48 +02:00
bcm47xx MIPS: BCM47XX: Cast memcmp() of function to (void *) 2022-10-26 13:15:45 +02:00
bcm63xx MIPS: BCM63xx: Add check for NULL for clk in clk_enable 2023-01-07 12:07:15 +01:00
bmips MIPS: Use address-of operator on section symbols 2022-05-15 19:39:17 +02:00
boot mips: disable branch profiling in boot/decompress.o 2021-07-20 16:21:16 +02:00
cavium-octeon mips: cavium-octeon: Fix missing of_node_put() in octeon2_usb_clocks_start 2022-08-25 11:09:31 +02:00
cobalt
configs Merge android-4.9.197(e9766ef) into msm-4.9 2019-12-06 19:41:21 +08:00
dec DEC: Limit PMAX memory probing to R3k systems 2022-04-20 09:06:30 +02:00
emma
fw MIPS: fw: sni: Fix out of bounds init of o32 stack 2019-11-06 12:18:11 +01:00
generic
include UPSTREAM: mm,fork: introduce MADV_WIPEONFORK 2026-05-15 18:04:15 +07:00
jazz MIPS: jazz: fix 64bit build 2019-02-27 10:06:59 +01:00
jz4740
kernel MIPS: vpe-cmp: fix possible memory leak while module exiting 2023-01-07 12:07:14 +01:00
kvm UPSTREAM: Make anon_inodes unconditional 2019-09-03 13:44:37 -07:00
lantiq MIPS: lantiq: export clk_get_io() for lantiq_wdt.ko 2022-09-28 10:55:46 +02:00
lasat
lib MIPS: Fix kernel hang under FUNCTION_GRAPH_TRACER and PREEMPT_TRACER 2021-06-16 11:36:33 +02:00
loongson32 MIPS: loongson32: ls1c: Fix hang during startup 2022-09-15 12:39:46 +02:00
loongson64 MIPS: Loongson: Fix potential NULL dereference in loongson3_platform_init() 2020-02-28 15:42:19 +01:00
math-emu MIPS: math-emu: do not use bools for arithmetic 2019-07-10 09:55:43 +02:00
mm MIPS: tlbex: Explicitly compare _PAGE_NO_EXEC against 0 2022-08-25 11:09:32 +02:00
mti-malta MIPS: Malta: fix alignment of the devicetree buffer 2021-09-22 11:43:04 +02:00
net bpf: get rid of pure_initcall dependency to enable jits 2019-08-25 10:51:40 +02:00
netlogic
oprofile
paravirt
pci MIPS: pci-legacy: stop using of_pci_range_to_resource 2021-05-22 10:40:27 +02:00
pic32 MIPS: pic32: treat port as signed integer 2022-12-08 11:15:39 +01:00
pistachio MIPS: pistachio: Build uImage.gz by default 2019-06-11 12:22:48 +02:00
pmcs-msp71xx
pnx833x
power
ralink MIPS: ralink: export rt_sysc_membase for rt2880_wdt.c 2021-06-03 08:23:33 +02:00
rb532 MIPS: RB532: fix return value of __setup handler 2022-04-20 09:06:36 +02:00
sgi-ip22
sgi-ip27
sgi-ip32
sibyte Revert "MIPS: SiByte: Enable swiotlb for SWARM, LittleSur and BigSur" 2019-09-21 07:14:03 +02:00
sni MIPS: sni: Fix the build 2021-11-26 11:48:40 +01:00
txx9 mips: txx9: fix iounmap related issue 2019-11-25 09:52:07 +01:00
vdso MIPS: vdso: Invalid GIC access through VDSO 2021-07-20 16:21:16 +02:00
vr41xx MIPS: Remove repetitive increase irq_err_count 2022-07-02 16:17:14 +02:00
xilfpga
Kbuild
Kbuild.platforms
Kconfig mips: BCM63XX: ensure that CPU_SUPPORTS_32BIT_KERNEL is set 2021-11-26 11:48:41 +01:00
Kconfig.debug
Makefile mips: Fix non-POSIX regexp 2021-08-15 13:01:01 +02:00