Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ntfs: fix WSL symlink target leak on reparse failure

ntfs_reparse_set_wsl_symlink() converts the symlink target into an
allocated NLS string and transfers ownership to ni->target only after
ntfs_set_ntfs_reparse_data() succeeds. If setting the reparse data fails,
the converted target is left unreferenced and leaks.

Free the converted target on the reparse update failure path. Use kfree()
for the other local failure path as well, matching the ntfs_ucstonls()
allocation contract.

Fixes: fc053f05ca28 ("ntfs: add reparse and ea operations")
Signed-off-by: DaeMyung Kang <charsyam@gmail.com>
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>

authored by

DaeMyung Kang and committed by
Namjae Jeon
2dd8c166 b5198fcd

+3 -2
+3 -2
fs/ntfs/reparse.c
··· 505 505 struct reparse_point *reparse; 506 506 struct wsl_link_reparse_data *data; 507 507 508 - utarget = (char *)NULL; 509 508 len = ntfs_ucstonls(ni->vol, target, target_len, &utarget, 0); 510 509 if (len <= 0) 511 510 return -EINVAL; ··· 513 514 reparse = kvzalloc(reparse_len, GFP_NOFS); 514 515 if (!reparse) { 515 516 err = -ENOMEM; 516 - kvfree(utarget); 517 + kfree(utarget); 517 518 } else { 518 519 data = (struct wsl_link_reparse_data *)reparse->reparse_data; 519 520 reparse->reparse_tag = IO_REPARSE_TAG_LX_SYMLINK; ··· 527 528 kvfree(reparse); 528 529 if (!err) 529 530 ni->target = utarget; 531 + else 532 + kfree(utarget); 530 533 } 531 534 return err; 532 535 }