Re: [PATCH] sys_getppid oopses on debug kernel (v2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Andrew Morton wrote:
> Although I'm not sure it's needed for this problem. A getppid() which does
> asmlinkage long sys_getppid(void)
> {
> 	int pid;
> 	read_lock(&tasklist_lock);
> 	pid = current->group_leader->real_parent->tgid;
> 	read_unlock(&tasklist_lock);
> 	return pid;
> }
> seems like a fine implementation to me ;)

Why do we need to use ->group_leader? All threads should have the same

Why do we need tasklist_lock? I think rcu_read_lock() is enough.

In other words, do you see any problems with this code

	smlinkage long sys_getppid(void)
		int pid;

		pid = rcu_dereference(current->real_parent)->tgid;

		return pid;

? Yes, we may read a stale value for ->real_parent, but the memory
can't be freed while we are under rcu_read_lock(). And in this case
the returned value is ok because the task could be reparented just
after return anyway.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at
Please read the FAQ at

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux