mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jianlin Shi <shijianlin11@foxmail.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] ipc: only destroy orphaned shm segments on sysctl write
Date: Tue,  2 Jun 2026 10:34:51 +0800	[thread overview]
Message-ID: <tencent_C93259A588148F1AF774C0689A68BAAE3806@qq.com> (raw)

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.

Signed-off-by: Jianlin Shi <shijianlin11@foxmail.com>
---
 ipc/ipc_sysctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
index 71d0a4ef5..8bf0e9a5f 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;
 }
-- 
2.43.0


             reply	other threads:[~2026-06-02  2:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-02  2:34 Jianlin Shi [this message]
2026-06-15  2:27 ` [PATCH v2] " Jianlin Shi
2026-06-25 23:06   ` Andrew Morton
2026-07-27  4:44     ` Jianlin Shi
2026-07-30 19:32     ` Davidlohr Bueso

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=tencent_C93259A588148F1AF774C0689A68BAAE3806@qq.com \
    --to=shijianlin11@foxmail.com \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®