* [PATCH] cifs: Fix memory allocation in __smb2_handle_cancelled_cmd()
@ 2020-01-13 20:46 Paulo Alcantara (SUSE)
2020-01-13 20:58 ` Pavel Shilovsky
0 siblings, 1 reply; 5+ messages in thread
From: Paulo Alcantara (SUSE) @ 2020-01-13 20:46 UTC (permalink / raw)
To: smfrench; +Cc: linux-cifs, Paulo Alcantara (SUSE)
__smb2_handle_cancelled_cmd() is called under a spin lock held in
cifs_mid_q_entry_release(), so make its memory allocation GFP_ATOMIC.
This issue was observed when running xfstests generic/028:
[ 1722.589204] CIFS VFS: \\192.168.30.26 Cancelling wait for mid 72064 cmd: 5
[ 1722.590687] CIFS VFS: \\192.168.30.26 Cancelling wait for mid 72065 cmd: 17
[ 1722.593529] CIFS VFS: \\192.168.30.26 Cancelling wait for mid 72066 cmd: 6
[ 1723.039014] BUG: sleeping function called from invalid context at mm/slab.h:565
[ 1723.040710] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 30877, name: cifsd
[ 1723.045098] CPU: 3 PID: 30877 Comm: cifsd Not tainted 5.5.0-rc4+ #313
[ 1723.046256] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.0-59-gc9ba527-rebuilt.opensuse.org 04/01/2014
[ 1723.048221] Call Trace:
[ 1723.048689] dump_stack+0x97/0xe0
[ 1723.049268] ___might_sleep.cold+0xd1/0xe1
[ 1723.050069] kmem_cache_alloc_trace+0x204/0x2b0
[ 1723.051051] __smb2_handle_cancelled_cmd+0x40/0x140 [cifs]
[ 1723.052137] smb2_handle_cancelled_mid+0xf6/0x120 [cifs]
[ 1723.053247] cifs_mid_q_entry_release+0x44d/0x630 [cifs]
[ 1723.054351] ? cifs_reconnect+0x26a/0x1620 [cifs]
[ 1723.055325] cifs_demultiplex_thread+0xad4/0x14a0 [cifs]
[ 1723.056458] ? cifs_handle_standard+0x2c0/0x2c0 [cifs]
[ 1723.057365] ? kvm_sched_clock_read+0x14/0x30
[ 1723.058197] ? sched_clock+0x5/0x10
[ 1723.058838] ? sched_clock_cpu+0x18/0x110
[ 1723.059629] ? lockdep_hardirqs_on+0x17d/0x250
[ 1723.060456] kthread+0x1ab/0x200
[ 1723.061149] ? cifs_handle_standard+0x2c0/0x2c0 [cifs]
[ 1723.062078] ? kthread_create_on_node+0xd0/0xd0
[ 1723.062897] ret_from_fork+0x3a/0x50
Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Fixes: 9150c3adbf24 ("CIFS: Close open handle after interrupted close")
---
fs/cifs/smb2misc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c
index 0516fc482d43..0511aaf451d4 100644
--- a/fs/cifs/smb2misc.c
+++ b/fs/cifs/smb2misc.c
@@ -743,7 +743,7 @@ __smb2_handle_cancelled_cmd(struct cifs_tcon *tcon, __u16 cmd, __u64 mid,
{
struct close_cancelled_open *cancelled;
- cancelled = kzalloc(sizeof(*cancelled), GFP_KERNEL);
+ cancelled = kzalloc(sizeof(*cancelled), GFP_ATOMIC);
if (!cancelled)
return -ENOMEM;
--
2.24.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] cifs: Fix memory allocation in __smb2_handle_cancelled_cmd()
2020-01-13 20:46 [PATCH] cifs: Fix memory allocation in __smb2_handle_cancelled_cmd() Paulo Alcantara (SUSE)
@ 2020-01-13 20:58 ` Pavel Shilovsky
2020-01-13 21:13 ` Paulo Alcantara
0 siblings, 1 reply; 5+ messages in thread
From: Pavel Shilovsky @ 2020-01-13 20:58 UTC (permalink / raw)
To: Paulo Alcantara (SUSE); +Cc: Steve French, linux-cifs
пн, 13 янв. 2020 г. в 12:47, Paulo Alcantara (SUSE) <pc@cjr.nz>:
>
> __smb2_handle_cancelled_cmd() is called under a spin lock held in
> cifs_mid_q_entry_release(), so make its memory allocation GFP_ATOMIC.
>
> This issue was observed when running xfstests generic/028:
>
> [ 1722.589204] CIFS VFS: \\192.168.30.26 Cancelling wait for mid 72064 cmd: 5
> [ 1722.590687] CIFS VFS: \\192.168.30.26 Cancelling wait for mid 72065 cmd: 17
> [ 1722.593529] CIFS VFS: \\192.168.30.26 Cancelling wait for mid 72066 cmd: 6
> [ 1723.039014] BUG: sleeping function called from invalid context at mm/slab.h:565
> [ 1723.040710] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 30877, name: cifsd
> [ 1723.045098] CPU: 3 PID: 30877 Comm: cifsd Not tainted 5.5.0-rc4+ #313
> [ 1723.046256] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.0-59-gc9ba527-rebuilt.opensuse.org 04/01/2014
> [ 1723.048221] Call Trace:
> [ 1723.048689] dump_stack+0x97/0xe0
> [ 1723.049268] ___might_sleep.cold+0xd1/0xe1
> [ 1723.050069] kmem_cache_alloc_trace+0x204/0x2b0
> [ 1723.051051] __smb2_handle_cancelled_cmd+0x40/0x140 [cifs]
> [ 1723.052137] smb2_handle_cancelled_mid+0xf6/0x120 [cifs]
> [ 1723.053247] cifs_mid_q_entry_release+0x44d/0x630 [cifs]
> [ 1723.054351] ? cifs_reconnect+0x26a/0x1620 [cifs]
> [ 1723.055325] cifs_demultiplex_thread+0xad4/0x14a0 [cifs]
> [ 1723.056458] ? cifs_handle_standard+0x2c0/0x2c0 [cifs]
> [ 1723.057365] ? kvm_sched_clock_read+0x14/0x30
> [ 1723.058197] ? sched_clock+0x5/0x10
> [ 1723.058838] ? sched_clock_cpu+0x18/0x110
> [ 1723.059629] ? lockdep_hardirqs_on+0x17d/0x250
> [ 1723.060456] kthread+0x1ab/0x200
> [ 1723.061149] ? cifs_handle_standard+0x2c0/0x2c0 [cifs]
> [ 1723.062078] ? kthread_create_on_node+0xd0/0xd0
> [ 1723.062897] ret_from_fork+0x3a/0x50
>
> Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
> Fixes: 9150c3adbf24 ("CIFS: Close open handle after interrupted close")
> ---
> fs/cifs/smb2misc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c
> index 0516fc482d43..0511aaf451d4 100644
> --- a/fs/cifs/smb2misc.c
> +++ b/fs/cifs/smb2misc.c
> @@ -743,7 +743,7 @@ __smb2_handle_cancelled_cmd(struct cifs_tcon *tcon, __u16 cmd, __u64 mid,
> {
> struct close_cancelled_open *cancelled;
>
> - cancelled = kzalloc(sizeof(*cancelled), GFP_KERNEL);
> + cancelled = kzalloc(sizeof(*cancelled), GFP_ATOMIC);
> if (!cancelled)
> return -ENOMEM;
>
> --
> 2.24.1
>
Good catch!
Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
The patch 9150c3adbf24 was marked for stable, so, this one should be marked too.
--
Best regards,
Pavel Shilovsky
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cifs: Fix memory allocation in __smb2_handle_cancelled_cmd()
2020-01-13 20:58 ` Pavel Shilovsky
@ 2020-01-13 21:13 ` Paulo Alcantara
2020-01-14 7:23 ` Steve French
0 siblings, 1 reply; 5+ messages in thread
From: Paulo Alcantara @ 2020-01-13 21:13 UTC (permalink / raw)
To: Pavel Shilovsky; +Cc: Steve French, linux-cifs
Pavel Shilovsky <piastryyy@gmail.com> writes:
> The patch 9150c3adbf24 was marked for stable, so, this one should be
> marked too.
Ah, good point. Thanks!
Should I resend it or Steve would take care of it?
Paulo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cifs: Fix memory allocation in __smb2_handle_cancelled_cmd()
2020-01-13 21:13 ` Paulo Alcantara
@ 2020-01-14 7:23 ` Steve French
2020-01-15 21:11 ` Steve French
0 siblings, 1 reply; 5+ messages in thread
From: Steve French @ 2020-01-14 7:23 UTC (permalink / raw)
To: Paulo Alcantara; +Cc: Pavel Shilovsky, linux-cifs
I can update - it. Check back by Wednesday - I plan to add a bunch
of the work for next release into cifs-2.6.git for-next (including
this patch)
On Mon, Jan 13, 2020 at 3:13 PM Paulo Alcantara <pc@cjr.nz> wrote:
>
> Pavel Shilovsky <piastryyy@gmail.com> writes:
>
> > The patch 9150c3adbf24 was marked for stable, so, this one should be
> > marked too.
>
> Ah, good point. Thanks!
>
> Should I resend it or Steve would take care of it?
>
> Paulo
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cifs: Fix memory allocation in __smb2_handle_cancelled_cmd()
2020-01-14 7:23 ` Steve French
@ 2020-01-15 21:11 ` Steve French
0 siblings, 0 replies; 5+ messages in thread
From: Steve French @ 2020-01-15 21:11 UTC (permalink / raw)
To: Paulo Alcantara; +Cc: Pavel Shilovsky, linux-cifs
updated with reviewed-by and cc:stable
merged into cifs-2.6.git for-next
On Tue, Jan 14, 2020 at 1:23 AM Steve French <smfrench@gmail.com> wrote:
>
> I can update - it. Check back by Wednesday - I plan to add a bunch
> of the work for next release into cifs-2.6.git for-next (including
> this patch)
>
> On Mon, Jan 13, 2020 at 3:13 PM Paulo Alcantara <pc@cjr.nz> wrote:
> >
> > Pavel Shilovsky <piastryyy@gmail.com> writes:
> >
> > > The patch 9150c3adbf24 was marked for stable, so, this one should be
> > > marked too.
> >
> > Ah, good point. Thanks!
> >
> > Should I resend it or Steve would take care of it?
> >
> > Paulo
>
>
>
> --
> Thanks,
>
> Steve
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-01-15 21:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-13 20:46 [PATCH] cifs: Fix memory allocation in __smb2_handle_cancelled_cmd() Paulo Alcantara (SUSE)
2020-01-13 20:58 ` Pavel Shilovsky
2020-01-13 21:13 ` Paulo Alcantara
2020-01-14 7:23 ` Steve French
2020-01-15 21:11 ` Steve French
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).