* [PATCH net] net: hsr: don't take the PRP RCT from host frame payloads
@ 2026-12-02 16:50 Andrew Stellman
2026-12-03 16:00 ` Daniel Machon
2026-12-03 17:03 ` netdev-bot+sashiko
0 siblings, 2 replies; 3+ messages in thread
From: Andrew Stellman @ 2026-12-02 16:50 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Willem de Bruijn, Felix Maurer, Luka Gejak,
Fernando Fernandez Mancera, Shaurya Rane, Xin Xie, netdev
From: Andrew Stellman <astellman@stellman-greene.com>
prp_fill_frame_info() looks for a Redundancy Control Trailer (RCT) at
the end of every frame, including frames sent through the PRP master.
If a UDP payload ends in bytes that look like an RCT, the frame goes
out with no new RCT, with the payload's sequence number and the LAN ID
written into the payload, and hsr->sequence_nr isn't advanced.
Skip the RCT check for frames received on the master port. Frames sent
through the master that already end in a valid RCT now get a second
RCT instead of having theirs reused.
Fixes: 451d8123f897 ("net: prp: add packet handling support")
Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
---
Tested on mainline 19cc08c1a6a6 (7.4.0-rc5) in arm64 QEMU with KASAN: a
UDP payload with such a tail went out as a 106-byte frame with a changed
payload before the fix, and as a 112-byte frame with the payload intact
with it.
Found with Quality Playbook
(https://github.com/andrewstellman/quality-playbook) running Claude Opus
5.5; the fix was drafted with OpenAI GPT-6 (Codex).
A reproducer is available on request.
net/hsr/hsr_forward.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
index 44f6d9c83180..6cec0d36e9e8 100644
--- a/net/hsr/hsr_forward.c
+++ b/net/hsr/hsr_forward.c
@@ -682,7 +682,8 @@ int prp_fill_frame_info(__be16 proto, struct sk_buff *skb,
/* Supervision frame */
struct prp_rct *rct = skb_get_PRP_rct(skb);
- if (rct &&
+ /* Host frames have no RCT yet, even if their payload looks like one. */
+ if (rct && frame->port_rcv->type != HSR_PT_MASTER &&
prp_check_lsdu_size(skb, rct, frame->is_supervision)) {
frame->skb_hsr = NULL;
frame->skb_std = NULL;
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net] net: hsr: don't take the PRP RCT from host frame payloads
2026-12-02 16:50 [PATCH net] net: hsr: don't take the PRP RCT from host frame payloads Andrew Stellman
@ 2026-12-03 16:00 ` Daniel Machon
2026-12-03 17:03 ` netdev-bot+sashiko
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Machon @ 2026-12-03 16:00 UTC (permalink / raw)
To: Andrew Stellman
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Willem de Bruijn, Felix Maurer, Luka Gejak,
Fernando Fernandez Mancera, Shaurya Rane, Xin Xie, netdev
Hi Andrew,
> From: Andrew Stellman <astellman@stellman-greene.com>
>
> prp_fill_frame_info() looks for a Redundancy Control Trailer (RCT) at
> the end of every frame, including frames sent through the PRP master.
> If a UDP payload ends in bytes that look like an RCT, the frame goes
> out with no new RCT, with the payload's sequence number and the LAN ID
> written into the payload, and hsr->sequence_nr isn't advanced.
>
> Skip the RCT check for frames received on the master port. Frames sent
> through the master that already end in a valid RCT now get a second
> RCT instead of having theirs reused.
>
> Fixes: 451d8123f897 ("net: prp: add packet handling support")
> Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
> ---
> Tested on mainline 19cc08c1a6a6 (7.4.0-rc5) in arm64 QEMU with KASAN: a
> UDP payload with such a tail went out as a 106-byte frame with a changed
> payload before the fix, and as a 112-byte frame with the payload intact
> with it.
> Found with Quality Playbook
> (https://github.com/andrewstellman/quality-playbook) running Claude Opus
> 5.5; the fix was drafted with OpenAI GPT-6 (Codex).
> A reproducer is available on request.
>
> net/hsr/hsr_forward.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
> index 44f6d9c83180..6cec0d36e9e8 100644
> --- a/net/hsr/hsr_forward.c
> +++ b/net/hsr/hsr_forward.c
> @@ -682,7 +682,8 @@ int prp_fill_frame_info(__be16 proto, struct sk_buff *skb,
> /* Supervision frame */
> struct prp_rct *rct = skb_get_PRP_rct(skb);
>
> - if (rct &&
> + /* Host frames have no RCT yet, even if their payload looks like one. */
> + if (rct && frame->port_rcv->type != HSR_PT_MASTER &&
What about the interlink? Same check should apply there.
> prp_check_lsdu_size(skb, rct, frame->is_supervision)) {
> frame->skb_hsr = NULL;
> frame->skb_std = NULL;
> --
> 2.53.0
>
/Daniel
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net] net: hsr: don't take the PRP RCT from host frame payloads
2026-12-02 16:50 [PATCH net] net: hsr: don't take the PRP RCT from host frame payloads Andrew Stellman
2026-12-03 16:00 ` Daniel Machon
@ 2026-12-03 17:03 ` netdev-bot+sashiko
1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sashiko @ 2026-12-03 17:03 UTC (permalink / raw)
To: bugs
Cc: davem, edumazet, kuba, pabeni, horms, willemb, fmaurer,
luka.gejak, fmancera, ssrane_b23, xiexinet, netdev
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The fix is incomplete.
--
net: hsr: don't take the PRP RCT from host frame payloads
prp_fill_frame_info() checks the end of every frame for a Redundancy
Control Trailer, including frames sent through the PRP master. This patch
skips that check for frames received on the master port, so a payload
that happens to end in RCT-like bytes is no longer treated as an RCT.
> diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
> index 44f6d9c83180a..6cec0d36e9e84 100644
> --- a/net/hsr/hsr_forward.c
> +++ b/net/hsr/hsr_forward.c
> @@ -682,7 +682,8 @@ int prp_fill_frame_info(__be16 proto, struct sk_buff *skb,
> /* Supervision frame */
> struct prp_rct *rct = skb_get_PRP_rct(skb);
>
> - if (rct &&
> + /* Host frames have no RCT yet, even if their payload looks like one. */
> + if (rct && frame->port_rcv->type != HSR_PT_MASTER &&
> prp_check_lsdu_size(skb, rct, frame->is_supervision)) {
> frame->skb_hsr = NULL;
> frame->skb_std = NULL;
[Severity: High]
Should HSR_PT_INTERLINK also be excluded here?
In PRP RedBox mode, frames arriving on the interlink come from SANs. Like
host frames, they have no RCT yet. They still go through this check, though.
handle_std_frame() already treats master and interlink the same way, as
ports whose frames get the local sequence number:
net/hsr/hsr_forward.c:handle_std_frame() {
...
if (port->type == HSR_PT_MASTER ||
port->type == HSR_PT_INTERLINK) {
/* Sequence nr for the master/interlink node */
lockdep_assert_held(&hsr->seqnr_lock);
frame->sequence_nr = hsr->sequence_nr;
WRITE_ONCE(hsr->sequence_nr, hsr->sequence_nr + 1);
}
}
hsr_handle_frame() also takes seqnr_lock around hsr_forward_skb() only for
interlink frames, because those frames are supposed to get a locally
assigned sequence number.
Suppose a SAN on the interlink sends a frame whose last 6 bytes end in
0x88FB, with the LSDU size field equal to skb->len - 14 (or skb->len - 18
with a VLAN tag). That frame takes the skb_prp path:
hsr_handle_frame()
hsr_forward_skb()
fill_frame_info()
prp_fill_frame_info()
frame->skb_prp = skb;
frame->sequence_nr = prp_get_skb_sequence_nr(rct);
The result is the same failure this patch fixes for the master port:
- frame->sequence_nr comes from the SAN's payload.
- hsr->sequence_nr is not advanced.
- handle_std_frame() is skipped, so is_from_san stays false.
prp_create_tagged_frame() then writes the LAN ID into the payload bytes in
place before cloning:
if (frame->skb_prp) {
struct prp_rct *trailer = skb_get_PRP_rct(frame->skb_prp);
if (trailer) {
prp_set_lan_id(trailer, port);
...
return skb_clone(frame->skb_prp, GFP_ATOMIC);
So the frame goes out on LAN A/B with a changed payload and no real RCT.
On local delivery, prp_get_untagged_frame() also trims the last 6 payload
bytes.
The new comment ("Host frames have no RCT yet, even if their payload looks
like one") seems to apply just as well to SAN frames bridged from the
interlink. Would a check like the following cover both cases?
frame->port_rcv->type != HSR_PT_MASTER &&
frame->port_rcv->type != HSR_PT_INTERLINK
The commit message also doesn't say why the interlink is left out.
hsr_get_node() in net/hsr/hsr_framereg.c uses the same master-only rule.
An interlink SAN whose payload looks like an RCT therefore gets recorded
with san == false:
rct = skb_get_PRP_rct(skb);
if (!rct && rx_port != HSR_PT_MASTER)
san = true;
Should that be updated together with this check?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202165002.49988-1-bugs%40stellman-greene.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-03 17:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 16:50 [PATCH net] net: hsr: don't take the PRP RCT from host frame payloads Andrew Stellman
2026-12-03 16:00 ` Daniel Machon
2026-12-03 17:03 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox