netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] 9p: Fixes for hard-to-hit bugs
@ 2017-09-06 14:59 Tuomas Tynkkynen
  2017-09-06 14:59 ` [PATCH 1/2] fs/9p: Compare qid.path in v9fs_test_inode Tuomas Tynkkynen
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Tuomas Tynkkynen @ 2017-09-06 14:59 UTC (permalink / raw)
  To: Al Viro
  Cc: v9fs-developer, Eric Van Hensbergen, Ron Minnich,
	Latchesar Ionkov, David S. Miller, linux-kernel, netdev,
	linux-fsdevel, Tuomas Tynkkynen

These two patches fix two hard-to-hit (but really annoying) bugs in 9p.
The first one was posted earlier in February (with one R-b), the second
is a new one.

Both of these have had soaking in NixOS distribution kernels for
a couple of months with no ill effects.

Tuomas Tynkkynen (2):
  fs/9p: Compare qid.path in v9fs_test_inode
  net/9p: Switch to wait_event_killable()

 fs/9p/vfs_inode.c      |  3 +++
 fs/9p/vfs_inode_dotl.c |  3 +++
 net/9p/client.c        |  3 +--
 net/9p/trans_virtio.c  | 13 ++++++-------
 net/9p/trans_xen.c     |  4 ++--
 5 files changed, 15 insertions(+), 11 deletions(-)

-- 
2.13.0

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

* [PATCH 1/2] fs/9p: Compare qid.path in v9fs_test_inode
  2017-09-06 14:59 [PATCH 0/2] 9p: Fixes for hard-to-hit bugs Tuomas Tynkkynen
@ 2017-09-06 14:59 ` Tuomas Tynkkynen
  2017-09-06 14:59 ` [PATCH 2/2] net/9p: Switch to wait_event_killable() Tuomas Tynkkynen
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Tuomas Tynkkynen @ 2017-09-06 14:59 UTC (permalink / raw)
  To: Al Viro
  Cc: v9fs-developer, Eric Van Hensbergen, Ron Minnich,
	Latchesar Ionkov, David S. Miller, linux-kernel, netdev,
	linux-fsdevel, Tuomas Tynkkynen, stable

Commit fd2421f54423 ("fs/9p: When doing inode lookup compare qid details
and inode mode bits.") transformed v9fs_qid_iget() to use iget5_locked()
instead of iget_locked(). However, the test() callback is not checking
fid.path at all, which means that a lookup in the inode cache can now
accidentally locate a completely wrong inode from the same inode hash
bucket if the other fields (qid.type and qid.version) match.

Fixes: fd2421f54423 ("fs/9p: When doing inode lookup compare qid details and inode mode bits.")
Cc: stable@vger.kernel.org
Reviewed-by: Latchesar Ionkov <lucho@ionkov.net>
Signed-off-by: Tuomas Tynkkynen <tuomas@tuxera.com>
---
 fs/9p/vfs_inode.c      | 3 +++
 fs/9p/vfs_inode_dotl.c | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 2a5de610dd8f..bdabb2765d1b 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -483,6 +483,9 @@ static int v9fs_test_inode(struct inode *inode, void *data)
 
 	if (v9inode->qid.type != st->qid.type)
 		return 0;
+
+	if (v9inode->qid.path != st->qid.path)
+		return 0;
 	return 1;
 }
 
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index 70f9887c59a9..7f6ae21a27b3 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -87,6 +87,9 @@ static int v9fs_test_inode_dotl(struct inode *inode, void *data)
 
 	if (v9inode->qid.type != st->qid.type)
 		return 0;
+
+	if (v9inode->qid.path != st->qid.path)
+		return 0;
 	return 1;
 }
 
-- 
2.13.0

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

* [PATCH 2/2] net/9p: Switch to wait_event_killable()
  2017-09-06 14:59 [PATCH 0/2] 9p: Fixes for hard-to-hit bugs Tuomas Tynkkynen
  2017-09-06 14:59 ` [PATCH 1/2] fs/9p: Compare qid.path in v9fs_test_inode Tuomas Tynkkynen
