Skip to contentSkip to conversation

PATCH: Lock tty directly in acct layer

PATCH Alan Cox 2 participants 3 messages Aug 16, 2006

lore
Share & tools
lore

Alan Cox

author
#0 lore raw
kernel/acct.c +2 -2
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.18-rc4-mm1/kernel/acct.c linux-2.6.18-rc4-mm1/kernel/acct.c
@@ -483,10 +484,10 @@
 	ac.ac_ppid = current->parent->tgid;
 #endif
 
-	read_lock(&tasklist_lock);	/* pin current->signal */
+	mutex_lock(&tty_mutex);
 	ac.ac_tty = current->signal->tty ?
 		old_encode_dev(tty_devnum(current->signal->tty)) : 0;
-	read_unlock(&tasklist_lock);
+	mutex_unlock(&tty_mutex);
 
 	spin_lock_irq(&current->sighand->siglock);
 	ac.ac_utime = encode_comp_t(jiffies_to_AHZ(cputime_to_jiffies(pacct->ac_utime)));
#1 lore raw

kernel/acct.c line 488

Quoted 12 lines · Alan Cox

diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.18-rc4-mm1/kernel/acct.c linux-2.6.18-rc4-mm1/kernel/acct.c

kernel/acct.c +1 -1
@@ -483,10 +484,10 @@
 	ac.ac_ppid = current->parent->tgid;
 #endif
 
-	read_lock(&tasklist_lock);	/* pin current->signal */
+	mutex_lock(&tty_mutex);
 	ac.ac_tty = current->signal->tty ?

but.. can't ->signal still change, even if signal->tty isn't ?

Signature · 1 line
if you want to mail me at work (you don't), use arjan (at) linux.intel.com
author
#2 lore raw

Ar Mer, 2006-08-16 am 18:24 +0200, ysgrifennodd Arjan van de Ven:

Quoted 5 lines

kernel/acct.c line 488

Quoted 3 lines
kernel/acct.c +1 -1
-	read_lock(&tasklist_lock);	/* pin current->signal */
+	mutex_lock(&tty_mutex);
 	ac.ac_tty = current->signal->tty ?

but.. can't ->signal still change, even if signal->tty isn't ?

I'm not sure, thats a good question (as if so is how to lock it). Will investigate.