diff options
author | Dmitry Safonov <dima@arista.com> | 2020-09-21 15:36:56 +0100 |
---|---|---|
committer | Steffen Klassert <steffen.klassert@secunet.com> | 2020-09-24 08:53:04 +0200 |
commit | 96392ee5a13b992563cfe07d23ee30d333b89126 (patch) | |
tree | b0ef5dc0aaa0325c06151cbb6b5108680ef2749b /net/xfrm/xfrm_state.c | |
parent | 5106f4a8acff480e244300bc5097c0ad7048c3a2 (diff) | |
download | linux-96392ee5a13b992563cfe07d23ee30d333b89126.tar.gz linux-96392ee5a13b992563cfe07d23ee30d333b89126.tar.bz2 linux-96392ee5a13b992563cfe07d23ee30d333b89126.zip |
xfrm/compat: Translate 32-bit user_policy from sockptr
Provide compat_xfrm_userpolicy_info translation for xfrm setsocketopt().
Reallocate buffer and put the missing padding for 64-bit message.
Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'net/xfrm/xfrm_state.c')
-rw-r--r-- | net/xfrm/xfrm_state.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index cc206ca3df78..f9961884500b 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c @@ -2331,9 +2331,6 @@ int xfrm_user_policy(struct sock *sk, int optname, sockptr_t optval, int optlen) struct xfrm_mgr *km; struct xfrm_policy *pol = NULL; - if (in_compat_syscall()) - return -EOPNOTSUPP; - if (sockptr_is_null(optval) && !optlen) { xfrm_sk_policy_insert(sk, XFRM_POLICY_IN, NULL); xfrm_sk_policy_insert(sk, XFRM_POLICY_OUT, NULL); @@ -2348,6 +2345,20 @@ int xfrm_user_policy(struct sock *sk, int optname, sockptr_t optval, int optlen) if (IS_ERR(data)) return PTR_ERR(data); + if (in_compat_syscall()) { + struct xfrm_translator *xtr = xfrm_get_translator(); + + if (!xtr) + return -EOPNOTSUPP; + + err = xtr->xlate_user_policy_sockptr(&data, optlen); + xfrm_put_translator(xtr); + if (err) { + kfree(data); + return err; + } + } + err = -EINVAL; rcu_read_lock(); list_for_each_entry_rcu(km, &xfrm_km_list, list) { |