@ 2017-09-06 14:59 ` Tuomas Tynkkynen
  2017-09-07 14:49 ` [PATCH 0/2] 9p: Fixes for hard-to-hit bugs Latchesar Ionkov
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Tuomas Tynkkynen @ 2017-09-06 14:59 UTC (permalink / raw)
  To: Al Viro
  Cc: v9fs-developer, Eric Van Hensbergen, Ron Minnich,
	Latchesar Ionkov, David S. Miller, linux-kernel, netdev,
	linux-fsdevel, Tuomas Tynkkynen, stable

Because userspace gets Very Unhappy when calls like stat() and execve()
return -EINTR on 9p filesystem mounts. For instance, when bash is
looking in PATH for things to execute and some SIGCHLD interrupts
stat(), bash can throw a spurious 'command not found' since it doesn't
retry the stat().

In practice, hitting the problem is rare and needs a really
slow/bogged down 9p server.

Cc: stable@vger.kernel.org
Signed-off-by: Tuomas Tynkkynen <tuomas@tuxera.com>
---
 net/9p/client.c       |  3 +--
 net/9p/trans_virtio.c | 13 ++++++-------
 net/9p/trans_xen.c    |  4 ++--
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/net/9p/client.c b/net/9p/client.c
index 4674235b0d9b..1beb131dd3e1 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -773,8 +773,7 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...)
 	}
 again:
 	/* Wait for the response */
