* [PATCH] afs: Fix mmap
@ 2021-12-14 9:22 David Howells
2021-12-16 17:13 ` Linus Torvalds
0 siblings, 1 reply; 4+ messages in thread
From: David Howells @ 2021-12-14 9:22 UTC (permalink / raw)
To: torvalds
Cc: dhowells, marc.dionne, jaltman, linux-afs, linux-fsdevel, linux-kernel
Hi Linus,
Could you apply this patch please? Note the odd email address in the
Reported-by and Tested-by fields. That's an attempt to note Auristor's
internal testcase ID for their tracking purposes. Is this a reasonable way
to do it? It's kind of modelled on what syzbot does. Would it be
preferable to use some other field or a comment after the Reported-by
instead?
David
---
afs: Fix mmap
Fix afs_add_open_map() to check that the vnode isn't already on the list
when it adds it. It's possible that afs_drop_open_mmap() decremented the
cb_nr_mmap counter, but hadn't yet got into the locked section to remove
it.
Also vnode->cb_mmap_link should be initialised, so fix that too.
Fixes: 6e0e99d58a65 ("afs: Fix mmap coherency vs 3rd-party changes")
Reported-by: kafs-testing+fedora34_64checkkafs-build-300@auristor.com
Suggested-by: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: kafs-testing+fedora34_64checkkafs-build-300@auristor.com
cc: linux-afs@lists.infradead.org
Link: https://lore.kernel.org/r/686465.1639435380@warthog.procyon.org.uk/ # v1
---
fs/afs/file.c | 5 +++--
fs/afs/super.c | 1 +
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/afs/file.c b/fs/afs/file.c
index cb6ad61eec3b..afe4b803f84b 100644
--- a/fs/afs/file.c
+++ b/fs/afs/file.c
@@ -514,8 +514,9 @@ static void afs_add_open_mmap(struct afs_vnode *vnode)
if (atomic_inc_return(&vnode->cb_nr_mmap) == 1) {
down_write(&vnode->volume->cell->fs_open_mmaps_lock);
- list_add_tail(&vnode->cb_mmap_link,
- &vnode->volume->cell->fs_open_mmaps);
+ if (list_empty(&vnode->cb_mmap_link))
+ list_add_tail(&vnode->cb_mmap_link,
+ &vnode->volume->cell->fs_open_mmaps);
up_write(&vnode->volume->cell->fs_open_mmaps_lock);
}
diff --git a/fs/afs/super.c b/fs/afs/super.c
index d110def8aa8e..34c68724c98b 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -667,6 +667,7 @@ static void afs_i_init_once(void *_vnode)
INIT_LIST_HEAD(&vnode->pending_locks);
INIT_LIST_HEAD(&vnode->granted_locks);
INIT_DELAYED_WORK(&vnode->lock_work, afs_lock_work);
+ INIT_LIST_HEAD(&vnode->cb_mmap_link);
seqlock_init(&vnode->cb_lock);
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] afs: Fix mmap
2021-12-14 9:22 [PATCH] afs: Fix mmap David Howells
@ 2021-12-16 17:13 ` Linus Torvalds
0 siblings, 0 replies; 4+ messages in thread
From: Linus Torvalds @ 2021-12-16 17:13 UTC (permalink / raw)
To: David Howells
Cc: Marc Dionne, Jeffrey E Altman, linux-afs, linux-fsdevel,
Linux Kernel Mailing List
On Tue, Dec 14, 2021 at 1:22 AM David Howells <dhowells@redhat.com> wrote:
>
> Could you apply this patch please? Note the odd email address in the
> Reported-by and Tested-by fields. That's an attempt to note Auristor's
> internal testcase ID for their tracking purposes. Is this a reasonable way
> to do it? It's kind of modelled on what syzbot does.
Yeah, this looks sane to me.
I don't like bare bug tracking IDs that don't tell anybody else
anything, but the "embedding it in the email" trick means that it now
(a) gives a contact for it so that it contains meaningful information
and (b) also acts a "namespace" for the testcase ID.
Applied.
Linus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] afs: Fix mmap
2021-12-13 16:57 David Howells
@ 2021-12-13 22:43 ` David Howells
0 siblings, 0 replies; 4+ messages in thread
From: David Howells @ 2021-12-13 22:43 UTC (permalink / raw)
To: marc.dionne; +Cc: dhowells, linux-afs, linux-fsdevel, linux-kernel
I forgot to commit the patch and so lost part of it. Full patch below.
David
---
commit 23e7d72edeeff56d7bfa47c32c9638385c90eddd
Author: David Howells <dhowells@redhat.com>
Date: Mon Dec 13 16:26:44 2021 +0000
afs: Fix mmap
Fix afs_add_open_map() to check that the vnode isn't already on the list
when it adds it. It's possible that afs_drop_open_mmap() decremented the
cb_nr_mmap counter, but hadn't yet got into the locked section to remove
it.
Also vnode->cb_mmap_link should be initialised, so fix that too.
Fixes: 6e0e99d58a65 ("afs: Fix mmap coherency vs 3rd-party changes")
Reported-by: kafs-testing+fedora34_64checkkafs-build-300@auristor.com
Suggested-by: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-afs@lists.infradead.org
diff --git a/fs/afs/file.c b/fs/afs/file.c
index cb6ad61eec3b..afe4b803f84b 100644
--- a/fs/afs/file.c
+++ b/fs/afs/file.c
@@ -514,8 +514,9 @@ static void afs_add_open_mmap(struct afs_vnode *vnode)
if (atomic_inc_return(&vnode->cb_nr_mmap) == 1) {
down_write(&vnode->volume->cell->fs_open_mmaps_lock);
- list_add_tail(&vnode->cb_mmap_link,
- &vnode->volume->cell->fs_open_mmaps);
+ if (list_empty(&vnode->cb_mmap_link))
+ list_add_tail(&vnode->cb_mmap_link,
+ &vnode->volume->cell->fs_open_mmaps);
up_write(&vnode->volume->cell->fs_open_mmaps_lock);
}
diff --git a/fs/afs/super.c b/fs/afs/super.c
index d110def8aa8e..34c68724c98b 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -667,6 +667,7 @@ static void afs_i_init_once(void *_vnode)
INIT_LIST_HEAD(&vnode->pending_locks);
INIT_LIST_HEAD(&vnode->granted_locks);
INIT_DELAYED_WORK(&vnode->lock_work, afs_lock_work);
+ INIT_LIST_HEAD(&vnode->cb_mmap_link);
seqlock_init(&vnode->cb_lock);
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] afs: Fix mmap
@ 2021-12-13 16:57 David Howells
2021-12-13 22:43 ` David Howells
0 siblings, 1 reply; 4+ messages in thread
From: David Howells @ 2021-12-13 16:57 UTC (permalink / raw)
To: marc.dionne; +Cc: dhowells, linux-afs, linux-fsdevel, linux-kernel
Fix afs_add_open_map() to check that the vnode isn't already on the list
when it adds it. It's possible that afs_drop_open_mmap() decremented the
cb_nr_mmap counter, but hadn't yet got into the locked section to remove
it.
Also vnode->cb_mmap_link should be initialised, so fix that too.
Fixes: 6e0e99d58a65 ("afs: Fix mmap coherency vs 3rd-party changes")
Reported-by: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-afs@lists.infradead.org
---
fs/afs/file.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/afs/file.c b/fs/afs/file.c
index 572063dad0b3..bcda99dcfdec 100644
--- a/fs/afs/file.c
+++ b/fs/afs/file.c
@@ -539,8 +539,9 @@ static void afs_add_open_mmap(struct afs_vnode *vnode)
if (atomic_inc_return(&vnode->cb_nr_mmap) == 1) {
down_write(&vnode->volume->cell->fs_open_mmaps_lock);
- list_add_tail(&vnode->cb_mmap_link,
- &vnode->volume->cell->fs_open_mmaps);
+ if (list_empty(&vnode->cb_mmap_link))
+ list_add_tail(&vnode->cb_mmap_link,
+ &vnode->volume->cell->fs_open_mmaps);
up_write(&vnode->volume->cell->fs_open_mmaps_lock);
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-16 17:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14 9:22 [PATCH] afs: Fix mmap David Howells
2021-12-16 17:13 ` Linus Torvalds
-- strict thread matches above, loose matches on Subject: below --
2021-12-13 16:57 David Howells
2021-12-13 22:43 ` David Howells
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.