[PATCH v3 8/9] fs: Report errors for out-of-bounds protect operations

Ahmad Fatoum a.fatoum at pengutronix.de
Tue Jun 24 22:45:39 PDT 2025


Hi,

On 17.06.25 09:56, Sascha Hauer wrote:
>> -	if (count > f->f_size - offset)
>> -		count = f->f_size - offset;
>> +		return errno_set(-ENXIO);
>> +	if (!count  || count > f->f_size - offset)
>> +		return errno_set(-EINVAL);
> 
> This breaks the saveenv command which does a
> 
> 	ret = protect(envfd, ~0, 0, 0);
> 
> to unprotect the environment sector. Try on a board with environment in
> SPI flash.

Just ran into this as well. It's easy to reproduce with QEMU.

Either by building multi_v7_defconfig and running:

  labgrid-pytest --lg-env test/arm/multi_v7_defconfig.yaml --interactive

or by building platform-v7a in DistroKit and running:

  configs/platform-v7a/run

Cheers,
Ahmad

> 
> Sascha
> 
> 


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list