Skip to content

Commit

Permalink
ioam6: improve checks on user data
Browse files Browse the repository at this point in the history
This patch improves two checks on user data.

The first one prevents bit 23 from being set, as specified by RFC 9197
(Sec 4.4.1):

  Bit 23    Reserved; MUST be set to zero upon transmission and be
            ignored upon receipt.  This bit is reserved to allow for
            future extensions of the IOAM Trace-Type bit field.

The second one checks that the tunnel destination address !=
IPV6_ADDR_ANY, just like we already do for the tunnel source address.

Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
Link: https://patch.msgid.link/20240830191919.51439-1-justin.iurman@uliege.be
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Justin Iurman authored and Jakub Kicinski committed Sep 3, 2024
1 parent 54f1a10 commit 1a5c486
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions net/ipv6/ioam6_iptunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static bool ioam6_validate_trace_hdr(struct ioam6_trace_hdr *trace)
trace->type.bit12 | trace->type.bit13 | trace->type.bit14 |
trace->type.bit15 | trace->type.bit16 | trace->type.bit17 |
trace->type.bit18 | trace->type.bit19 | trace->type.bit20 |
trace->type.bit21)
trace->type.bit21 | trace->type.bit23)
return false;

trace->nodelen = 0;
Expand Down Expand Up @@ -199,9 +199,17 @@ static int ioam6_build_state(struct net *net, struct nlattr *nla,
}
}

if (tb[IOAM6_IPTUNNEL_DST])
if (tb[IOAM6_IPTUNNEL_DST]) {
ilwt->tundst = nla_get_in6_addr(tb[IOAM6_IPTUNNEL_DST]);

if (ipv6_addr_any(&ilwt->tundst)) {
NL_SET_ERR_MSG_ATTR(extack, tb[IOAM6_IPTUNNEL_DST],
"invalid tunnel dest address");
err = -EINVAL;
goto free_cache;
}
}

tuninfo = ioam6_lwt_info(lwt);
tuninfo->eh.hdrlen = ((sizeof(*tuninfo) + len_aligned) >> 3) - 1;
tuninfo->pad[0] = IPV6_TLV_PADN;
Expand Down

0 comments on commit 1a5c486

Please sign in to comment.