-	err = wait_event_interruptible(*req->wq,
-				       req->status >= REQ_STATUS_RCVD);
+	err = wait_event_killable(*req->wq, req->status >= REQ_STATUS_RCVD);
 
 	/*
 	 * Make sure our req is coherent with regard to updates in other
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index f24b25c25106..f3a4efcf1456 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -286,8 +286,8 @@ p9_virtio_request(struct p9_client *client, struct p9_req_t *req)
 		if (err == -ENOSPC) {
 			chan->ring_bufs_avail = 0;
 			spin_unlock_irqrestore(&chan->lock, flags);
-			err = wait_event_interruptible(*chan->vc_wq,
-							chan->ring_bufs_avail);
+			err = wait_event_killable(*chan->vc_wq,
+						  chan->ring_bufs_avail);
 			if (err  == -ERESTARTSYS)
 				return err;
 
@@ -327,7 +327,7 @@ static int p9_get_mapped_pages(struct virtio_chan *chan,
 		 * Other zc request to finish here
 		 */
 		if (atomic_read(&vp_pinned) >= chan->p9_max_pages) {
-			err = wait_event_interruptible(vp_wq,
+			err = wait_event_killable(vp_wq,
 			      (atomic_read(&vp_pinned) < chan->p9_max_pages));
 			if (err == -ERESTARTSYS)
 				return err;
@@ -471,8 +471,8 @@ p9_virtio_zc_request(struct p9_client *client, struct p9_req_t *req,
 		if (err == -ENOSPC) {
 			chan->ring_bufs_avail = 0;
 			spin_unlock_irqrestore(&chan->lock, flags);
-			err = wait_event_interruptible(*chan->vc_wq,
-						       chan->ring_bufs_avail);
+			err = wait_event_killable(*chan->vc_wq,
+						  chan->ring_bufs_avail);
 			if (err  == -ERESTARTSYS)
 				goto err_out;
 
@@ -489,8 +489,7 @@ p9_virtio_zc_request(struct p9_client *client, struct p9_req_t *req,
 	virtqueue_kick(chan->vq);
 	spin_unlock_irqrestore(&chan->lock, flags);
 	p9_debug(P9_DEBUG_TRANS, "virtio request kicked\n");
-	err = wait_event_interruptible(*req->wq,
-				       req->status >= REQ_STATUS_RCVD);
+	err = wait_event_killable(*req->wq, req->status >= REQ_STATUS_RCVD);
 	/*
 	 * Non kernel buffers are pinned, unpin them
 	 */
diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c
index 6ad3e043c617..325c56043007 100644
--- a/net/9p/trans_xen.c
+++ b/net/9p/trans_xen.c
@@ -156,8 +156,8 @@ static int p9_xen_request(struct p9_client *client, struct p9_req_t *p9_req)
 	ring = &priv->rings[num];
 
 again:
-	while (wait_event_interruptible(ring->wq,
-					p9_xen_write_todo(ring, size)) != 0)
+	while (wait_event_killable(ring->wq,
+				   p9_xen_write_todo(ring, size)) != 0)
 		;
 
 	spin_lock_irqsave(&ring->lock, flags);
-- 
2.13.0

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

* Re: [PATCH 0/2] 9p: Fixes for hard-to-hit bugs
  2017-09-06 14:59 [PATCH 0/2] 9p: Fixes for hard-to-hit bugs Tuomas Tynkkynen
  2017-09-06 14:59 ` [PATCH 1/2] fs/9p: Compare qid.path in v9fs_test_inode Tuomas Tynkkynen
  2017-09-06 14:59 ` [PATCH 2/2] net/9p: Switch to wait_event_killable() Tuomas Tynkkynen
@ 2017-09-07 14:49 ` Latchesar Ionkov
  2017-09-26 13:10 ` Tuomas Tynkkynen
  2017-10-20 12:34 ` Tuomas Tynkkynen
  4 siblings, 0 replies; 10+ messages in thread
From: Latchesar Ionkov @ 2017-09-07 14:49 UTC (permalink / raw)
  To: Tuomas Tynkkynen
  Cc: Al Viro, V9FS Developers, Eric Van Hensbergen, Ron Minnich,
	David S. Miller, Linux Kernel, netdev, linux-fsdevel

Acked-by: Latchesar Ionkov <lucho@ionkov.net>

On Wed, Sep 6, 2017 at 8:59 AM, Tuomas Tynkkynen <tuomas@tuxera.com> wrote:
> These two patches fix two hard-to-hit (but really annoying) bugs in 9p.
> The first one was posted earlier in February (with one R-b), the second
> is a new one.
>
> Both of these have had soaking in NixOS distribution kernels for
> a couple of months with no ill effects.
>
> Tuomas Tynkkynen (2):
>   fs/9p: Compare qid.path in v9fs_test_inode
>   net/9p: Switch to wait_event_killable()
>
>  fs/9p/vfs_inode.c      |  3 +++
>  fs/9p/vfs_inode_dotl.c |  3 +++
>  net/9p/client.c        |  3 +--
>  net/9p/trans_virtio.c  | 13 ++++++-------
>  net/9p/trans_xen.c     |  4 ++--
>  5 files changed, 15 insertions(+), 11 deletions(-)
>
> --
> 2.13.0
>

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

* Re: [PATCH 0/2] 9p: Fixes for hard-to-hit bugs
  2017-09-06 14:59 [PATCH 0/2] 9p: Fixes for hard-to-hit bugs Tuomas Tynkkynen
                   ` (2 preceding siblings ...)
  2017-09-07 14:49 ` [PATCH 0/2] 9p: Fixes for hard-to-hit bugs Latchesar Ionkov
@ 2017-09-26 13:10 ` Tuomas Tynkkynen
  2017-10-20 20:11   ` Al Viro
  2017-10-20 12:34 ` Tuomas Tynkkynen
  4 siblings, 1 reply; 10+ messages in thread
From: Tuomas Tynkkynen @ 2017-09-26 13:10 UTC (permalink / raw)
  To: Al Viro
  Cc: v9fs-developer, Eric Van Hensbergen, Ron Minnich,
	Latchesar Ionkov, David S. Miller, linux-kernel, netdev,
	linux-fsdevel

Hi Al,

On Wed, 2017-09-06 at 17:59 +0300, Tuomas Tynkkynen wrote:
> These two patches fix two hard-to-hit (but really annoying) bugs in
> 9p.
> The first one was posted earlier in February (with one R-b), the
> second
> is a new one.
> 
> Both of these have had soaking in NixOS distribution kernels for
> a couple of months with no ill effects.
> 
> Tuomas Tynkkynen (2):
>   fs/9p: Compare qid.path in v9fs_test_inode
>   net/9p: Switch to wait_event_killable()
> 
>  fs/9p/vfs_inode.c      |  3 +++
>  fs/9p/vfs_inode_dotl.c |  3 +++
>  net/9p/client.c        |  3 +--
>  net/9p/trans_virtio.c  | 13 ++++++-------
>  net/9p/trans_xen.c     |  4 ++--
>  5 files changed, 15 insertions(+), 11 deletions(-)
> 

Could you apply these? Thanks!

- Tuomas

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

* Re: [PATCH 0/2] 9p: Fixes for hard-to-hit bugs
  2017-09-06 14:59 [PATCH 0/2] 9p: Fixes for hard-to-hit bugs Tuomas Tynkkynen
                   ` (3 preceding siblings ...)
  2017-09-26 13:10 ` Tuomas Tynkkynen
@ 2017-10-20 12:34 ` Tuomas Tynkkynen
  2017-10-20 19:40   ` Linus Torvalds
  4 siblings, 1 reply; 10+ messages in thread
From: Tuomas Tynkkynen @ 2017-10-20 12:34 UTC (permalink / raw)
  To: Al Viro, Linus Torvalds
  Cc: v9fs-developer, Eric Van Hensbergen, Ron Minnich,
	Latchesar Ionkov, David S. Miller, linux-kernel, netdev,
	linux-fsdevel

Al, Linus

Can one of you please pick these patches? They've been on the list for
a month now, with an ack from Latchesar Ionkov.

Thanks!

Tuomas

On Wed, 2017-09-06 at 17:59 +0300, Tuomas Tynkkynen wrote:
> These two patches fix two hard-to-hit (but really annoying) bugs in
> 9p.
> The first one was posted earlier in February (with one R-b), the
> second
> is a new one.
> 
> Both of these have had soaking in NixOS distribution kernels for
> a couple of months with no ill effects.
> 
> Tuomas Tynkkynen (2):
>   fs/9p: Compare qid.path in v9fs_test_inode
>   net/9p: Switch to wait_event_killable()
> 
>  fs/9p/vfs_inode.c      |  3 +++
>  fs/9p/vfs_inode_dotl.c |  3 +++
>  net/9p/client.c        |  3 +--
>  net/9p/trans_virtio.c  | 13 ++++++-------
>  net/9p/trans_xen.c     |  4 ++--
>  5 files changed, 15 insertions(+), 11 deletions(-)
> 

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

* Re: [PATCH 0/2] 9p: Fixes for hard-to-hit bugs
  2017-10-20 12:34 ` Tuomas Tynkkynen
@ 2017-10-20 19:40   ` Linus Torvalds
  0 siblings, 0 replies; 10+ messages in thread
From: Linus Torvalds @ 2017-10-20 19:40 UTC (permalink / raw)
  To: Tuomas Tynkkynen
  Cc: Al Viro, V9FS Developers, Eric Van Hensbergen, Ron Minnich,
	Latchesar Ionkov, David S. Miller, Linux Kernel Mailing List,
	Network Development, linux-fsdevel

On Fri, Oct 20, 2017 at 8:34 AM, Tuomas Tynkkynen <tuomas@tuxera.com> wrote:
> Al, Linus
>
> Can one of you please pick these patches? They've been on the list for
> a month now, with an ack from Latchesar Ionkov.

I  don't pick up patches from the list. They need to be actually sent
to me so that I feel like I'm supposed to take them.

It does seem like 9pfs is unmaintained. I think I got my last 9p pull
request in January 2016. Hmm.

          Linus

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

* Re: [PATCH 0/2] 9p: Fixes for hard-to-hit bugs
  2017-09-26 13:10 ` Tuomas Tynkkynen
@ 2017-10-20 20:11   ` Al Viro
  2017-10-24  1:41     ` Tuomas Tynkkynen
  0 siblings, 1 reply; 10+ messages in thread
From: Al Viro @ 2017-10-20 20:11 UTC (permalink / raw)
  To: Tuomas Tynkkynen
  Cc: v9fs-developer, Eric Van Hensbergen, Ron Minnich,
	Latchesar Ionkov, David S. Miller, linux-kernel, netdev,
	linux-fsdevel

On Tue, Sep 26, 2017 at 04:10:14PM +0300, Tuomas Tynkkynen wrote:
> Hi Al,
> 
> On Wed, 2017-09-06 at 17:59 +0300, Tuomas Tynkkynen wrote:
> > These two patches fix two hard-to-hit (but really annoying) bugs in
> > 9p.
> > The first one was posted earlier in February (with one R-b), the
> > second
> > is a new one.
> > 
> > Both of these have had soaking in NixOS distribution kernels for
> > a couple of months with no ill effects.
> > 
> > Tuomas Tynkkynen (2):
> >   fs/9p: Compare qid.path in v9fs_test_inode
> >   net/9p: Switch to wait_event_killable()
> > 
> >  fs/9p/vfs_inode.c      |  3 +++
> >  fs/9p/vfs_inode_dotl.c |  3 +++
> >  net/9p/client.c        |  3 +--
> >  net/9p/trans_virtio.c  | 13 ++++++-------
> >  net/9p/trans_xen.c     |  4 ++--
> >  5 files changed, 15 insertions(+), 11 deletions(-)
> > 
> 
> Could you apply these? Thanks!

I can pick those, or, if you (or somebody else) are willing to actively
maintain a 9p tree, you could start sending straight to Linus - up to
you.

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

* Re: [PATCH 0/2] 9p: Fixes for hard-to-hit bugs
  2017-10-20 20:11   ` Al Viro
@ 2017-10-24  1:41     ` Tuomas Tynkkynen
  2017-10-24  2:11       ` Al Viro
  0 siblings, 1 reply; 10+ messages in thread
From: Tuomas Tynkkynen @ 2017-10-24  1:41 UTC (permalink / raw)
  To: Al Viro
  Cc: v9fs-developer, Eric Van Hensbergen, Ron Minnich,
	Latchesar Ionkov, David S. Miller, linux-kernel, netdev,
	linux-fsdevel

Hi Al,

On Fri, 2017-10-20 at 21:11 +0100, Al Viro wrote:
> On Tue, Sep 26, 2017 at 04:10:14PM +0300, Tuomas Tynkkynen wrote:
> > Hi Al,
> > 
> > On Wed, 2017-09-06 at 17:59 +0300, Tuomas Tynkkynen wrote:
> > > These two patches fix two hard-to-hit (but really annoying) bugs
> > > in
> > > 9p.
> > > The first one was posted earlier in February (with one R-b), the
> > > second
> > > is a new one.
> > > 
...
> > > 
> > 
> > Could you apply these? Thanks!
> 
> I can pick those, or, if you (or somebody else) are willing to
> actively
> maintain a 9p tree, you could start sending straight to Linus - up to
> you.

You can pick these up, I don't have plans for more patches right now
(unless we hit some new bugs that affect our workloads).

(FWIW there do lurk dragons there, at least 1) setxattr() with zero-
length value turns into a removexattr(), and 2) creat("foo", 0444)
fails due to the R/O perms when opening the writeback_fid. Fixes to
either didn't seem too easy...)

Thanks!

- Tuomas

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

* Re: [PATCH 0/2] 9p: Fixes for hard-to-hit bugs
  2017-10-24  1:41     ` Tuomas Tynkkynen
@ 2017-10-24  2:11       ` Al Viro
  0 siblings, 0 replies; 10+ messages in thread
From: Al Viro @ 2017-10-24  2:11 UTC (permalink / raw)
  To: Tuomas Tynkkynen
  Cc: v9fs-developer, Eric Van Hensbergen, Ron Minnich,
	Latchesar Ionkov, David S. Miller, linux-kernel, netdev,
	linux-fsdevel

On Tue, Oct 24, 2017 at 04:41:08AM +0300, Tuomas Tynkkynen wrote:

> > I can pick those, or, if you (or somebody else) are willing to
> > actively
> > maintain a 9p tree, you could start sending straight to Linus - up to
> > you.
> 
> You can pick these up, I don't have plans for more patches right now
> (unless we hit some new bugs that affect our workloads).

Done.

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

end of thread, other threads:[~2017-10-24  2:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-06 14:59 [PATCH 0/2] 9p: Fixes for hard-to-hit bugs Tuomas Tynkkynen
2017-09-06 14:59 ` [PATCH 1/2] fs/9p: Compare qid.path in v9fs_test_inode Tuomas Tynkkynen
2017-09-06 14:59 ` [PATCH 2/2] net/9p: Switch to wait_event_killable() Tuomas Tynkkynen
2017-09-07 14:49 ` [PATCH 0/2] 9p: Fixes for hard-to-hit bugs Latchesar Ionkov
2017-09-26 13:10 ` Tuomas Tynkkynen
2017-10-20 20:11   ` Al Viro
2017-10-24  1:41     ` Tuomas Tynkkynen
2017-10-24  2:11       ` Al Viro
2017-10-20 12:34 ` Tuomas Tynkkynen
2017-10-20 19:40   ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).