diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml
index e41f5234a571..969c4f8bae0f 100644
--- a/android/abi_gki_aarch64.xml
+++ b/android/abi_gki_aarch64.xml
@@ -149,6 +149,7 @@
+
@@ -1257,6 +1258,7 @@
+
@@ -1562,6 +1564,7 @@
+
@@ -1641,6 +1644,8 @@
+
+
@@ -1816,6 +1821,7 @@
+
@@ -2044,6 +2050,7 @@
+
@@ -3288,6 +3295,7 @@
+
@@ -4264,6 +4272,8 @@
+
+
@@ -4516,7 +4526,7 @@
-
+
@@ -4567,7 +4577,7 @@
-
+
@@ -5264,6 +5274,17 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -7647,114 +7668,114 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -7783,7 +7804,7 @@
-
+
@@ -11197,6 +11218,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -14184,23 +14222,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -14329,17 +14350,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -14494,7 +14504,7 @@
-
+
@@ -14529,8 +14539,8 @@
-
-
+
+
@@ -14588,7 +14598,7 @@
-
+
@@ -14599,7 +14609,7 @@
-
+
@@ -15182,7 +15192,7 @@
-
+
@@ -16234,7 +16244,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -16249,6 +16273,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -19692,23 +19749,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -19867,6 +19907,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -21964,6 +22021,8 @@
+
+
@@ -35683,6 +35742,12 @@
+
+
+
+
+
+
@@ -77695,17 +77760,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -85212,7 +85266,7 @@
-
+
@@ -85221,13 +85275,13 @@
-
+
-
+
@@ -85988,16 +86042,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -86289,14 +86333,6 @@
-
-
-
-
-
-
-
-
@@ -86352,6 +86388,17 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -86377,6 +86424,14 @@
+
+
+
+
+
+
+
+
@@ -86700,6 +86755,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -87049,11 +87121,11 @@
-
+
-
+
@@ -87555,23 +87627,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -87706,46 +87761,25 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
-
+
-
-
+
@@ -88953,7 +88987,7 @@
-
+
@@ -89197,7 +89231,7 @@
-
+
@@ -89353,7 +89387,7 @@
-
+
@@ -89364,7 +89398,7 @@
-
+
@@ -89497,7 +89531,7 @@
-
+
@@ -90517,39 +90551,39 @@
-
-
-
-
-
+
+
+
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
@@ -90780,6 +90814,7 @@
+
@@ -90788,6 +90823,11 @@
+
+
+
+
+
@@ -91008,7 +91048,7 @@
-
+
@@ -91028,7 +91068,7 @@
-
+
@@ -99771,23 +99811,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -103690,7 +103713,7 @@
-
+
@@ -103724,21 +103747,21 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -103910,12 +103933,12 @@
-
-
+
+
-
-
+
+
@@ -104262,7 +104285,7 @@
-
+
@@ -104453,13 +104476,213 @@
-
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -104543,7 +104766,7 @@
-
+
@@ -104594,7 +104817,18 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -104629,6 +104863,12 @@
+
+
+
+
+
+
@@ -104729,6 +104969,10 @@
+
+
+
+
@@ -104767,6 +105011,13 @@
+
+
+
+
+
+
+
@@ -104774,6 +105025,10 @@
+
+
+
+
@@ -105088,6 +105343,11 @@
+
+
+
+
+
@@ -105228,6 +105488,10 @@
+
+
+
+
@@ -105295,17 +105559,35 @@
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -105319,6 +105601,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -105355,7 +105660,6 @@
-
@@ -105411,11 +105715,6 @@
-
-
-
-
-
@@ -110203,6 +110502,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -110411,23 +110729,15 @@
-
+
-
+
-
-
-
-
-
-
+
-
-
-
-
+
@@ -112578,17 +112888,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -112741,7 +113040,7 @@
-
+
@@ -112780,7 +113079,7 @@
-
+
@@ -112862,7 +113161,7 @@
-
+
@@ -112877,7 +113176,7 @@
-
+
@@ -112889,7 +113188,7 @@
-
+
@@ -112898,7 +113197,7 @@
-
+
@@ -112980,207 +113279,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -113191,7 +113290,7 @@
-
+
@@ -113199,18 +113298,7 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -113282,17 +113370,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -113356,7 +113433,7 @@
-
+
@@ -119232,21 +119309,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/android/abi_gki_aarch64_cuttlefish b/android/abi_gki_aarch64_cuttlefish
index 289794edf98a..df6a9c3c7eb0 100644
--- a/android/abi_gki_aarch64_cuttlefish
+++ b/android/abi_gki_aarch64_cuttlefish
@@ -1,4 +1,4 @@
-[abi_whitelist]
+[abi_symbol_list]
# commonly used symbols
add_wait_queue
alloc_etherdev_mqs
diff --git a/android/abi_gki_aarch64_db845c b/android/abi_gki_aarch64_db845c
index e0c60b2d616d..cb55ce982af9 100644
--- a/android/abi_gki_aarch64_db845c
+++ b/android/abi_gki_aarch64_db845c
@@ -1,4 +1,4 @@
-[abi_whitelist]
+[abi_symbol_list]
# commonly used symbols
__arch_copy_from_user
__arch_copy_to_user
diff --git a/android/abi_gki_aarch64_exynos b/android/abi_gki_aarch64_exynos
index ef9721e4d3b5..97cf3901b7a1 100644
--- a/android/abi_gki_aarch64_exynos
+++ b/android/abi_gki_aarch64_exynos
@@ -1,4 +1,4 @@
-[abi_whitelist]
+[abi_symbol_list]
add_timer
add_timer_on
add_uevent_var
diff --git a/android/abi_gki_aarch64_galaxy b/android/abi_gki_aarch64_galaxy
index acceef3b6eb0..3e4c50792f6c 100644
--- a/android/abi_gki_aarch64_galaxy
+++ b/android/abi_gki_aarch64_galaxy
@@ -1,4 +1,4 @@
-[abi_whitelist]
+[abi_symbol_list]
___ratelimit
__alloc_disk_node
__alloc_pages_nodemask
@@ -93,6 +93,7 @@
__mutex_init
__napi_alloc_skb
__napi_schedule
+ __napi_schedule_irqoff
__netdev_alloc_skb
__netlink_kernel_create
__nlmsg_put
@@ -145,6 +146,8 @@
__tasklet_schedule
__trace_bprintk
__tracepoint_android_vh_is_fpsimd_save
+ __tracepoint_android_vh_kfree_skb
+ __tracepoint_android_vh_ptype_head
__tracepoint_device_pm_callback_end
__tracepoint_device_pm_callback_start
__tracepoint_pelt_cfs_tp
@@ -415,6 +418,8 @@
cpufreq_table_index_unsorted
cpufreq_unregister_driver
cpuhp_tasks_frozen
+ cpuidle_pause_and_lock
+ cpuidle_resume_and_unlock
cpumask_next
cpumask_next_and
cpus_read_lock
@@ -797,6 +802,7 @@
drm_dp_update_payload_part1
drm_dp_update_payload_part2
drm_edid_duplicate
+ drm_edid_get_monitor_name
drm_encoder_cleanup
drm_encoder_init
drm_err
@@ -853,6 +859,7 @@
drm_mode_create
drm_mode_create_dp_colorspace_property
drm_mode_debug_printmodeline
+ drm_mode_destroy
drm_mode_duplicate
drm_mode_equal
drm_mode_object_find
@@ -987,6 +994,7 @@
get_cpu_device
get_cpu_idle_time
get_device
+ get_options
get_pid_task
get_random_bytes
get_random_u32
@@ -1041,6 +1049,8 @@
gpiod_set_value
gpiod_set_value_cansleep
gpiod_to_irq
+ gro_find_complete_by_type
+ gro_find_receive_by_type
gs_alloc_req
gs_free_req
gserial_alloc_line
@@ -1131,6 +1141,7 @@
iio_read_channel_processed
iio_read_channel_raw
import_iovec
+ in_aton
in_egroup_p
init_dummy_netdev
init_net
@@ -1289,6 +1300,7 @@
kfree_call_rcu
kfree_const
kfree_skb
+ kfree_skb_partial
kill_fasync
kimage_vaddr
kimage_voffset
@@ -2022,6 +2034,7 @@
smp_call_function
smp_call_function_many
smp_call_function_single
+ smp_call_function_single_async
smp_call_on_cpu
snd_card_free
snd_card_new
diff --git a/android/abi_gki_aarch64_goldfish b/android/abi_gki_aarch64_goldfish
index be17c303b5fe..93efcaf60f8a 100644
--- a/android/abi_gki_aarch64_goldfish
+++ b/android/abi_gki_aarch64_goldfish
@@ -1,4 +1,4 @@
-[abi_whitelist]
+[abi_symbol_list]
# commonly used symbols
__alloc_disk_node
alloc_etherdev_mqs
diff --git a/android/abi_gki_aarch64_hikey960 b/android/abi_gki_aarch64_hikey960
index 6ce7564f0826..f4997bb0639b 100644
--- a/android/abi_gki_aarch64_hikey960
+++ b/android/abi_gki_aarch64_hikey960
@@ -1,4 +1,4 @@
-[abi_whitelist]
+[abi_symbol_list]
# commonly used symbols
add_uevent_var
alloc_chrdev_region
diff --git a/android/abi_gki_aarch64_oneplus b/android/abi_gki_aarch64_oneplus
index 7cdf6d261ab5..9d8fa8a826ad 100644
--- a/android/abi_gki_aarch64_oneplus
+++ b/android/abi_gki_aarch64_oneplus
@@ -1,4 +1,4 @@
-[abi_whitelist]
+[abi_symbol_list]
# commonly used symbols
add_timer
alloc_chrdev_region
diff --git a/android/abi_gki_aarch64_oplus b/android/abi_gki_aarch64_oplus
index 39e7e1905b82..15ac9a66a517 100644
--- a/android/abi_gki_aarch64_oplus
+++ b/android/abi_gki_aarch64_oplus
@@ -1,4 +1,4 @@
-[abi_whitelist]
+[abi_symbol_list]
# commonly used symbols
alloc_workqueue
__arch_copy_from_user
diff --git a/android/abi_gki_aarch64_qcom b/android/abi_gki_aarch64_qcom
index ab8314462433..4878c5f5fb7d 100644
--- a/android/abi_gki_aarch64_qcom
+++ b/android/abi_gki_aarch64_qcom
@@ -1,4 +1,4 @@
-[abi_whitelist]
+[abi_symbol_list]
add_device_randomness
add_timer
add_timer_on
diff --git a/android/abi_gki_aarch64_sunxi b/android/abi_gki_aarch64_sunxi
index cfa5e5b29a40..9fb7727b17a4 100644
--- a/android/abi_gki_aarch64_sunxi
+++ b/android/abi_gki_aarch64_sunxi
@@ -1,4 +1,4 @@
-[abi_whitelist]
+[abi_symbol_list]
# commonly used symbols
pinctrl_get
pinctrl_gpio_set_config
diff --git a/android/abi_gki_aarch64_unisoc b/android/abi_gki_aarch64_unisoc
index a743719eb889..c40f652bfbcd 100644
--- a/android/abi_gki_aarch64_unisoc
+++ b/android/abi_gki_aarch64_unisoc
@@ -1,4 +1,4 @@
-[abi_whitelist]
+[abi_symbol_list]
# commonly used symbols
add_timer
add_uevent_var
diff --git a/android/abi_gki_aarch64_vivo b/android/abi_gki_aarch64_vivo
index 2ddab083f547..b739d3bee3dc 100644
--- a/android/abi_gki_aarch64_vivo
+++ b/android/abi_gki_aarch64_vivo
@@ -1,4 +1,4 @@
-[abi_whitelist]
+[abi_symbol_list]
add_device_randomness
add_timer
add_uevent_var
diff --git a/android/abi_gki_aarch64_workarounds b/android/abi_gki_aarch64_workarounds
index 3e4b6d16c687..c96aebcba081 100644
--- a/android/abi_gki_aarch64_workarounds
+++ b/android/abi_gki_aarch64_workarounds
@@ -1,3 +1,3 @@
-[abi_whitelist]
+[abi_symbol_list]
# b/167230325
ehci_handshake
diff --git a/arch/arm64/configs/hikey960_gki.fragment b/arch/arm64/configs/hikey960_gki.fragment
index 854372329ff8..d303efbe3a5a 100644
--- a/arch/arm64/configs/hikey960_gki.fragment
+++ b/arch/arm64/configs/hikey960_gki.fragment
@@ -4,7 +4,6 @@ CONFIG_CONNECTOR=m
CONFIG_BLK_DEV_NVME=m
CONFIG_NVME_TARGET=m
CONFIG_HISI_HIKEY_USB=m
-CONFIG_SCSI_UFS_HISI=m
CONFIG_WLAN_VENDOR_TI=y
CONFIG_WL18XX=m
CONFIG_WLCORE_SDIO=m
@@ -37,7 +36,6 @@ CONFIG_USB_OHCI_HCD=m
CONFIG_USB_OHCI_HCD_PLATFORM=m
CONFIG_USB_DWC3=m
CONFIG_USB_GADGETFS=m
-CONFIG_TYPEC_TCPM=m
CONFIG_TYPEC_TCPCI=m
CONFIG_TYPEC_RT1711H=m
CONFIG_MMC_BLOCK=m
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 77de74ac6be8..8fcbd44a19ec 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -55,6 +55,7 @@
#include
#include
#include
+#include
#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_STACKPROTECTOR_PER_TASK)
#include
@@ -254,6 +255,7 @@ void __show_regs(struct pt_regs *regs)
top_reg = 29;
}
+ trace_android_vh_show_regs(regs);
show_regs_print_info(KERN_DEFAULT);
print_pstate(regs);
diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c
index 2ed3b8b2bccf..4dc0d89c835b 100644
--- a/drivers/android/vendor_hooks.c
+++ b/drivers/android/vendor_hooks.c
@@ -17,6 +17,7 @@
#include
#include
#include
+#include
/*
* Export tracepoints that act as a bare tracehook (ie: have no trace event
@@ -56,3 +57,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alter_futex_plist_add);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_is_fpsimd_save);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ipi_stop);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_printk_store);
+EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_show_regs);
diff --git a/drivers/misc/lkdtm/usercopy.c b/drivers/misc/lkdtm/usercopy.c
index b833367a45d0..120e9ffd0f28 100644
--- a/drivers/misc/lkdtm/usercopy.c
+++ b/drivers/misc/lkdtm/usercopy.c
@@ -314,7 +314,7 @@ void lkdtm_USERCOPY_KERNEL(void)
pr_info("attempting bad copy_to_user from kernel text: %px\n",
vm_mmap);
- if (copy_to_user((void __user *)user_addr, vm_mmap,
+ if (copy_to_user((void __user *)user_addr, __va_function(vm_mmap),
unconst + PAGE_SIZE)) {
pr_warn("copy_to_user failed, but lacked Oops\n");
goto free_user;
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 7d13501910ee..78aeaafa2384 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1037,7 +1037,6 @@ static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count,
static int __set_oom_adj(struct file *file, int oom_adj, bool legacy)
{
- static DEFINE_MUTEX(oom_adj_mutex);
struct mm_struct *mm = NULL;
struct task_struct *task;
int err = 0;
@@ -1077,7 +1076,7 @@ static int __set_oom_adj(struct file *file, int oom_adj, bool legacy)
struct task_struct *p = find_lock_task_mm(task);
if (p) {
- if (atomic_read(&p->mm->mm_users) > 1) {
+ if (test_bit(MMF_MULTIPROCESS, &p->mm->flags)) {
mm = p->mm;
mmgrab(mm);
}
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 2f821accb850..e032e34213aa 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -116,6 +116,14 @@ extern int mmap_rnd_compat_bits __read_mostly;
#define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x), 0))
#endif
+#ifndef __va_function
+#define __va_function(x) (x)
+#endif
+
+#ifndef __pa_function
+#define __pa_function(x) __pa_symbol(x)
+#endif
+
#ifndef page_to_virt
#define page_to_virt(x) __va(PFN_PHYS(page_to_pfn(x)))
#endif
diff --git a/include/linux/oom.h b/include/linux/oom.h
index c696c265f019..b9df34326772 100644
--- a/include/linux/oom.h
+++ b/include/linux/oom.h
@@ -55,6 +55,7 @@ struct oom_control {
};
extern struct mutex oom_lock;
+extern struct mutex oom_adj_mutex;
static inline void set_current_oom_origin(void)
{
diff --git a/include/linux/sched/coredump.h b/include/linux/sched/coredump.h
index ecdc6542070f..dfd82eab2902 100644
--- a/include/linux/sched/coredump.h
+++ b/include/linux/sched/coredump.h
@@ -72,6 +72,7 @@ static inline int get_dumpable(struct mm_struct *mm)
#define MMF_DISABLE_THP 24 /* disable THP for all VMAs */
#define MMF_OOM_VICTIM 25 /* mm is the oom victim */
#define MMF_OOM_REAP_QUEUED 26 /* mm was queued for oom_reaper */
+#define MMF_MULTIPROCESS 27 /* mm is shared between processes */
#define MMF_DISABLE_THP_MASK (1 << MMF_DISABLE_THP)
#define MMF_INIT_MASK (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK |\
diff --git a/include/trace/hooks/minidump.h b/include/trace/hooks/minidump.h
new file mode 100644
index 000000000000..11283e43322d
--- /dev/null
+++ b/include/trace/hooks/minidump.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM minidump
+
+#define TRACE_INCLUDE_PATH trace/hooks
+
+#if !defined(_TRACE_HOOK_MINIDUMP_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_HOOK_MINIDUMP_H
+#include
+#include
+
+#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS)
+struct pt_regs;
+DECLARE_HOOK(android_vh_show_regs,
+ TP_PROTO(struct pt_regs *regs),
+ TP_ARGS(regs));
+#else
+#define trace_android_vh_show_regs(regs)
+#endif
+
+#endif /* _TRACE_HOOK_MINIDUMP_H */
+/* This part must be outside protection */
+#include
+
diff --git a/kernel/fork.c b/kernel/fork.c
index e0a1e1187728..41ce6de4d5d1 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1760,6 +1760,25 @@ static __always_inline void delayed_free_task(struct task_struct *tsk)
free_task(tsk);
}
+static void copy_oom_score_adj(u64 clone_flags, struct task_struct *tsk)
+{
+ /* Skip if kernel thread */
+ if (!tsk->mm)
+ return;
+
+ /* Skip if spawning a thread or using vfork */
+ if ((clone_flags & (CLONE_VM | CLONE_THREAD | CLONE_VFORK)) != CLONE_VM)
+ return;
+
+ /* We need to synchronize with __set_oom_adj */
+ mutex_lock(&oom_adj_mutex);
+ set_bit(MMF_MULTIPROCESS, &tsk->mm->flags);
+ /* Update the values in case they were changed after copy_signal */
+ tsk->signal->oom_score_adj = current->signal->oom_score_adj;
+ tsk->signal->oom_score_adj_min = current->signal->oom_score_adj_min;
+ mutex_unlock(&oom_adj_mutex);
+}
+
/*
* This creates a new process as a copy of the old one,
* but does not actually start it yet.
@@ -2234,6 +2253,8 @@ static __latent_entropy struct task_struct *copy_process(
trace_task_newtask(p, clone_flags);
uprobe_copy_process(p, clone_flags);
+ copy_oom_score_adj(clone_flags, p);
+
return p;
bad_fork_cancel_cgroup:
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index d58c481b3df8..212e71874301 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -63,6 +63,8 @@ int sysctl_oom_dump_tasks = 1;
* and mark_oom_victim
*/
DEFINE_MUTEX(oom_lock);
+/* Serializes oom_score_adj and oom_score_adj_min updates */
+DEFINE_MUTEX(oom_adj_mutex);
static inline bool is_memcg_oom(struct oom_control *oc)
{