Linux-Fsdevel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] fanotify: compare fsid when merging name event
@ 2020-07-28  6:51 Amir Goldstein
  2020-07-28  7:42 ` Jan Kara
  0 siblings, 1 reply; 5+ messages in thread
From: Amir Goldstein @ 2020-07-28  6:51 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-fsdevel

This was missed when splitting name event from fid event

Fixes: cacfb956d46e ("fanotify: record name info for FAN_DIR_MODIFY event")
Cc: <stable@vger.kernel.org> # v5.7+
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---

Jan,

We missed a spot in v5.7.

IMO, the issue is not that critical that we must fast track the fix to
v5.8, but I am posting this patch based on v5.8-rc7, so you may decide
whether you want to fast track it or to apply it at the beginning of the
series for next.

Either way, this is going to be easier for cherry-picking to stable rather
that backporting the fix from the top of the series for next.
I pushed my "forward porting" to branch fsnotify-fixes.

Thanks,
Amir.

 fs/notify/fanotify/fanotify.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index 85eda539b35f..04f9a7012f46 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -64,6 +64,7 @@ static bool fanotify_name_event_equal(struct fanotify_name_event *fne1,
 		return false;
 
 	if (fne1->name_len != fne2->name_len ||
+	    !fanotify_fsid_equal(&fne1->fsid, &fne2->fsid) ||
 	    !fanotify_fh_equal(&fne1->dir_fh, &fne2->dir_fh))
 		return false;
 
-- 
2.17.1


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

* Re: [PATCH] fanotify: compare fsid when merging name event
  2020-07-28  6:51 [PATCH] fanotify: compare fsid when merging name event Amir Goldstein
@ 2020-07-28  7:42 ` Jan Kara
  2020-07-28  8:06   ` Amir Goldstein
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kara @ 2020-07-28  7:42 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Jan Kara, linux-fsdevel

On Tue 28-07-20 09:51:08, Amir Goldstein wrote:
> This was missed when splitting name event from fid event
> 
> Fixes: cacfb956d46e ("fanotify: record name info for FAN_DIR_MODIFY event")
> Cc: <stable@vger.kernel.org> # v5.7+
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>

OK, but given we never enabled FAN_DIR_MODIFY in 5.7, this is just a dead
code there, isn't it? So it should be enough to fix this for the series
that's currently queued?

								Honza

> ---
> 
> Jan,
> 
> We missed a spot in v5.7.
> 
> IMO, the issue is not that critical that we must fast track the fix to
> v5.8, but I am posting this patch based on v5.8-rc7, so you may decide
> whether you want to fast track it or to apply it at the beginning of the
> series for next.
> 
> Either way, this is going to be easier for cherry-picking to stable rather
> that backporting the fix from the top of the series for next.
> I pushed my "forward porting" to branch fsnotify-fixes.
> 
> Thanks,
> Amir.
> 
>  fs/notify/fanotify/fanotify.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
> index 85eda539b35f..04f9a7012f46 100644
> --- a/fs/notify/fanotify/fanotify.c
> +++ b/fs/notify/fanotify/fanotify.c
> @@ -64,6 +64,7 @@ static bool fanotify_name_event_equal(struct fanotify_name_event *fne1,
>  		return false;
>  
>  	if (fne1->name_len != fne2->name_len ||
> +	    !fanotify_fsid_equal(&fne1->fsid, &fne2->fsid) ||
>  	    !fanotify_fh_equal(&fne1->dir_fh, &fne2->dir_fh))
>  		return false;
>  
> -- 
> 2.17.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH] fanotify: compare fsid when merging name event
  2020-07-28  7:42 ` Jan Kara
@ 2020-07-28  8:06   ` Amir Goldstein
  2020-07-28  9:04     ` Jan Kara
  0 siblings, 1 reply; 5+ messages in thread
From: Amir Goldstein @ 2020-07-28  8:06 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-fsdevel

On Tue, Jul 28, 2020 at 10:42 AM Jan Kara <jack@suse.cz> wrote:
>
> On Tue 28-07-20 09:51:08, Amir Goldstein wrote:
> > This was missed when splitting name event from fid event
> >
> > Fixes: cacfb956d46e ("fanotify: record name info for FAN_DIR_MODIFY event")
> > Cc: <stable@vger.kernel.org> # v5.7+
> > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
>
> OK, but given we never enabled FAN_DIR_MODIFY in 5.7, this is just a dead
> code there, isn't it? So it should be enough to fix this for the series
> that's currently queued?

Doh! you are right.
So you can just work it into the series and remove the explicit stable tag.
If we leave the Fixes tag, stable bots will probably pick this up, but OTOH,
there is no harm in applying the patch to stable kernel, so whatever.

Thanks,
Amir.

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

