All of lore.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] ovl: check whiteout in ovl_create_over_whiteout()" failed to apply to 4.9-stable tree
@ 2018-11-15  0:08 gregkh
  2018-11-15  9:42 ` Miklos Szeredi
  0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2018-11-15  0:08 UTC (permalink / raw)
  To: mszeredi, stable, xiakaixu1987; +Cc: stable


The patch below does not apply to the 4.9-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

>From 5e1275808630ea3b2c97c776f40e475017535f72 Mon Sep 17 00:00:00 2001
From: Miklos Szeredi <mszeredi@redhat.com>
Date: Wed, 31 Oct 2018 12:15:23 +0100
Subject: [PATCH] ovl: check whiteout in ovl_create_over_whiteout()

Kaixuxia repors that it's possible to crash overlayfs by removing the
whiteout on the upper layer before creating a directory over it.  This is a
reproducer:

 mkdir lower upper work merge
 touch lower/file
 mount -t overlay overlay -olowerdir=lower,upperdir=upper,workdir=work merge
 rm merge/file
 ls -al merge/file
 rm upper/file
 ls -al merge/
 mkdir merge/file

Before commencing with a vfs_rename(..., RENAME_EXCHANGE) verify that the
lookup of "upper" is positive and is a whiteout, and return ESTALE
otherwise.

Reported by: kaixuxia <xiakaixu1987@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Fixes: e9be9d5e76e3 ("overlay filesystem")
Cc: <stable@vger.kernel.org> # v3.18

diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index ce1857fb5434..c6289147c787 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -462,6 +462,10 @@ static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode,
 	if (IS_ERR(upper))
 		goto out_unlock;
 
+	err = -ESTALE;
+	if (d_is_negative(upper) || !IS_WHITEOUT(d_inode(upper)))
+		goto out_dput;
+
 	newdentry = ovl_create_temp(workdir, cattr);
 	err = PTR_ERR(newdentry);
 	if (IS_ERR(newdentry))

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

* Re: FAILED: patch "[PATCH] ovl: check whiteout in ovl_create_over_whiteout()" failed to apply to 4.9-stable tree
  2018-11-15  0:08 FAILED: patch "[PATCH] ovl: check whiteout in ovl_create_over_whiteout()" failed to apply to 4.9-stable tree gregkh
@ 2018-11-15  9:42 ` Miklos Szeredi
  2018-11-19 15:08   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Miklos Szeredi @ 2018-11-15  9:42 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: stable, xiakaixu1987

[-- Attachment #1: Type: text/plain, Size: 388 bytes --]

On Thu, Nov 15, 2018 at 1:08 AM <gregkh@linuxfoundation.org> wrote:
>
>
> The patch below does not apply to the 4.9-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.

Attaching backport.  Should also apply cleanly to v3.18..v4.9

Thanks,
Miklos

[-- Attachment #2: 4.9.y-ovl-check-whiteout-in-ovl_create_over_whiteout.patch --]
[-- Type: text/x-patch, Size: 1438 bytes --]

From: Miklos Szeredi <mszeredi@redhat.com>
Date: Wed, 31 Oct 2018 12:15:23 +0100
Subject: [4.9.y PATCH] ovl: check whiteout in ovl_create_over_whiteout()

commit 5e1275808630ea3b2c97c776f40e475017535f72 upstream.

Kaixuxia repors that it's possible to crash overlayfs by removing the
whiteout on the upper layer before creating a directory over it.  This is a
reproducer:

 mkdir lower upper work merge
 touch lower/file
 mount -t overlay overlay -olowerdir=lower,upperdir=upper,workdir=work merge
 rm merge/file
 ls -al merge/file
 rm upper/file
 ls -al merge/
 mkdir merge/file

Before commencing with a vfs_rename(..., RENAME_EXCHANGE) verify that the
lookup of "upper" is positive and is a whiteout, and return ESTALE
otherwise.

Reported by: kaixuxia <xiakaixu1987@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Fixes: e9be9d5e76e3 ("overlay filesystem")
---
 fs/overlayfs/dir.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 306b6c161840..fd85115bcab7 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -407,6 +407,10 @@ static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode,
 	if (IS_ERR(upper))
 		goto out_dput;
 
+	err = -ESTALE;
+	if (d_is_negative(upper) || !IS_WHITEOUT(d_inode(upper)))
+		goto out_dput2;
+
 	err = ovl_create_real(wdir, newdentry, stat, link, hardlink, true);
 	if (err)
 		goto out_dput2;
-- 
2.14.5


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

* Re: FAILED: patch "[PATCH] ovl: check whiteout in ovl_create_over_whiteout()" failed to apply to 4.9-stable tree
  2018-11-15  9:42 ` Miklos Szeredi
@ 2018-11-19 15:08   ` Greg Kroah-Hartman
  2018-11-19 15:15     ` Miklos Szeredi
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-19 15:08 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: stable, xiakaixu1987

On Thu, Nov 15, 2018 at 10:42:20AM +0100, Miklos Szeredi wrote:
> On Thu, Nov 15, 2018 at 1:08 AM <gregkh@linuxfoundation.org> wrote:
> >
> >
> > The patch below does not apply to the 4.9-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to <stable@vger.kernel.org>.
> 
> Attaching backport.  Should also apply cleanly to v3.18..v4.9

This doesn't apply at all, are you sure you generated it properly?  Can
you try it again?

thanks,

greg k-h

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

* Re: FAILED: patch "[PATCH] ovl: check whiteout in ovl_create_over_whiteout()" failed to apply to 4.9-stable tree
  2018-11-19 15:08   ` Greg Kroah-Hartman
@ 2018-11-19 15:15     ` Miklos Szeredi
  0 siblings, 0 replies; 4+ messages in thread
From: Miklos Szeredi @ 2018-11-19 15:15 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: stable, Kaixu Xia

On Mon, Nov 19, 2018 at 4:08 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Thu, Nov 15, 2018 at 10:42:20AM +0100, Miklos Szeredi wrote:
> > On Thu, Nov 15, 2018 at 1:08 AM <gregkh@linuxfoundation.org> wrote:
> > >
> > >
> > > The patch below does not apply to the 4.9-stable tree.
> > > If someone wants it applied there, or to any other stable or longterm
> > > tree, then please email the backport, including the original git commit
> > > id to <stable@vger.kernel.org>.
> >
> > Attaching backport.  Should also apply cleanly to v3.18..v4.9
>
> This doesn't apply at all, are you sure you generated it properly?  Can
> you try it again?

Okay.   I only looked at the base kernel, not the stable one, so
probably there's some conflict in the stable patches themselves.

Thanks,
Miklos

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

end of thread, other threads:[~2018-11-20  1:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-15  0:08 FAILED: patch "[PATCH] ovl: check whiteout in ovl_create_over_whiteout()" failed to apply to 4.9-stable tree gregkh
2018-11-15  9:42 ` Miklos Szeredi
2018-11-19 15:08   ` Greg Kroah-Hartman
2018-11-19 15:15     ` Miklos Szeredi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.