Re: [PATCH] caif: fix integer underflow in cffrml_receive()

From: Simon Horman
Date: Tue Dec 09 2025 - 14:13:41 EST


On Thu, Dec 04, 2025 at 09:30:47PM +0800, Junrui Luo wrote:
> The cffrml_receive() function extracts a length field from the packet
> header and, when FCS is disabled, subtracts 2 from this length without
> validating that len >= 2.
>
> If an attacker sends a malicious packet with a length field of 0 or 1
> to an interface with FCS disabled, the subtraction causes an integer
> underflow.
>
> This can lead to memory exhaustion and kernel instability, potential
> information disclosure if padding contains uninitialized kernel memory.
>
> Fix this by validating that len >= 2 before performing the subtraction.
>
> Reported-by: Yuhao Jiang <danisjiang@xxxxxxxxx>
> Reported-by: Junrui Luo <moonafterrain@xxxxxxxxxxx>
> Fixes: b482cd2053e3 ("net-caif: add CAIF core protocol stack")
> Signed-off-by: Junrui Luo <moonafterrain@xxxxxxxxxxx>

Hi Junrui,

I agree with your analysis and that the problem was introduced
by the cited commit.

I think that this function could benefit with a goto label that is jumped
to by all of the cases that follow the same error handling logic as this
one - I count 4 including this one. But as a minimal bug fix I agree this
is a good approach.

No need to repost, but in future please consider targeting networking
bug fixes at the net tree like this:

Subject: [PATCH net] ...

Reviewed-by: Simon Horman <horms@xxxxxxxxxx>

...