]> git.baikalelectronics.ru Git - kernel.git/commit
tipc: fix race in disc create/delete
authorYing Xue <ying.xue@windriver.com>
Mon, 21 Apr 2014 02:55:52 +0000 (10:55 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 23 Apr 2014 01:17:53 +0000 (21:17 -0400)
commit581f4d93348c768af9eed99a3bc36689b8ad3c79
tree02d52832745176ee6d63579f50d375caddd1fc62
parentadabbb0081e8d3b0824cd4aa0666127c83c23655
tipc: fix race in disc create/delete

Commit 4f5eba29e0236742f8cd865d33210df5c3b5c206 (tipc: fix neighbor
detection problem after hw address change) introduces a race condition
involving tipc_disc_delete() and tipc_disc_add/remove_dest that can
cause TIPC to dereference the pointer to the bearer discovery request
structure after it has been freed since a stray pointer is left in the
bearer structure.

In order to fix the issue, the process of resetting the discovery
request handler is optimized: the discovery request handler and request
buffer are just reset instead of being freed, allocated and initialized.
As the request point is always valid and the request's lock is taken
while the request handler is reset, the race doesn't happen any more.

Reported-by: Erik Hugne <erik.hugne@ericsson.com>
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Tested-by: Erik Hugne <erik.hugne@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/bearer.c
net/tipc/discover.c
net/tipc/discover.h