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>] [thread-next>] [day] [month] [year] [list]
Message-ID: <47E87F2A.2040303@bk.jp.nec.com>
Date:	Tue, 25 Mar 2008 13:27:22 +0900
From:	Atsushi Tsuji <a-tsuji@...jp.nec.com>
To:	Oleg Nesterov <oleg@...sign.ru>
CC:	linux-kernel@...r.kernel.org
Subject: [PATCH] kill_something_info: don't take tasklist_lock for pid==-1
 case

Hi Oleg,

Thanks for some patches about tasklist_lock. The avoidance of
tasklist_lock is very important for us.  And now, I found another
avoidable tasklist_lock, and made the patch. Could you please have a
look?

This patch avoid taking tasklist_lock in kill_something_info() when
the pid is -1. It can convert to rcu_read_lock() for this case because
group_send_sig_info() doesn't need tasklist_lock.

This patch is for 2.6.25-rc5-mm1.

Signed-off-by: Atsushi Tsuji <a-tsuji@...jp.nec.com>
---
diff --git a/kernel/signal.c b/kernel/signal.c
index 3edbfd4..a888c58 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1089,14 +1089,16 @@ static int kill_something_info(int sig, struct siginfo 
*info, int pid)
  		return ret;
  	}

-	read_lock(&tasklist_lock);
  	if (pid != -1) {
+		read_lock(&tasklist_lock);
  		ret = __kill_pgrp_info(sig, info,
  				pid ? find_vpid(-pid) : task_pgrp(current));
+		read_unlock(&tasklist_lock);
  	} else {
  		int retval = 0, count = 0;
  		struct task_struct * p;

+		rcu_read_lock();
  		for_each_process(p) {
  			if (p->pid > 1 && !same_thread_group(p, current)) {
  				int err = group_send_sig_info(sig, info, p);
@@ -1106,8 +1108,8 @@ static int kill_something_info(int sig, struct siginfo 
*info, int pid)
  			}
  		}
  		ret = count ? retval : -ESRCH;
+		rcu_read_unlock();
  	}
-	read_unlock(&tasklist_lock);

  	return ret;
  }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