diff options
author | Sabrina Dubroca <sd@queasysnail.net> | 2017-12-31 10:18:56 -0500 |
---|---|---|
committer | Steffen Klassert <steffen.klassert@secunet.com> | 2017-12-31 10:29:24 -0500 |
commit | 2f10a61cee8fdb9f8da90f5db687e1862b22cf06 (patch) | |
tree | ce6216dcf1b159f1c63a130778fe81105a3bd8fb | |
parent | 4e765b4972af7b07adcb1feb16e7a525ce1f6b28 (diff) |
xfrm: fix rcu usage in xfrm_get_type_offload
request_module can sleep, thus we cannot hold rcu_read_lock() while
calling it. The function also jumps back and takes rcu_read_lock()
again (in xfrm_state_get_afinfo()), resulting in an imbalance.
This codepath is triggered whenever a new offloaded state is created.
Fixes: ffdb5211da1c ("xfrm: Auto-load xfrm offload modules")
Reported-by: syzbot+ca425f44816d749e8eb49755567a75ee48cf4a30@syzkaller.appspotmail.com
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
-rw-r--r-- | net/xfrm/xfrm_state.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 1e80f68e2266..429957412633 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
@@ -313,13 +313,14 @@ retry: | |||
313 | if ((type && !try_module_get(type->owner))) | 313 | if ((type && !try_module_get(type->owner))) |
314 | type = NULL; | 314 | type = NULL; |
315 | 315 | ||
316 | rcu_read_unlock(); | ||
317 | |||
316 | if (!type && try_load) { | 318 | if (!type && try_load) { |
317 | request_module("xfrm-offload-%d-%d", family, proto); | 319 | request_module("xfrm-offload-%d-%d", family, proto); |
318 | try_load = 0; | 320 | try_load = 0; |
319 | goto retry; | 321 | goto retry; |
320 | } | 322 | } |
321 | 323 | ||
322 | rcu_read_unlock(); | ||
323 | return type; | 324 | return type; |
324 | } | 325 | } |
325 | 326 | ||