[Devel] [PATCH hci-8.1 v8 5/6] ovl: Fix leaking fd references in ovl_copyfile

Vladimir Riabchun vladimir.riabchun at virtuozzo.com
Mon Nov 16 23:03:33 MSK 2026



On 11/16/26 20:28, no-reply at sashiko.virtuozzo.com wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Low] ovl: commit message does not state the actual fd leak in
>    ovl_copyfile()
> --
> 
> commit 19e71b9ba90a3111ae72b566162542bd1c41d68d
> Author: Vladimir Riabchun <vladimir.riabchun at virtuozzo.com>
> 
>> ovl: Fix leaking fd references in ovl_copyfile
>>
>> We lack of ovl_real_file, added in d66907b[1], which changed
>> logic so that the code needs no fdput anymore. We still need it.
>>
>> Imported commit a1e0eb8[2] didn't bother with fdput cleanup,
>> because it relied on d66907b existence. We need to perform
>> a cleanup when rw_verify_area fails and put real_in/real_out fds.
>>
>> [1]: https://github.com/torvalds/linux/commit/d66907b51ba0
>> [2]: https://github.com/torvalds/linux/commit/a1e0eb8f55cf
>>
>> https://virtuozzo.atlassian.net/browse/VSTOR-142405
>> Fixes: d5a10d38e534 ("rh10: import RHEL10 kernel-6.12.0-211.75.1.el10")
>> Signed-off-by: Vladimir Riabchun <vladimir.riabchun at virtuozzo.com>
> 
> [Severity: Low]
> Could the message state the leak more directly? The sentence "the code
> needs no fdput anymore. We still need it." contradicts itself, and the
> message never names the path that leaks.

No contradiction. Code with d66907b needs no fdput, but this is not
our code.

> 
> As far as I can tell, the leak is in the cross-sb check in ovl_copyfile().
> When rw_verify_area() fails, the code jumped to out_unlock. Both
> ovl_real_fdget() calls had already succeeded, so this skipped fdput(real_in)
> and fdput(real_out). When FDPUT_FPUT is set, that leaks the file
> references.
> 
> The message could say this in one sentence. It could also name the
> upstream commits by 12-character sha and subject instead of the short
> shas and bare URLs.

The leak is obvious from the code. I'm not adding useless words to the
commit message.

> 

-- 
Best regards, Riabchun Vladimir
Linux Kernel Developer, Virtuozzo



More information about the Devel mailing list