• Li Zetao's avatar
    bcachefs: Fix null-ptr-deref in bch2_fs_alloc() · f8cdf65b
    Li Zetao authored
    There is a null-ptr-deref issue reported by kasan:
    
      KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
      Call Trace:
        <TASK>
        bch2_fs_alloc+0x1092/0x2170 [bcachefs]
        bch2_fs_open+0x683/0xe10 [bcachefs]
        ...
    
    When initializing the name of bch_fs, it needs to dynamically alloc memory
    to meet the length of the name. However, when name allocation failed, it
    will cause a null-ptr-deref access exception in subsequent string copy.
    
    Fix this issue by checking if name allocation is successful.
    
    Fixes: 401ec4db ("bcachefs: Printbuf rework")
    Signed-off-by: default avatarLi Zetao <lizetao1@huawei.com>
    Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
    f8cdf65b
super.c 50 KB