[PATCH net v4] cipso: fix optlen corruption in cipso_v4_delopt()

Paul Moore paul at paul-moore.com
Thu Oct 29 13:55:11 UTC 2026


On Wed, Oct 28, 2026 at 11:39 PM Qihang <q.h.hack.winter at gmail.com> wrote:
>
> cipso_v4_delopt() recomputes the option length by walking the option
> buffer after the CIPSO option has been moved out.  The walk then reads
> the stale bytes at the tail of the buffer as option data, and a crafted
> setsockopt(IP_OPTIONS) buffer can make it treat one of them as an option
> length, increasing opt->opt.optlen beyond the valid option data.
>
> The corrupted length stays on the socket and is later used as the copy
> length by getsockopt(IP_OPTIONS) and by the udp/raw/ping sendmsg paths,
> where it exceeds the size of the buffers they copy into.
>
> Compute the new length from the intact options before the move and
> subtract the CIPSO length, and fill the padding with IPOPT_END.
>
> Assisted-by: LLM
> Fixes: 014ab19a69c32 ("selinux: Set socket NetLabel based on connection endpoint")
> Cc: stable at vger.kernel.org
> Signed-off-by: Qihang <q.h.hack.winter at gmail.com>
> ---
> v4:
>  - rebased onto net (fcc00b15cb21a)
>  - reworded the impact paragraph only, no functional change
>  - first public posting (v1-v3 were reviewed privately)
>
>  net/ipv4/cipso_ipv4.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)

Thanks!

Acked-by: Paul Moore <paul at paul-moore.com>

-- 
paul-moore.com



More information about the Linux-security-module-archive mailing list