Re: [PATCH net-next 2/4] tools: ynl: reject zero-length attributes instead of looping forever
From: Jakub Kicinski
Date: Thu Sep 10 2026 - 22:25:20 EST
On Tue, 08 Sep 2026 19:45:08 -0400 Taylor Bates wrote:
> The BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS payload the kernel then sends:
>
> 34 00 02 00 MDBA_ROUTER, len 52
> 30 00 01 00 MDBA_ROUTER_PORT, len 48
> 08 00 00 00 bare ifindex 8, written by nla_put_nohdr()
> 08 00 01 00 MDBA_ROUTER_PATTR_TIMER, len 8
> 00 00 00 00 timer value, 0 for a permanent router
Sounds like the family outputs garbage and should not be supported.
> while offset < len(msg):
> attr = NlAttr(msg, offset)
> + if attr.full_len < 4:
> + raise YnlException(
> + f'Malformed attribute at offset {offset}: '
> + f'length {attr.payload_len} is shorter than the header')
> offset += attr.full_len
> self.attrs.append(attr)
Not sure i follow you logic. If anything I'd have written:
if len(msg) - offset < 4:
raise ...short, not overly verbose msg")
? But again, if the kernel is not outputting valid attrs that's not
YNL's problem.