lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CAEy91+YmfCeA6Y29Bf2Cunk5L3Wrif=1tRFxBOc6iPO6JEtBpw@mail.gmail.com>
Date: Fri, 27 Jun 2025 18:16:19 +0530
From: ritu pal <ritupal888@...il.com>
To: linux-kernel@...r.kernel.org, Christian Brauner <brauner@...nel.org>, 
	Al Viro <viro@...iv.linux.org.uk>, Ritu Pal <ritupal888@...il.com>, 
	NeilBrown <neil@...wn.name>, Chen Ni <nichen@...as.ac.cn>
Subject: ipc/mqueue: release spinlock before freeing node_cache in mqueue_evict_inode()

Currently, mqueue_evict_inode() holds info->lock while freeing info->node_cache
with kfree(). Although kfree() does not sleep, it may take a non-trivial amount
of time, increasing the duration the spinlock is held and potentially impacting
concurrency.

This change moves the kfree(info->node_cache) call outside the critical section,
releasing the spinlock before freeing memory. This reduces lock contention and
follows kernel best practices of minimising the time spent holding spinlocks,
especially around potentially slow operations.

No functional change intended.
Signed-off-by: Ritu Pal <ritupal888@...il.com>
---
 ipc/mqueue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 82ed2d3c9846..897caf55e217 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -526,8 +526,8 @@ static void mqueue_evict_inode(struct inode *inode)
  spin_lock(&info->lock);
  while ((msg = msg_get(info)) != NULL)
  list_add_tail(&msg->m_list, &tmp_msg);
- kfree(info->node_cache);
  spin_unlock(&info->lock);
+ kfree(info->node_cache);

  list_for_each_entry_safe(msg, nmsg, &tmp_msg, m_list) {
  list_del(&msg->m_list);
--
2.39.5 (Apple Git-154)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