* Re: [PATCH] fanotify: compare fsid when merging name event
  2020-07-28  8:06   ` Amir Goldstein
@ 2020-07-28  9:04     ` Jan Kara
  2020-07-28  9:20       ` Amir Goldstein
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kara @ 2020-07-28  9:04 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Jan Kara, linux-fsdevel


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

On Tue 28-07-20 11:06:25, Amir Goldstein wrote:
> On Tue, Jul 28, 2020 at 10:42 AM Jan Kara <jack@suse.cz> wrote:
> >
> > On Tue 28-07-20 09:51:08, Amir Goldstein wrote:
> > > This was missed when splitting name event from fid event
> > >
> > > Fixes: cacfb956d46e ("fanotify: record name info for FAN_DIR_MODIFY event")
> > > Cc: <stable@vger.kernel.org> # v5.7+
> > > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> >
> > OK, but given we never enabled FAN_DIR_MODIFY in 5.7, this is just a dead
> > code there, isn't it? So it should be enough to fix this for the series
> > that's currently queued?
> 
> Doh! you are right.
> So you can just work it into the series and remove the explicit stable tag.
> If we leave the Fixes tag, stable bots will probably pick this up, but OTOH,
> there is no harm in applying the patch to stable kernel, so whatever.

Attached is what I have pushed to my tree.

									Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

[-- Attachment #2: 0001-fanotify-compare-fsid-when-merging-name-event.patch --]
[-- Type: text/x-patch, Size: 1374 bytes --]

From 8aed8cebdd973e95d20743e00e35467c7b467d0d Mon Sep 17 00:00:00 2001
From: Jan Kara <jack@suse.cz>
Date: Tue, 28 Jul 2020 10:58:07 +0200
Subject: [PATCH] fanotify: compare fsid when merging name event

When merging name events, fsids of the two involved events have to
match. Otherwise we could merge events from two different filesystems
and thus effectively loose the second event.

Backporting note: Although the commit cacfb956d46e introducing this bug
was merged for 5.7, the relevant code didn't get used in the end until
7e8283af6ede ("fanotify: report parent fid + name + child fid") which
will be merged with this patch. So there's no need for backporting this.

Fixes: cacfb956d46e ("fanotify: record name info for FAN_DIR_MODIFY event")
Reported-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/notify/fanotify/fanotify.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index bd9e88e889ea..c942910a8649 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -82,6 +82,9 @@ static bool fanotify_name_event_equal(struct fanotify_name_event *fne1,
 	if (!info1->dir_fh_totlen)
 		return false;
 
+	if (!fanotify_fsid_equal(&fne1->fsid, &fne2->fsid))
+		return false;
+
 	return fanotify_info_equal(info1, info2);
 }
 
-- 
2.16.4


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

* Re: [PATCH] fanotify: compare fsid when merging name event
  2020-07-28  9:04     ` Jan Kara
@ 2020-07-28  9:20       ` Amir Goldstein
  0 siblings, 0 replies; 5+ messages in thread
From: Amir Goldstein @ 2020-07-28  9:20 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-fsdevel

On Tue, Jul 28, 2020 at 12:04 PM Jan Kara <jack@suse.cz> wrote:
>
> On Tue 28-07-20 11:06:25, Amir Goldstein wrote:
> > On Tue, Jul 28, 2020 at 10:42 AM Jan Kara <jack@suse.cz> wrote:
> > >
> > > On Tue 28-07-20 09:51:08, Amir Goldstein wrote:
> > > > This was missed when splitting name event from fid event
> > > >
> > > > Fixes: cacfb956d46e ("fanotify: record name info for FAN_DIR_MODIFY event")
> > > > Cc: <stable@vger.kernel.org> # v5.7+
> > > > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> > >
> > > OK, but given we never enabled FAN_DIR_MODIFY in 5.7, this is just a dead
> > > code there, isn't it? So it should be enough to fix this for the series
> > > that's currently queued?
> >
> > Doh! you are right.
> > So you can just work it into the series and remove the explicit stable tag.
> > If we leave the Fixes tag, stable bots will probably pick this up, but OTOH,
> > there is no harm in applying the patch to stable kernel, so whatever.
>
> Attached is what I have pushed to my tree.
>

Excellent.

Thanks,
Amir.

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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-28  6:51 [PATCH] fanotify: compare fsid when merging name event Amir Goldstein
2020-07-28  7:42 ` Jan Kara
2020-07-28  8:06   ` Amir Goldstein
2020-07-28  9:04     ` Jan Kara
2020-07-28  9:20       ` Amir Goldstein

Linux-Fsdevel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-fsdevel/0 linux-fsdevel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-fsdevel linux-fsdevel/ https://lore.kernel.org/linux-fsdevel \
		linux-fsdevel@vger.kernel.org
	public-inbox-index linux-fsdevel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-fsdevel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git