ipsec-2023-03-15
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEH7ZpcWbFyOOp6OJbrB3Eaf9PW7cFAmQRocUACgkQrB3Eaf9P W7fmcA/+IrOhVd0sw4coM29SydA5nNgGr/w+hsAnTLOjO+CMBfhx2k6KV6BJndwT hZdrNildGAHQu1C1hyedK1I7bqGBrPxKSJBvRQzehyZnqIONQcdSG1+bl2ie3r/4 2YCazVIsyW5zromrvlmbItXBtzR6aEVoGcKoM5yFui95TYnMqYXud5W/8jy3rQ94 VHiWZBXcWhuSrfRZFHC4hinj3IZRrs6OGTcNYgvJN7LaP3i+IesWcCYilSk6cwRb 8+qxIOc2FU3/9iIFtwGOMvxeFfWOcUKOY96ZlbNZsZ9HzoHGLnVzGDu9N/k/B5Pp S7yCI1nbQaod0dWZ9flXubIdvfChDFsJxSwgBnax8yBYypcqHqkp+nlTNSm1zyt4 MUa3y2zcCEGx7O5Mn8gWS4wOUZWPH2/8kyL3QWUeXP963TZO8dZXHbRRn/TjofCJ rLTzh6NXcVMo9H+koGk5/lL/EOmHm94ra6btHB1w1BSVpe1i5TsbLGdl66BXflCB TCeAfAWiRWVP/mzga6DWVNj13vkVYEJPOTnccPJgcbP9UmwjBKcl83fFTwC91hmv TEXGyTB9fcPaJod0Q6TaemyM52EsJN7JJoJ1WFge9rfgBlle0YoWwNWkuB0FmkZR /VEKDrhLOS8kZ5887vtw1xb3sNTspSAkMdfnfQQ01N5B8XS4eCQ= =h5yU -----END PGP SIGNATURE----- Merge tag 'ipsec-2023-03-15' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec Steffen Klassert says: ==================== pull request (net): ipsec 2023-03-15 1) Fix an information leak when dumping algos and encap. From Herbert Xu 2) Allow transport-mode states with AF_UNSPEC selector to allow for nested transport-mode states. From Herbert Xu. * tag 'ipsec-2023-03-15' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec: xfrm: Allow transport-mode states with AF_UNSPEC selector xfrm: Zero padding when dumping algos and encap ==================== Link: https://lore.kernel.org/r/20230315105623.1396491-1-steffen.klassert@secunet.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
84770d1249
|
@ -2815,11 +2815,6 @@ int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload,
|
|||
goto error;
|
||||
}
|
||||
|
||||
if (!(inner_mode->flags & XFRM_MODE_FLAG_TUNNEL)) {
|
||||
NL_SET_ERR_MSG(extack, "Only tunnel modes can accommodate an AF_UNSPEC selector");
|
||||
goto error;
|
||||
}
|
||||
|
||||
x->inner_mode = *inner_mode;
|
||||
|
||||
if (x->props.family == AF_INET)
|
||||
|
|
|
@ -1012,7 +1012,9 @@ static int copy_to_user_aead(struct xfrm_algo_aead *aead, struct sk_buff *skb)
|
|||
return -EMSGSIZE;
|
||||
|
||||
ap = nla_data(nla);
|
||||
memcpy(ap, aead, sizeof(*aead));
|
||||
strscpy_pad(ap->alg_name, aead->alg_name, sizeof(ap->alg_name));
|
||||
ap->alg_key_len = aead->alg_key_len;
|
||||
ap->alg_icv_len = aead->alg_icv_len;
|
||||
|
||||
if (redact_secret && aead->alg_key_len)
|
||||
memset(ap->alg_key, 0, (aead->alg_key_len + 7) / 8);
|
||||
|
@ -1032,7 +1034,8 @@ static int copy_to_user_ealg(struct xfrm_algo *ealg, struct sk_buff *skb)
|
|||
return -EMSGSIZE;
|
||||
|
||||
ap = nla_data(nla);
|
||||
memcpy(ap, ealg, sizeof(*ealg));
|
||||
strscpy_pad(ap->alg_name, ealg->alg_name, sizeof(ap->alg_name));
|
||||
ap->alg_key_len = ealg->alg_key_len;
|
||||
|
||||
if (redact_secret && ealg->alg_key_len)
|
||||
memset(ap->alg_key, 0, (ealg->alg_key_len + 7) / 8);
|
||||
|
@ -1043,6 +1046,40 @@ static int copy_to_user_ealg(struct xfrm_algo *ealg, struct sk_buff *skb)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int copy_to_user_calg(struct xfrm_algo *calg, struct sk_buff *skb)
|
||||
{
|
||||
struct nlattr *nla = nla_reserve(skb, XFRMA_ALG_COMP, sizeof(*calg));
|
||||
struct xfrm_algo *ap;
|
||||
|
||||
if (!nla)
|
||||
return -EMSGSIZE;
|
||||
|
||||
ap = nla_data(nla);
|
||||
strscpy_pad(ap->alg_name, calg->alg_name, sizeof(ap->alg_name));
|
||||
ap->alg_key_len = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int copy_to_user_encap(struct xfrm_encap_tmpl *ep, struct sk_buff *skb)
|
||||
{
|
||||
struct nlattr *nla = nla_reserve(skb, XFRMA_ENCAP, sizeof(*ep));
|
||||
struct xfrm_encap_tmpl *uep;
|
||||
|
||||
if (!nla)
|
||||
return -EMSGSIZE;
|
||||
|
||||
uep = nla_data(nla);
|
||||
memset(uep, 0, sizeof(*uep));
|
||||
|
||||
uep->encap_type = ep->encap_type;
|
||||
uep->encap_sport = ep->encap_sport;
|
||||
uep->encap_dport = ep->encap_dport;
|
||||
uep->encap_oa = ep->encap_oa;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xfrm_smark_put(struct sk_buff *skb, struct xfrm_mark *m)
|
||||
{
|
||||
int ret = 0;
|
||||
|
@ -1098,12 +1135,12 @@ static int copy_to_user_state_extra(struct xfrm_state *x,
|
|||
goto out;
|
||||
}
|
||||
if (x->calg) {
|
||||
ret = nla_put(skb, XFRMA_ALG_COMP, sizeof(*(x->calg)), x->calg);
|
||||
ret = copy_to_user_calg(x->calg, skb);
|
||||
if (ret)
|
||||
goto out;
|
||||
}
|
||||
if (x->encap) {
|
||||
ret = nla_put(skb, XFRMA_ENCAP, sizeof(*x->encap), x->encap);
|
||||
ret = copy_to_user_encap(x->encap, skb);
|
||||
if (ret)
|
||||
goto out;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue