Re: [PATCH] proc: Disable /proc/$pid/wchan

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

 



On Wed, Sep 29, 2021 at 11:54:55AM -0700, Kees Cook wrote:

> > > > > > It's supposed to show where a blocked task is blocked; the "wait
> > > > > > channel".

> Since I think we're considering get_wchan() to be slow-path, can we just
> lock the runqueue and use arch_stack_walk_reliable()?

Funny thing, when a task is blocked it isn't on the runqueue :-)

So if all we want to do is capture a blocked task and fail otherwise we
don't need the rq->lock at all.

Something like:

	unsigned long ip = 0;

	raw_spin_lock_irq(&p->pi_lock);
	state = READ_ONCE(p->__state);
	smp_rmb(); /* see try_to_wake_up() */
	if (state == TASK_RUNNING || state == TASK_WAKING || p->on_rq)
		goto unlock;

	ip = /* do actual stack walk on a blocked task */
unlock:
	raw_spin_unlock_irq(&p->pi_lock);

	return ip;


Should get us there.




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux