mbox series

[SRU,L/K/J/F,0/1] UBUNTU: SAUCE: overlayfs: fix reference count mismatch

Message ID 20230622093731.632666-1-andrea.righi@canonical.com
Headers show
Series UBUNTU: SAUCE: overlayfs: fix reference count mismatch | expand

Message

Andrea Righi June 22, 2023, 9:37 a.m. UTC
BugLink: https://bugs.launchpad.net/bugs/2016398

[Impact]

Opened files reported in /proc/pid/map_files can be shows with the wrong
mount point using overlayfs with filesystem namspaces.

This incorrect behavior is fixed:

  UBUNTU: SAUCE: overlayfs: fix incorrect mnt_id of files opened from map_files

However, the fix introduced a new regression, the reference to the
original file stored in vma->vm_prfile is not properly released when
vma->vm_prfile is replaced with a new file.

This can cause a reference counter unbalance, leading errors such as
"target is busy" when trying to unmount overlayfs, even if the
filesystem has not active reference.

[Test case]

Reproducer provided by original bug reporter:
https://launchpadlibrarian.net/663151659/overlayfsscript_example

[Fix]

Fix by properly releasing the original file stored in vm_prfile.

[Regression potential]

This fix seems to solve the reported bug (verified with the reproducer)
and it doesn't seem to introduce other regressions or behavior change.

However, we may experience regressions in overlayfs or potentially other
"target is busy" errors when unmounting overlayfs filesystems with this
fix applied, if there are still other corner cases not covered properly.

Comments

Stefan Bader June 30, 2023, 7:26 a.m. UTC | #1
On 22.06.23 11:37, Andrea Righi wrote:
> BugLink: https://bugs.launchpad.net/bugs/2016398
> 
> [Impact]
> 
> Opened files reported in /proc/pid/map_files can be shows with the wrong
> mount point using overlayfs with filesystem namspaces.
> 
> This incorrect behavior is fixed:
> 
>    UBUNTU: SAUCE: overlayfs: fix incorrect mnt_id of files opened from map_files
> 
> However, the fix introduced a new regression, the reference to the
> original file stored in vma->vm_prfile is not properly released when
> vma->vm_prfile is replaced with a new file.
> 
> This can cause a reference counter unbalance, leading errors such as
> "target is busy" when trying to unmount overlayfs, even if the
> filesystem has not active reference.
> 
> [Test case]
> 
> Reproducer provided by original bug reporter:
> https://launchpadlibrarian.net/663151659/overlayfsscript_example
> 
> [Fix]
> 
> Fix by properly releasing the original file stored in vm_prfile.
> 
> [Regression potential]
> 
> This fix seems to solve the reported bug (verified with the reproducer)
> and it doesn't seem to introduce other regressions or behavior change.
> 
> However, we may experience regressions in overlayfs or potentially other
> "target is busy" errors when unmounting overlayfs filesystems with this
> fix applied, if there are still other corner cases not covered properly.
> 
> 

 From the discussion I would expect a fresh submission for Focal. 
Andrea, I think that would better be a new thread. Hence the NACK.

-Stefan
Andrea Righi June 30, 2023, 7:45 a.m. UTC | #2
On Fri, Jun 30, 2023 at 09:26:20AM +0200, Stefan Bader wrote:
> On 22.06.23 11:37, Andrea Righi wrote:
> > BugLink: https://bugs.launchpad.net/bugs/2016398
> > 
> > [Impact]
> > 
> > Opened files reported in /proc/pid/map_files can be shows with the wrong
> > mount point using overlayfs with filesystem namspaces.
> > 
> > This incorrect behavior is fixed:
> > 
> >    UBUNTU: SAUCE: overlayfs: fix incorrect mnt_id of files opened from map_files
> > 
> > However, the fix introduced a new regression, the reference to the
> > original file stored in vma->vm_prfile is not properly released when
> > vma->vm_prfile is replaced with a new file.
> > 
> > This can cause a reference counter unbalance, leading errors such as
> > "target is busy" when trying to unmount overlayfs, even if the
> > filesystem has not active reference.
> > 
> > [Test case]
> > 
> > Reproducer provided by original bug reporter:
> > https://launchpadlibrarian.net/663151659/overlayfsscript_example
> > 
> > [Fix]
> > 
> > Fix by properly releasing the original file stored in vm_prfile.
> > 
> > [Regression potential]
> > 
> > This fix seems to solve the reported bug (verified with the reproducer)
> > and it doesn't seem to introduce other regressions or behavior change.
> > 
> > However, we may experience regressions in overlayfs or potentially other
> > "target is busy" errors when unmounting overlayfs filesystems with this
> > fix applied, if there are still other corner cases not covered properly.
> > 
> > 
> 
> From the discussion I would expect a fresh submission for Focal. Andrea, I
> think that would better be a new thread. Hence the NACK.

Yes, I'll send a new patch set in a separate thread. Thanks!

-Andrea
Roxana Nicolescu Aug. 2, 2023, 8:55 a.m. UTC | #3
On 22/06/2023 11:37, Andrea Righi wrote:
> BugLink: https://bugs.launchpad.net/bugs/2016398
>
> [Impact]
>
> Opened files reported in /proc/pid/map_files can be shows with the wrong
> mount point using overlayfs with filesystem namspaces.
>
> This incorrect behavior is fixed:
>
>    UBUNTU: SAUCE: overlayfs: fix incorrect mnt_id of files opened from map_files
>
> However, the fix introduced a new regression, the reference to the
> original file stored in vma->vm_prfile is not properly released when
> vma->vm_prfile is replaced with a new file.
>
> This can cause a reference counter unbalance, leading errors such as
> "target is busy" when trying to unmount overlayfs, even if the
> filesystem has not active reference.
>
> [Test case]
>
> Reproducer provided by original bug reporter:
> https://launchpadlibrarian.net/663151659/overlayfsscript_example
>
> [Fix]
>
> Fix by properly releasing the original file stored in vm_prfile.
>
> [Regression potential]
>
> This fix seems to solve the reported bug (verified with the reproducer)
> and it doesn't seem to introduce other regressions or behavior change.
>
> However, we may experience regressions in overlayfs or potentially other
> "target is busy" errors when unmounting overlayfs filesystems with this
> fix applied, if there are still other corner cases not covered properly.
>
>
Acked-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
Stefan Bader Aug. 2, 2023, 9:25 a.m. UTC | #4
On 22.06.23 11:37, Andrea Righi wrote:
> BugLink: https://bugs.launchpad.net/bugs/2016398
> 
> [Impact]
> 
> Opened files reported in /proc/pid/map_files can be shows with the wrong
> mount point using overlayfs with filesystem namspaces.
> 
> This incorrect behavior is fixed:
> 
>    UBUNTU: SAUCE: overlayfs: fix incorrect mnt_id of files opened from map_files
> 
> However, the fix introduced a new regression, the reference to the
> original file stored in vma->vm_prfile is not properly released when
> vma->vm_prfile is replaced with a new file.
> 
> This can cause a reference counter unbalance, leading errors such as
> "target is busy" when trying to unmount overlayfs, even if the
> filesystem has not active reference.
> 
> [Test case]
> 
> Reproducer provided by original bug reporter:
> https://launchpadlibrarian.net/663151659/overlayfsscript_example
> 
> [Fix]
> 
> Fix by properly releasing the original file stored in vm_prfile.
> 
> [Regression potential]
> 
> This fix seems to solve the reported bug (verified with the reproducer)
> and it doesn't seem to introduce other regressions or behavior change.
> 
> However, we may experience regressions in overlayfs or potentially other
> "target is busy" errors when unmounting overlayfs filesystems with this
> fix applied, if there are still other corner cases not covered properly.
> 
> 

Applied to lunar,jammy:linux/master-next. Kinetic is EOL and Focal was 
applied from a separate submission. Thanks.

-Stefan