Repository navigation
Commit 0b4e824
fsnotify: invalidate dcache before IN_DELETE event
commit a37d9a1 upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent 8bae6db commit 0b4e824
3 files changed
Lines changed: 49 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3103 | 3103 | | |
3104 | 3104 | | |
3105 | 3105 | | |
3106 | | - | |
3107 | | - | |
3108 | | - | |
3109 | | - | |
| 3106 | + | |
| 3107 | + | |
3110 | 3108 | | |
3111 | 3109 | | |
3112 | 3110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3709 | 3709 | | |
3710 | 3710 | | |
3711 | 3711 | | |
3712 | | - | |
3713 | 3712 | | |
3714 | 3713 | | |
3715 | 3714 | | |
3716 | 3715 | | |
3717 | 3716 | | |
3718 | | - | |
| 3717 | + | |
3719 | 3718 | | |
3720 | 3719 | | |
3721 | 3720 | | |
| |||
3825 | 3824 | | |
3826 | 3825 | | |
3827 | 3826 | | |
3828 | | - | |
3829 | 3827 | | |
3830 | 3828 | | |
3831 | 3829 | | |
3832 | 3830 | | |
3833 | 3831 | | |
3834 | 3832 | | |
3835 | 3833 | | |
3836 | | - | |
| 3834 | + | |
| 3835 | + | |
| 3836 | + | |
3837 | 3837 | | |
3838 | | - | |
| 3838 | + | |
3839 | 3839 | | |
3840 | 3840 | | |
3841 | 3841 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
206 | 242 | | |
207 | 243 | | |
208 | 244 | | |
209 | 245 | | |
210 | 246 | | |
211 | 247 | | |
212 | 248 | | |
213 | | - | |
214 | | - | |
| 249 | + | |
| 250 | + | |
215 | 251 | | |
216 | | - | |
| 252 | + | |
217 | 253 | | |
218 | 254 | | |
219 | 255 | | |
| |||
233 | 269 | | |
234 | 270 | | |
235 | 271 | | |
236 | | - | |
237 | | - | |
| 272 | + | |
| 273 | + | |
238 | 274 | | |
239 | | - | |
| 275 | + | |
240 | 276 | | |
241 | 277 | | |
242 | 278 | | |
| |||
0 commit comments