]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
xfrm: fix rcu usage in xfrm_get_type_offload
authorSabrina Dubroca <sd@queasysnail.net>
Sun, 31 Dec 2017 15:18:56 +0000 (16:18 +0100)
committerSteffen Klassert <steffen.klassert@secunet.com>
Sun, 31 Dec 2017 15:29:24 +0000 (16:29 +0100)
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>
net/xfrm/xfrm_state.c

index 1e80f68e226665e5393dd07eeeaaf9fa7090ca9b..42995741263386852b61a6a72a23669f4d134b5b 100644 (file)
@@ -313,13 +313,14 @@ retry:
        if ((type && !try_module_get(type->owner)))
                type = NULL;
 
+       rcu_read_unlock();
+
        if (!type && try_load) {
                request_module("xfrm-offload-%d-%d", family, proto);
                try_load = 0;
                goto retry;
        }
 
-       rcu_read_unlock();
        return type;
 }