Repository navigation
Commit a37d9a1
fsnotify: invalidate dcache before IN_DELETE event
Apparently, there are some applications that use IN_DELETE event as an
invalidation mechanism and expect that if they try to open a file with
the name reported with the delete event, that it should not contain the
content of the deleted file.
Commit 4924646 ("fsnotify: move fsnotify_nameremove() hook out of
d_delete()") moved the fsnotify delete hook before d_delete() so fsnotify
will have access to a positive dentry.
This allowed a race where opening the deleted file via cached dentry
is now possible after receiving the IN_DELETE event.
To fix the regression, create a new hook fsnotify_delete() that takes
the unlinked inode as an argument and use a helper d_delete_notify() to
pin the inode, so we can pass it to fsnotify_delete() after d_delete().
Backporting hint: this regression is from v5.3. Although patch will
apply with only trivial conflicts to v5.4 and v5.10, it won't build,
because fsnotify_delete() implementation is different in each of those
versions (see fsnotify_link()).
A follow up patch will fix the fsnotify_unlink/rmdir() calls in pseudo
filesystem that do not need to call d_delete().
Link: https://lore.kernel.org/r/20220120215305.282577-1-amir73il@gmail.com
Reported-by: Ivan Delalande <colona@arista.com>
Link: https://lore.kernel.org/linux-fsdevel/YeNyzoDM5hP5LtGW@visor/
Fixes: 4924646 ("fsnotify: move fsnotify_nameremove() hook out of d_delete()")
Cc: stable@vger.kernel.org # v5.3+
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>1 parent 217663f commit a37d9a1
3 files changed
Lines changed: 50 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3086 | 3086 | | |
3087 | 3087 | | |
3088 | 3088 | | |
3089 | | - | |
3090 | | - | |
3091 | | - | |
3092 | | - | |
| 3089 | + | |
| 3090 | + | |
3093 | 3091 | | |
3094 | 3092 | | |
3095 | 3093 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3974 | 3974 | | |
3975 | 3975 | | |
3976 | 3976 | | |
3977 | | - | |
3978 | 3977 | | |
3979 | 3978 | | |
3980 | 3979 | | |
3981 | 3980 | | |
3982 | 3981 | | |
3983 | | - | |
| 3982 | + | |
3984 | 3983 | | |
3985 | 3984 | | |
3986 | 3985 | | |
| |||
4102 | 4101 | | |
4103 | 4102 | | |
4104 | 4103 | | |
4105 | | - | |
4106 | 4104 | | |
4107 | 4105 | | |
4108 | 4106 | | |
4109 | 4107 | | |
4110 | 4108 | | |
4111 | 4109 | | |
4112 | 4110 | | |
4113 | | - | |
| 4111 | + | |
| 4112 | + | |
| 4113 | + | |
4114 | 4114 | | |
4115 | | - | |
| 4115 | + | |
4116 | 4116 | | |
4117 | 4117 | | |
4118 | 4118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
227 | 264 | | |
228 | 265 | | |
229 | 266 | | |
230 | 267 | | |
231 | 268 | | |
232 | 269 | | |
233 | 270 | | |
234 | | - | |
235 | | - | |
| 271 | + | |
| 272 | + | |
236 | 273 | | |
237 | | - | |
| 274 | + | |
238 | 275 | | |
239 | 276 | | |
240 | 277 | | |
| |||
258 | 295 | | |
259 | 296 | | |
260 | 297 | | |
261 | | - | |
262 | | - | |
| 298 | + | |
| 299 | + | |
263 | 300 | | |
264 | | - | |
| 301 | + | |
265 | 302 | | |
266 | 303 | | |
267 | 304 | | |
| |||
0 commit comments