cipso: adjust cached option offsets when removing CIPSO
Subsystems (4)
PATCH v2 1/1 cipso: adjust cached option offsets when removing CIPSO
cipso_v4_skbuff_delattr() removes the CIPSO bytes but does not adjust cached offsets for options that follow them.
For example, with a valid 10-byte CIPSO option followed by a seven-byte RR option, parsing records rr at offset 30. Removing CIPSO moves RR to offset 20, while the cached offset remains 30. Consumers such as ip_forward_options() and __ip_options_echo() then access the wrong bytes; the latter may interpret packet data as the option length and copy it into fixed-size option storage.
Mirror cipso_v4_delopt() and subtract cipso_len from the srr, rr, ts and router_alert offsets when they follow CIPSO. cipso_len is the distance the first memmove() shifts those options. The later header move and network-header reset relocate the bytes and their offset base together.
---
Changes in v2:
- Replace the parser-invalid 8-byte example with a valid 10-byte one.
- Move the offset updates beside the other option metadata updates.
net/ipv4/cipso_ipv4.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/ipv4/cipso_ipv4.c +8 -0
@@ -2287,6 +2287,14 @@ int cipso_v4_skbuff_delattr(struct sk_buff *skb) new_hdr_len - new_hdr_len_actual); opt->optlen -= hdr_len_delta; +if (opt->srr > opt->cipso) + opt->srr -= cipso_len; +if (opt->rr > opt->cipso) + opt->rr -= cipso_len; +if (opt->ts > opt->cipso) + opt->ts -= cipso_len; +if (opt->router_alert > opt->cipso) + opt->router_alert -= cipso_len; opt->cipso =0 ; opt->is_changed =1 ;if (hdr_len_delta !=0 ) {
base-commit: d5a007b9b457c915ab1a53227e8939e4018aa97a
Signature · 1 line
2.55.0
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- Whether the issue was actually triggered, or is only theoretical (e.g. found by code inspection). If it was triggered please include the symptoms, like the stack trace or error messages.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 15 lines
cipso_v4_skbuff_delattr()removes the CIPSO bytes but does not adjust cached offsets for options that follow them.For example, with a valid 10-byte CIPSO option followed by a seven-byte RR option, parsing records rr at offset 30. Removing CIPSO moves RR to offset 20, while the cached offset remains 30. Consumers such as
ip_forward_options()and__ip_options_echo()then access the wrong bytes; the latter may interpret packet data as the option length and copy it into fixed-size option storage.Mirror
cipso_v4_delopt()and subtractcipso_lenfrom the srr, rr, ts androuter_alertoffsets when they follow CIPSO.cipso_lenis the distance the firstmemmove()shifts those options. The later header move and network-header reset relocate the bytes and their offset base together.
Quoted 5 lines
Fixes 89aa3619d141 ("cipso: make cipso_v4_skbuff_delattr() fully remove the CIPSO options")Reviewed-by Ondrej Mosnáček <[email protected]>Assisted-by LLMSigned-off-by Daehyeon Ko <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 26 lines · Daehyeon Ko
cipso_v4_skbuff_delattr()removes the CIPSO bytes but does not adjust cached offsets for options that follow them.For example, with a valid 10-byte CIPSO option followed by a seven-byte RR option, parsing records rr at offset 30. Removing CIPSO moves RR to offset 20, while the cached offset remains 30. Consumers such as
ip_forward_options()and__ip_options_echo()then access the wrong bytes; the latter may interpret packet data as the option length and copy it into fixed-size option storage.Mirror
cipso_v4_delopt()and subtractcipso_lenfrom the srr, rr, ts androuter_alertoffsets when they follow CIPSO.cipso_lenis the distance the firstmemmove()shifts those options. The later header move and network-header reset relocate the bytes and their offset base together.Fixes 89aa3619d141 ("cipso: make cipso_v4_skbuff_delattr() fully remove the CIPSO options")Reviewed-by Ondrej Mosnáček <[email protected]>Assisted-by LLMSigned-off-by Daehyeon Ko <[email protected]>---
Changes in v2:
- Replace the parser-invalid 8-byte example with a valid 10-byte one.
- Move the offset updates beside the other option metadata updates.
Quoted 4 lines
net/ipv4/cipso_ipv4.c | 8 ++++++++ 1 file changed, 8 insertions(+)
Signature · 1 line
paul-moore.com
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Tue, 6 Oct 2026 12:51:08 +0900 you wrote:
cipso_v4_skbuff_delattr()removes the CIPSO bytes but does not adjust cached offsets for options that follow them.For example, with a valid 10-byte CIPSO option followed by a seven-byte RR option, parsing records rr at offset 30. Removing CIPSO moves RR to offset 20, while the cached offset remains 30. Consumers such as
ip_forward_options()and__ip_options_echo()then access the wrong bytes; the latter may interpret packet data as the option length and copy it into fixed-size option storage.[...]
Here is the summary with links:
- [net,v2] cipso: adjust cached option offsets when removing CIPSO
https://git.kernel.org/netdev/net/c/6d25ffca055a
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html