[PATCH master v2] fs: fix NULL pointer dereference of fsdrv->truncate for read-only FS

Sascha Hauer sha at pengutronix.de
Fri Jul 9 13:54:07 PDT 2021


On Wed, Jul 07, 2021 at 08:52:51AM +0200, Ahmad Fatoum wrote:
> fsdrv->truncate is dereferenced at times without checking for NULL before,
> leading to crashes, e.g. doing:
> 
>   edit -o /mnt/myext4/FILE some text
> 
> on ext4 crashes. Fix this by returning -EROFS when truncate is unimplemented.
> 
> Reported-by: Xogium <contact at xogium.me>
> Signed-off-by: Ahmad Fatoum <ahmad at a3f.at>
> ---
> v1 -> v2:
>   - use dev parameter instead of going through &f->fsdev->dev.
>     No functional change, but makes diff easier to verify.
> ---
>  fs/fs.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)

Applied, thanks

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