]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
xfrm: Refuse to insert 32 bit userspace socket policies on 64 bit systems
authorSteffen Klassert <steffen.klassert@secunet.com>
Thu, 1 Feb 2018 07:49:23 +0000 (08:49 +0100)
committerSasha Levin <alexander.levin@microsoft.com>
Wed, 23 May 2018 01:33:57 +0000 (21:33 -0400)
[ Upstream commit 19d7df69fdb2636856dc8919de72fc1bf8f79598 ]

We don't have a compat layer for xfrm, so userspace and kernel
structures have different sizes in this case. This results in
a broken configuration, so refuse to configure socket policies
when trying to insert from 32 bit userspace as we do it already
with policies inserted via netlink.

Reported-and-tested-by: syzbot+e1a1577ca8bcb47b769a@syzkaller.appspotmail.com
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
net/xfrm/xfrm_state.c

index 560a1164a21d12f34cb3cb15ef5d369801b4934d..1c4a8dad580c1885639177d6f5c84d3018d4f0df 100644 (file)
@@ -1845,6 +1845,11 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen
        struct xfrm_mgr *km;
        struct xfrm_policy *pol = NULL;
 
+#ifdef CONFIG_COMPAT
+       if (is_compat_task())
+               return -EOPNOTSUPP;
+#endif
+
        if (!optval && !optlen) {
                xfrm_sk_policy_insert(sk, XFRM_POLICY_IN, NULL);
                xfrm_sk_policy_insert(sk, XFRM_POLICY_OUT, NULL);