* FAILED: patch "[PATCH] net/9p: Initialize the iounit field during fid creation" failed to apply to 5.10-stable tree
@ 2022-08-15 11:49 gregkh
2022-08-15 12:51 ` asmadeus
2022-08-16 1:49 ` [PATCH 5.10 5.4 4.19] net/9p: Initialize the iounit field during fid creation Tyler Hicks
0 siblings, 2 replies; 5+ messages in thread
From: gregkh @ 2022-08-15 11:49 UTC (permalink / raw)
To: tyhicks, asmadeus, linux_oss; +Cc: stable
The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From aa7aeee169480e98cf41d83c01290a37e569be6d Mon Sep 17 00:00:00 2001
From: Tyler Hicks <tyhicks@linux.microsoft.com>
Date: Sun, 10 Jul 2022 09:14:02 -0500
Subject: [PATCH] net/9p: Initialize the iounit field during fid creation
Ensure that the fid's iounit field is set to zero when a new fid is
created. Certain 9P operations, such as OPEN and CREATE, allow the
server to reply with an iounit size which the client code assigns to the
p9_fid struct shortly after the fid is created by p9_fid_create(). On
the other hand, an XATTRWALK operation doesn't allow for the server to
specify an iounit value. The iounit field of the newly allocated p9_fid
struct remained uninitialized in that case. Depending on allocation
patterns, the iounit value could have been something reasonable that was
carried over from previously freed fids or, in the worst case, could
have been arbitrary values from non-fid related usages of the memory
location.
The bug was detected in the Windows Subsystem for Linux 2 (WSL2) kernel
after the uninitialized iounit field resulted in the typical sequence of
two getxattr(2) syscalls, one to get the size of an xattr and another
after allocating a sufficiently sized buffer to fit the xattr value, to
hit an unexpected ERANGE error in the second call to getxattr(2). An
uninitialized iounit field would sometimes force rsize to be smaller
than the xattr value size in p9_client_read_once() and the 9P server in
WSL refused to chunk up the READ on the attr_fid and, instead, returned
ERANGE to the client. The virtfs server in QEMU seems happy to chunk up
the READ and this problem goes undetected there.
Link: https://lkml.kernel.org/r/20220710141402.803295-1-tyhicks@linux.microsoft.com
Fixes: ebf46264a004 ("fs/9p: Add support user. xattr")
Cc: stable@vger.kernel.org
Signed-off-by: Tyler Hicks <tyhicks@linux.microsoft.com>
Reviewed-by: Christian Schoenebeck <linux_oss@crudebyte.com>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
diff --git a/net/9p/client.c b/net/9p/client.c
index 89c5aeb00076..3c145a64dc2b 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -887,16 +887,13 @@ static struct p9_fid *p9_fid_create(struct p9_client *clnt)
struct p9_fid *fid;
p9_debug(P9_DEBUG_FID, "clnt %p\n", clnt);
- fid = kmalloc(sizeof(*fid), GFP_KERNEL);
+ fid = kzalloc(sizeof(*fid), GFP_KERNEL);
if (!fid)
return NULL;
- memset(&fid->qid, 0, sizeof(fid->qid));
fid->mode = -1;
fid->uid = current_fsuid();
fid->clnt = clnt;
- fid->rdir = NULL;
- fid->fid = 0;
refcount_set(&fid->count, 1);
idr_preload(GFP_KERNEL);
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: FAILED: patch "[PATCH] net/9p: Initialize the iounit field during fid creation" failed to apply to 5.10-stable tree
2022-08-15 11:49 FAILED: patch "[PATCH] net/9p: Initialize the iounit field during fid creation" failed to apply to 5.10-stable tree gregkh
@ 2022-08-15 12:51 ` asmadeus
2022-08-15 16:55 ` Tyler Hicks
2022-08-16 1:49 ` [PATCH 5.10 5.4 4.19] net/9p: Initialize the iounit field during fid creation Tyler Hicks
1 sibling, 1 reply; 5+ messages in thread
From: asmadeus @ 2022-08-15 12:51 UTC (permalink / raw)
To: tyhicks; +Cc: gregkh, linux_oss, stable
gregkh@linuxfoundation.org wrote on Mon, Aug 15, 2022 at 01:49:31PM +0200:
> The patch below does not apply to the 5.10-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
I guess it'd make sense, Tyler do you want to do it or shall I?
Probably almost trivial with just context around the zero
initializations you removed that changed a bit.
--
Dominique
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: FAILED: patch "[PATCH] net/9p: Initialize the iounit field during fid creation" failed to apply to 5.10-stable tree
2022-08-15 12:51 ` asmadeus
@ 2022-08-15 16:55 ` Tyler Hicks
0 siblings, 0 replies; 5+ messages in thread
From: Tyler Hicks @ 2022-08-15 16:55 UTC (permalink / raw)
To: asmadeus; +Cc: gregkh, linux_oss, stable
On 2022-08-15 21:51:22, asmadeus@codewreck.org wrote:
> gregkh@linuxfoundation.org wrote on Mon, Aug 15, 2022 at 01:49:31PM +0200:
> > The patch below does not apply to the 5.10-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to <stable@vger.kernel.org>.
>
> I guess it'd make sense, Tyler do you want to do it or shall I?
I'll take care of it today.
> Probably almost trivial with just context around the zero
> initializations you removed that changed a bit.
Yep, that's correct.
Tyler
>
> --
> Dominique
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 5.10 5.4 4.19] net/9p: Initialize the iounit field during fid creation
2022-08-15 11:49 FAILED: patch "[PATCH] net/9p: Initialize the iounit field during fid creation" failed to apply to 5.10-stable tree gregkh
2022-08-15 12:51 ` asmadeus
@ 2022-08-16 1:49 ` Tyler Hicks
2022-08-19 11:04 ` Greg KH
1 sibling, 1 reply; 5+ messages in thread
From: Tyler Hicks @ 2022-08-16 1:49 UTC (permalink / raw)
To: gregkh; +Cc: asmadeus, linux_oss, stable
[ Upstream commit aa7aeee169480e98cf41d83c01290a37e569be6d ]
Ensure that the fid's iounit field is set to zero when a new fid is
created. Certain 9P operations, such as OPEN and CREATE, allow the
server to reply with an iounit size which the client code assigns to the
p9_fid struct shortly after the fid is created by p9_fid_create(). On
the other hand, an XATTRWALK operation doesn't allow for the server to
specify an iounit value. The iounit field of the newly allocated p9_fid
struct remained uninitialized in that case. Depending on allocation
patterns, the iounit value could have been something reasonable that was
carried over from previously freed fids or, in the worst case, could
have been arbitrary values from non-fid related usages of the memory
location.
The bug was detected in the Windows Subsystem for Linux 2 (WSL2) kernel
after the uninitialized iounit field resulted in the typical sequence of
two getxattr(2) syscalls, one to get the size of an xattr and another
after allocating a sufficiently sized buffer to fit the xattr value, to
hit an unexpected ERANGE error in the second call to getxattr(2). An
uninitialized iounit field would sometimes force rsize to be smaller
than the xattr value size in p9_client_read_once() and the 9P server in
WSL refused to chunk up the READ on the attr_fid and, instead, returned
ERANGE to the client. The virtfs server in QEMU seems happy to chunk up
the READ and this problem goes undetected there.
Link: https://lkml.kernel.org/r/20220710141402.803295-1-tyhicks@linux.microsoft.com
Fixes: ebf46264a004 ("fs/9p: Add support user. xattr")
Cc: stable@vger.kernel.org
Signed-off-by: Tyler Hicks <tyhicks@linux.microsoft.com>
Reviewed-by: Christian Schoenebeck <linux_oss@crudebyte.com>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
[tyhicks: Adjusted context due to:
- Lack of fid refcounting introduced in v5.11 commit 6636b6dcc3db ("9p:
add refcount to p9_fid struct")
- Difference in how buffer sizes are specified v5.16 commit
6e195b0f7c8e ("9p: fix a bunch of checkpatch warnings")]
Signed-off-by: Tyler Hicks <tyhicks@linux.microsoft.com>
---
Tested on top of v5.10.136. Verified to apply to v5.4 and v4.19 and the
resulting code was read for correctness.
Tyler
net/9p/client.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/net/9p/client.c b/net/9p/client.c
index bf6ed00d7c37..e8862cd4f91b 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -893,16 +893,13 @@ static struct p9_fid *p9_fid_create(struct p9_client *clnt)
struct p9_fid *fid;
p9_debug(P9_DEBUG_FID, "clnt %p\n", clnt);
- fid = kmalloc(sizeof(struct p9_fid), GFP_KERNEL);
+ fid = kzalloc(sizeof(struct p9_fid), GFP_KERNEL);
if (!fid)
return NULL;
- memset(&fid->qid, 0, sizeof(struct p9_qid));
fid->mode = -1;
fid->uid = current_fsuid();
fid->clnt = clnt;
- fid->rdir = NULL;
- fid->fid = 0;
idr_preload(GFP_KERNEL);
spin_lock_irq(&clnt->lock);
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 5.10 5.4 4.19] net/9p: Initialize the iounit field during fid creation
2022-08-16 1:49 ` [PATCH 5.10 5.4 4.19] net/9p: Initialize the iounit field during fid creation Tyler Hicks
@ 2022-08-19 11:04 ` Greg KH
0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2022-08-19 11:04 UTC (permalink / raw)
To: Tyler Hicks; +Cc: asmadeus, linux_oss, stable
On Mon, Aug 15, 2022 at 08:49:25PM -0500, Tyler Hicks wrote:
> [ Upstream commit aa7aeee169480e98cf41d83c01290a37e569be6d ]
>
> Ensure that the fid's iounit field is set to zero when a new fid is
> created. Certain 9P operations, such as OPEN and CREATE, allow the
> server to reply with an iounit size which the client code assigns to the
> p9_fid struct shortly after the fid is created by p9_fid_create(). On
> the other hand, an XATTRWALK operation doesn't allow for the server to
> specify an iounit value. The iounit field of the newly allocated p9_fid
> struct remained uninitialized in that case. Depending on allocation
> patterns, the iounit value could have been something reasonable that was
> carried over from previously freed fids or, in the worst case, could
> have been arbitrary values from non-fid related usages of the memory
> location.
>
> The bug was detected in the Windows Subsystem for Linux 2 (WSL2) kernel
> after the uninitialized iounit field resulted in the typical sequence of
> two getxattr(2) syscalls, one to get the size of an xattr and another
> after allocating a sufficiently sized buffer to fit the xattr value, to
> hit an unexpected ERANGE error in the second call to getxattr(2). An
> uninitialized iounit field would sometimes force rsize to be smaller
> than the xattr value size in p9_client_read_once() and the 9P server in
> WSL refused to chunk up the READ on the attr_fid and, instead, returned
> ERANGE to the client. The virtfs server in QEMU seems happy to chunk up
> the READ and this problem goes undetected there.
>
> Link: https://lkml.kernel.org/r/20220710141402.803295-1-tyhicks@linux.microsoft.com
> Fixes: ebf46264a004 ("fs/9p: Add support user. xattr")
> Cc: stable@vger.kernel.org
> Signed-off-by: Tyler Hicks <tyhicks@linux.microsoft.com>
> Reviewed-by: Christian Schoenebeck <linux_oss@crudebyte.com>
> Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
> [tyhicks: Adjusted context due to:
> - Lack of fid refcounting introduced in v5.11 commit 6636b6dcc3db ("9p:
> add refcount to p9_fid struct")
> - Difference in how buffer sizes are specified v5.16 commit
> 6e195b0f7c8e ("9p: fix a bunch of checkpatch warnings")]
> Signed-off-by: Tyler Hicks <tyhicks@linux.microsoft.com>
> ---
>
> Tested on top of v5.10.136. Verified to apply to v5.4 and v4.19 and the
> resulting code was read for correctness.
>
All now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-08-19 11:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-15 11:49 FAILED: patch "[PATCH] net/9p: Initialize the iounit field during fid creation" failed to apply to 5.10-stable tree gregkh
2022-08-15 12:51 ` asmadeus
2022-08-15 16:55 ` Tyler Hicks
2022-08-16 1:49 ` [PATCH 5.10 5.4 4.19] net/9p: Initialize the iounit field during fid creation Tyler Hicks
2022-08-19 11:04 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox