All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-core] xnpipe: Racy input_handler business
@ 2008-12-16 13:35 Jan Kiszka
  2008-12-16 14:21 ` [Xenomai-core] [PATCH] xnpipe: Fix racy callback handlers Jan Kiszka
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Kiszka @ 2008-12-16 13:35 UTC (permalink / raw)
  To: xenomai-core

Hi,

someone just dumped another kernel oops on my desk which points to the
xnpipe subsystem: xnpipe_release was called, invoking
__pipe_input_handler ie. the registered input_handler of the native pipe
services. And that handler tried to call an invalid monitor callback
(but no one ever set a monitor handler).

So I looked at how the nucleus deals with input_handler registration,
deregistration, and invocation where it also passes some cookie that
points to the native pipe object here. Looks like that code is racy /wrt
concurrent cleanup of kernel and user side.

What is the intended locking policy when dereferencing the tuple of
xnpipe_state_t.input_handler and xnpipe_state_t.cookie? Sometimes the
handler is called under nklock, sometimes only both values are obtained
and then nklock is dropped before invoking the handler (which is bogus
as cookie may become invalid in the meantime). Even worse,
xnpipe_release does not care at all about locking when calling
input_handler as its last duty - and that's obviously where my customer
just caught an oops.

In other words: Can't we always hold nklock while checking for
input_handler != NULL and then invoking it with the corresponding
cookie? This will just require us to properly clear input_handler on
xnpipe_disconnect.

Jan

-- 
Siemens AG, Corporate Technology, CT SE 26
Corporate Competence Center Embedded Linux


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

end of thread, other threads:[~2008-12-16 14:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-16 13:35 [Xenomai-core] xnpipe: Racy input_handler business Jan Kiszka
2008-12-16 14:21 ` [Xenomai-core] [PATCH] xnpipe: Fix racy callback handlers Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.