Skip to contentSkip to conversation

fanotify: compare fsid when merging name event

PATCH In review Amir Goldstein 2 participants 5 messages Jul 28, 2020

Subsystems (3)
lore
Share & tools
lore

Amir Goldstein

author reviewer
#0 lore raw

PATCH 1/1 fanotify: compare fsid when merging name event

This was missed when splitting name event from fid event

Fixes cacfb956d46e ("fanotify: record name info for FAN_DIR_MODIFY event")
Cc <[email protected]> # v5.7+

---

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(+)
fs/notify/fanotify/fanotify.c +1 -0
index 85eda539b35f..04f9a7012f46 100644
@@ -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;
 
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 5 lines · Amir Goldstein

This was missed when splitting name event from fid event

Fixes cacfb956d46e ("fanotify: record name info for FAN_DIR_MODIFY event")
Cc <[email protected]> # v5.7+

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

Quoted 36 lines

---

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(+)
fs/notify/fanotify/fanotify.c +1 -0
index 85eda539b35f..04f9a7012f46 100644
@@ -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;
 
Signature · 1 line
2.17.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
author reviewer
#2 lore raw
Quoted 11 lines · Jan Kara
Quoted 5 lines · Amir Goldstein

This was missed when splitting name event from fid event

Fixes cacfb956d46e ("fanotify: record name info for FAN_DIR_MODIFY event")
Cc <[email protected]> # v5.7+

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.

maintainer
#3 lore raw
Quoted 9 lines · Amir Goldstein
Quoted 8 lines · Jan Kara
Quoted 5 lines · Amir Goldstein

This was missed when splitting name event from fid event

Fixes cacfb956d46e ("fanotify: record name info for FAN_DIR_MODIFY event")
Cc <[email protected]> # v5.7+
Quoted 8 lines
Quoted 3 lines

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

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR

From 8aed8cebdd973e95d20743e00e35467c7b467d0d Mon Sep 17 00:00:00 2001
From: Jan Kara <[email protected]>
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")
---
 fs/notify/fanotify/fanotify.c | 3 +++
 1 file changed, 3 insertions(+)
fs/notify/fanotify/fanotify.c +3 -0
index bd9e88e889ea..c942910a8649 100644
@@ -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);
 }
 
Signature · 1 line
2.16.4
author reviewer
#4 lore raw
Quoted 15 lines · Jan Kara
Quoted 13 lines · Amir Goldstein
Quoted 11 lines · Jan Kara
Quoted 5 lines · Amir Goldstein

This was missed when splitting name event from fid event

Fixes cacfb956d46e ("fanotify: record name info for FAN_DIR_MODIFY event")
Cc <[email protected]> # v5.7+

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?

Quoted 7 lines
Quoted 4 lines

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.