Skip to content

Commit

Permalink
xfrm: add extack to xfrm_set_spdinfo
Browse files Browse the repository at this point in the history
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
  • Loading branch information
Sabrina Dubroca authored and Steffen Klassert committed Nov 25, 2022
1 parent c2dad11 commit a741721
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions net/xfrm/xfrm_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -1367,20 +1367,28 @@ static int xfrm_set_spdinfo(struct sk_buff *skb, struct nlmsghdr *nlh,
if (attrs[XFRMA_SPD_IPV4_HTHRESH]) {
struct nlattr *rta = attrs[XFRMA_SPD_IPV4_HTHRESH];

if (nla_len(rta) < sizeof(*thresh4))
if (nla_len(rta) < sizeof(*thresh4)) {
NL_SET_ERR_MSG(extack, "Invalid SPD_IPV4_HTHRESH attribute length");
return -EINVAL;
}
thresh4 = nla_data(rta);
if (thresh4->lbits > 32 || thresh4->rbits > 32)
if (thresh4->lbits > 32 || thresh4->rbits > 32) {
NL_SET_ERR_MSG(extack, "Invalid hash threshold (must be <= 32 for IPv4)");
return -EINVAL;
}
}
if (attrs[XFRMA_SPD_IPV6_HTHRESH]) {
struct nlattr *rta = attrs[XFRMA_SPD_IPV6_HTHRESH];

if (nla_len(rta) < sizeof(*thresh6))
if (nla_len(rta) < sizeof(*thresh6)) {
NL_SET_ERR_MSG(extack, "Invalid SPD_IPV6_HTHRESH attribute length");
return -EINVAL;
}
thresh6 = nla_data(rta);
if (thresh6->lbits > 128 || thresh6->rbits > 128)
if (thresh6->lbits > 128 || thresh6->rbits > 128) {
NL_SET_ERR_MSG(extack, "Invalid hash threshold (must be <= 128 for IPv6)");
return -EINVAL;
}
}

if (thresh4 || thresh6) {
Expand Down

0 comments on commit a741721

Please sign in to comment.