lkml.org 
[lkml]   [2023]   [Oct]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectPROBLEM: NULL pointer dereference error in the "ufs_put_super_internal" function
NULL pointer dereference error may occur in "ufs_put_super_internal" function.

The "ufs_put_super_internal" function located in "fs/ufs/super.c" may occur a NULL pointer dereference error when it calls the function "ubh_memcpyubh" defined in "fs/ufs/util.c". The relevant code definitions are as follows:
ubh = ubh_bread(sb, uspi->s_csaddr + i, size);
ubh_memcpyubh (ubh, space, size);

It will call "ubh_bread" function to allocate enough memory to store the variable "ubh". The "ubh_bread" function may return NULL in various situations, especially when calling "kmalloc" function. If there are significant memory fragmentation issues, insufficient free memory blocks, or internal errors in the allocation function, the "kmalloc" function will return NULL. Finally, the "ubh" variable will get NULL, and the "ubh" will be passed as the first parameter to the "ubh_memcpyubh" function. This function will execute the following code snippet:
if (size > (ubh->count << uspi->s_fshift))
size = ubh->count << uspi->s_fshift;

If the "ubh" variable is NULL, it will cause an error. So I think that a null pointer check should be added in the function "ufs_put_super_internal".

My experimental kernel version is "LINUX 6.1", and this problem exists in all the version from "LINUX v3.0-rc1" to "LINUX v6.6-rc5".

Best regards,
Sicong Huang


\
 
 \ /
  Last update: 2023-10-16 06:27    [W:0.026 / U:1.720 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site