linux-alpha.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* getxpid() parent lookup is broken
@ 2010-09-26  4:34 Ben Hutchings
  2012-05-29  4:55 ` Matt Turner
  0 siblings, 1 reply; 4+ messages in thread
From: Ben Hutchings @ 2010-09-26  4:34 UTC (permalink / raw)
  To: linux-alpha

[-- Attachment #1: Type: text/plain, Size: 1244 bytes --]

I noticed that Tomoyo doesn't build on Alpha because Tomoyo tries to
call sys_getpid() and sys_getppid().  That's a bug in Tomoyo, but when I
looked at why Alpha is different I found that the implementation of
getxpid() hasn't been kept in sync getppid() for other architectures and
is presumably now incorrect.

sys_getppid():
	rcu_read_lock();
	pid = task_tgid_vnr(current->real_parent);
	rcu_read_unlock();

task_tgid_vnr(current->real_parent) expands through various inline
functions to:

pid_nr_ns(current->real_parent->group_leader->pids[PIDTYPE_PID].pid,
          current->nsproxy->pid_ns)

sys_getxpid():
	/* See linux/kernel/timer.c sys_getppid for discussion
	   about this loop.  */
	ldq	$3, TASK_GROUP_LEADER($2)
	ldq	$4, TASK_REAL_PARENT($3)
	ldl	$0, TASK_TGID($2)
1:	ldl	$1, TASK_TGID($4)
#ifdef CONFIG_SMP
	mov	$4, $5
	mb
	ldq	$3, TASK_GROUP_LEADER($2)
	ldq	$4, TASK_REAL_PARENT($3)
	cmpeq	$4, $5, $5
	beq	$5, 1b
#endif

The comment is obviously out-of-date.  This isn't following RCU protocol
and it isn't namespace-aware.  I think it needs to be turned into a
wrapper for the generic code.

Ben.

-- 
Ben Hutchings
Once a job is fouled up, anything done to improve it makes it worse.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-05-29 14:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-26  4:34 getxpid() parent lookup is broken Ben Hutchings
2012-05-29  4:55 ` Matt Turner
2012-05-29 14:09   ` Al Viro
2012-05-29 14:18     ` Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).