Re: [RFC] fs:unicode:mkutf8data.c: Fix the potential stack overflow risk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 25, 2022 at 05:14:43PM +0800, jianchunfu wrote:
> I'm not sure why there are so many missing checks of the malloc function,
> is it because the memory allocated is only a few bytes
> so no checks are needed?
> 
> Signed-off-by: jianchunfu <jianchunfu@xxxxxxxxxxxxxxxxxxxx>
> ---
>  fs/unicode/mkutf8data.c | 54 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 54 insertions(+)
> 

mkutf8data is a host tool used during the build, not kernel code, so it doesn't
really matter.  If malloc returns NULL, the tool will crash, which will be
treated as a build error, just like if it cleanly reported a failure.  It's
definitely poor practice, though.

How about just adding and using a helper function "xmalloc()" that has a NULL
check built in?  That would be much simpler than your patch.

- Eric



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux