linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ovl: fix getcwd() failure after unsuccessful rmdir
@ 2016-01-08 15:09 Rui Wang
  2016-01-30  9:44 ` Konstantin Khlebnikov
  0 siblings, 1 reply; 4+ messages in thread
From: Rui Wang @ 2016-01-08 15:09 UTC (permalink / raw)
  To: miklos; +Cc: viro, linux-unionfs, linux-kernel, rui.y.wang

ovl_remove_upper() should do d_drop() only after it successfully
removes the dir, otherwise a subsequent getcwd() system call will
fail, breaking userspace programs.

This is to fix: https://bugzilla.kernel.org/show_bug.cgi?id=110491

Signed-off-by: Rui Wang <rui.y.wang@intel.com>
---
 fs/overlayfs/dir.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 692ceda..36d6a5b 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -618,7 +618,8 @@ static int ovl_remove_upper(struct dentry *dentry, bool is_dir)
 	 * sole user of this dentry.  Too tricky...  Just unhash for
 	 * now.
 	 */
-	d_drop(dentry);
+	if (!err)
+		d_drop(dentry);
 	mutex_unlock(&dir->i_mutex);
 
 	return err;
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ovl: fix getcwd() failure after unsuccessful rmdir
  2016-01-08 15:09 [PATCH] ovl: fix getcwd() failure after unsuccessful rmdir Rui Wang
@ 2016-01-30  9:44 ` Konstantin Khlebnikov
  0 siblings, 0 replies; 4+ messages in thread
From: Konstantin Khlebnikov @ 2016-01-30  9:44 UTC (permalink / raw)
  To: Rui Wang
  Cc: Miklos Szeredi, Al Viro, linux-unionfs,
	Linux Kernel Mailing List, linux-fsdevel, Vivek Goyal

On Fri, Jan 8, 2016 at 6:09 PM, Rui Wang <rui.y.wang@intel.com> wrote:
> ovl_remove_upper() should do d_drop() only after it successfully
> removes the dir, otherwise a subsequent getcwd() system call will
> fail, breaking userspace programs.
>
> This is to fix: https://bugzilla.kernel.org/show_bug.cgi?id=110491
>
> Signed-off-by: Rui Wang <rui.y.wang@intel.com>

Reviewed-by: Konstantin Khlebnikov <koct9i@gmail.com>

The same problem also in ovl_remove_and_whiteout() - when we
remove non-pure dentry. It checks that directory isn't empty before,
but I'm sure that vfs_rename which exchanges dentry and whiteout
could fail for some reason and we'll end with unhashed dentry when
nothing actually has been changed.

> ---
>  fs/overlayfs/dir.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
> index 692ceda..36d6a5b 100644
> --- a/fs/overlayfs/dir.c
> +++ b/fs/overlayfs/dir.c
> @@ -618,7 +618,8 @@ static int ovl_remove_upper(struct dentry *dentry, bool is_dir)
>          * sole user of this dentry.  Too tricky...  Just unhash for
>          * now.
>          */
> -       d_drop(dentry);
> +       if (!err)
> +               d_drop(dentry);
>         mutex_unlock(&dir->i_mutex);
>
>         return err;
> --
> 1.7.5.4
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ovl: fix getcwd() failure after unsuccessful rmdir
  2016-02-01 15:36 Rui Wang
@ 2016-03-02 14:17 ` Miklos Szeredi
  0 siblings, 0 replies; 4+ messages in thread
From: Miklos Szeredi @ 2016-03-02 14:17 UTC (permalink / raw)
  To: Rui Wang
  Cc: Konstantin Khlebnikov, Al Viro, linux-unionfs,
	Kernel Mailing List, Linux-Fsdevel, Vivek Goyal

On Mon, Feb 1, 2016 at 4:36 PM, Rui Wang <rui.y.wang@intel.com> wrote:
> On Sat, Jan 30, 2016 5:44 PM Konstantin Khlebnikov <koct9i@gmail.com> wrote:
>> On Fri, Jan 8, 2016 at 6:09 PM, Rui Wang <rui.y.wang@intel.com> wrote:
>> ovl_remove_upper() should do d_drop() only after it successfully
>> removes the dir, otherwise a subsequent getcwd() system call will
>> fail, breaking userspace programs.
>>
>> This is to fix: https://bugzilla.kernel.org/show_bug.cgi?id=110491
>>
>> Signed-off-by: Rui Wang <rui.y.wang@intel.com>
>>
>> Reviewed-by: Konstantin Khlebnikov <koct9i@gmail.com>
>>
>> The same problem also in ovl_remove_and_whiteout() - when we remove
>> non-pure dentry. It checks that directory isn't empty before, but
>> I'm sure that vfs_rename which exchanges dentry and whiteout could
>> fail for some reason and we'll end with unhashed dentry when nothing
>> actually has been changed.
>
> Yes I had the same feeling. There's a "goto out_d_drop" which causes
> d_drop() to be called if ovl_do_rename() fails. but I wasn't able to
> find a way to reproduce this problem, so I only fixed the problem
> described in bug110491. It's what I could reliably test.

Thanks for the patch.  Added to the queue.

Miklos

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ovl: fix getcwd() failure after unsuccessful rmdir
@ 2016-02-01 15:36 Rui Wang
  2016-03-02 14:17 ` Miklos Szeredi
  0 siblings, 1 reply; 4+ messages in thread
From: Rui Wang @ 2016-02-01 15:36 UTC (permalink / raw)
  To: koct9i
  Cc: rui.y.wang, miklos, viro, linux-unionfs, linux-kernel,
	linux-fsdevel, vgoyal

On Sat, Jan 30, 2016 5:44 PM Konstantin Khlebnikov <koct9i@gmail.com> wrote: 
> On Fri, Jan 8, 2016 at 6:09 PM, Rui Wang <rui.y.wang@intel.com> wrote:
> ovl_remove_upper() should do d_drop() only after it successfully 
> removes the dir, otherwise a subsequent getcwd() system call will 
> fail, breaking userspace programs.
>
> This is to fix: https://bugzilla.kernel.org/show_bug.cgi?id=110491
>
> Signed-off-by: Rui Wang <rui.y.wang@intel.com>
> 
> Reviewed-by: Konstantin Khlebnikov <koct9i@gmail.com>
> 
> The same problem also in ovl_remove_and_whiteout() - when we remove
> non-pure dentry. It checks that directory isn't empty before, but
> I'm sure that vfs_rename which exchanges dentry and whiteout could
> fail for some reason and we'll end with unhashed dentry when nothing
> actually has been changed.

Yes I had the same feeling. There's a "goto out_d_drop" which causes
d_drop() to be called if ovl_do_rename() fails. but I wasn't able to
find a way to reproduce this problem, so I only fixed the problem
described in bug110491. It's what I could reliably test.

Thanks
Rui

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-03-02 14:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-08 15:09 [PATCH] ovl: fix getcwd() failure after unsuccessful rmdir Rui Wang
2016-01-30  9:44 ` Konstantin Khlebnikov
2016-02-01 15:36 Rui Wang
2016-03-02 14:17 ` Miklos Szeredi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).