]> git.baikalelectronics.ru Git - kernel.git/commit
ubi: ubi_create_volume: Fix use-after-free when volume creation failed
authorZhihao Cheng <chengzhihao1@huawei.com>
Tue, 10 May 2022 12:31:26 +0000 (20:31 +0800)
committerRichard Weinberger <richard@nod.at>
Fri, 27 May 2022 14:49:41 +0000 (16:49 +0200)
commitd33b16c3a0a85eaf1d9fc45b64f8b3d3b54dadf2
tree3522098526b91e0b24e51fa36ed869ba64939b4f
parentb2be21ccf55d01ba455413f31c771899ce519709
ubi: ubi_create_volume: Fix use-after-free when volume creation failed

There is an use-after-free problem for 'eba_tbl' in ubi_create_volume()'s
error handling path:

  ubi_eba_replace_table(vol, eba_tbl)
    vol->eba_tbl = tbl
out_mapping:
  ubi_eba_destroy_table(eba_tbl)   // Free 'eba_tbl'
out_unlock:
  put_device(&vol->dev)
    vol_release
      kfree(tbl->entries)   // UAF

Fix it by removing redundant 'eba_tbl' releasing.
Fetch a reproducer in [Link].

Fixes: f6de7429361b9 ("mtd: utilize new cdev_device_add helper function")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=215965
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
drivers/mtd/ubi/vmt.c