mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 net] net/802/mrp: fix vector attribute parsing in mrp_pdu_parse_vecattr
@ 2026-06-03  6:00 Yizhou Zhao
  2026-06-04 16:00 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Yizhou Zhao @ 2026-06-03  6:00 UTC (permalink / raw)
  To: netdev
  Cc: Yizhou Zhao, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, linux-kernel, Yuxiang Yang, Ao Wang,
	Xuewei Feng, Qi Li, Ke Xu

In mrp_pdu_parse_vecattr(), vector attribute events are encoded three
per byte and valen tracks the number of events left to process.

The parser decrements valen after processing the first and second events
from each event byte, but not after processing the third one. When valen
is exactly a multiple of three, the loop continues after the last valid
event and consumes the next byte as a new event byte, applying a
spurious event to the MRP applicant state.

Additionally, when valen is zero the parser unconditionally consumes
attrlen bytes as FirstValue and advances the offset, even though per
IEEE 802.1ak a VectorAttribute with only a LeaveAllEvent has valen of
zero and no FirstValue or Vector fields. This corrupts the offset for
subsequent PDU parsing.

Also, when valen exceeds three the loop crosses byte boundaries but
the attribute value is not incremented between the last event of one
byte and the first event of the next. This causes the first event of
the next byte to use the same attribute value as the third event
rather than the next consecutive value.

Decrement valen after processing the third event, skip FirstValue
consumption when valen is zero, and increment the attribute value at
the end of each loop iteration.

Fixes: febf018d2234 ("net/802: Implement Multiple Registration Protocol (MRP)")
Reported-by: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn>
Reported-by: Yuxiang Yang <yangyx22@mails.tsinghua.edu.cn>
Reported-by: Ao Wang <wangao@seu.edu.cn>
Reported-by: Xuewei Feng <fengxw06@126.com>
Reported-by: Qi Li <qli01@tsinghua.edu.cn>
Reported-by: Ke Xu <xuke@tsinghua.edu.cn>
Assisted-by: GLM:GLM-5.1
Signed-off-by: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn>
---
Changes in v2:
- Add early return when valen is 0 to skip FirstValue consumption,
  addressing the offset corruption noted by Simon Horman
- Add mrp_attrvalue_inc() at the end of each loop iteration to
  correctly advance the attribute value across byte boundaries,
  also noted by Simon Horman
- Link to v1: https://lore.kernel.org/netdev/20260527084624.43057-1-zhaoyz24@mails.tsinghua.edu.cn/
---
diff --git a/net/802/mrp.c b/net/802/mrp.c
index ff0e80574..160a3b145 100644
--- a/net/802/mrp.c
+++ b/net/802/mrp.c
@@ -703,6 +703,12 @@ static int mrp_pdu_parse_vecattr(struct mrp_applicant *app,
 	valen = be16_to_cpu(get_unaligned(&mrp_cb(skb)->vah->lenflags) &
 			    MRP_VECATTR_HDR_LEN_MASK);

+	/* If valen is 0, only a LeaveAllEvent is present; FirstValue and
+	 * Vector fields are absent per IEEE 802.1ak.
+	 */
+	if (valen == 0)
+		return 0;
+
 	/* The VectorAttribute structure in a PDU carries event information
 	 * about one or more attributes having consecutive values. Only the
 	 * value for the first attribute is contained in the structure. So
@@ -753,6 +759,9 @@ static int mrp_pdu_parse_vecattr(struct mrp_applicant *app,
 		vaevents %= __MRP_VECATTR_EVENT_MAX;
 		vaevent = vaevents;
 		mrp_pdu_parse_vecattr_event(app, skb, vaevent);
+		valen--;
+		mrp_attrvalue_inc(mrp_cb(skb)->attrvalue,
+				  mrp_cb(skb)->mh->attrlen);
 	}
 	return 0;
 }


--
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 net] net/802/mrp: fix vector attribute parsing in mrp_pdu_parse_vecattr
  2026-06-03  6:00 [PATCH v2 net] net/802/mrp: fix vector attribute parsing in mrp_pdu_parse_vecattr Yizhou Zhao
@ 2026-06-04 16:00 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-06-04 16:00 UTC (permalink / raw)
  To: Yizhou Zhao
  Cc: netdev, davem, edumazet, kuba, pabeni, horms, linux-kernel,
	yangyx22, wangao, fengxw06, qli01, xuke

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed,  3 Jun 2026 14:00:13 +0800 you wrote:
> In mrp_pdu_parse_vecattr(), vector attribute events are encoded three
> per byte and valen tracks the number of events left to process.
> 
> The parser decrements valen after processing the first and second events
> from each event byte, but not after processing the third one. When valen
> is exactly a multiple of three, the loop continues after the last valid
> event and consumes the next byte as a new event byte, applying a
> spurious event to the MRP applicant state.
> 
> [...]

Here is the summary with links:
  - [v2,net] net/802/mrp: fix vector attribute parsing in mrp_pdu_parse_vecattr
    https://git.kernel.org/netdev/net/c/7561c7fbc694

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-04 16:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-03  6:00 [PATCH v2 net] net/802/mrp: fix vector attribute parsing in mrp_pdu_parse_vecattr Yizhou Zhao
2026-06-04 16:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®