summaryrefslogtreecommitdiff
path: root/ipc/ipc_sysctl.c
diff options
context:
space:
mode:
authorJianlin Shi <shijianlin11@foxmail.com>2026-06-15 10:27:41 +0800
committerAndrew Morton <akpm@linux-foundation.org>2026-07-30 19:50:00 -0700
commit2a28cb9c9475458f672c28e72a81b5e380f24512 (patch)
tree2970317fd7d176ffe3aadf16a1b7ccf1036ab5cf /ipc/ipc_sysctl.c
parentb0934cd39d3dc4f2cdfc2584b67b1845bcb886ed (diff)
downloadlinux-next-2a28cb9c9475458f672c28e72a81b5e380f24512.tar.gz
linux-next-2a28cb9c9475458f672c28e72a81b5e380f24512.zip
ipc: only destroy orphaned shm segments on sysctl write
proc_ipc_dointvec_minmax_orphans() currently calls shm_destroy_orphaned() whenever shm_rmid_forced is set, including on sysctl reads. Reading /proc/sys/kernel/shm_rmid_forced should not take shm_ids rwsem for write and walk all segments. Only run the cleanup when the sysctl is written and the forced RMID policy is enabled. When shm_rmid_forced=1, monitoring tools that read /proc/sys/kernel/shm_rmid_forced trigger the cleanup on every read. Link: https://lore.kernel.org/all/?q=only+destroy+orphaned+shm+segments+on+sysctl+write Link: https://lore.kernel.org/tencent_738A8BC6E9EA205F555E4B0DAA154D4F8E0A@qq.com Signed-off-by: Jianlin Shi <shijianlin11@foxmail.com> Acked-by: Davidlohr Bueso <dave@stgolabs.net> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'ipc/ipc_sysctl.c')
-rw-r--r--ipc/ipc_sysctl.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
index 9b087ebeb643..d038d944257f 100644
--- a/ipc/ipc_sysctl.c
+++ b/ipc/ipc_sysctl.c
@@ -28,7 +28,7 @@ static int proc_ipc_dointvec_minmax_orphans(const struct ctl_table *table, int w
if (err < 0)
return err;
- if (ns->shm_rmid_forced)
+ if (write && ns->shm_rmid_forced)
shm_destroy_orphaned(ns);
return err;
}