* [PATCH] um: vector: Use GFP_ATOMIC under spin lock
@ 2020-06-19 5:20 Tiezhu Yang
2020-09-21 14:36 ` Anton Ivanov
0 siblings, 1 reply; 2+ messages in thread
From: Tiezhu Yang @ 2020-06-19 5:20 UTC (permalink / raw)
To: Jeff Dike, Richard Weinberger, Anton Ivanov
Cc: Xuefeng Li, Tiezhu Yang, linux-um, linux-kernel
Use GFP_ATOMIC instead of GFP_KERNEL under spin lock to fix possible
sleep-in-atomic-context bugs.
Fixes: 9807019a62dc ("um: Loadable BPF "Firmware" for vector drivers")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
arch/um/drivers/vector_kern.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
index 8735c46..555203e 100644
--- a/arch/um/drivers/vector_kern.c
+++ b/arch/um/drivers/vector_kern.c
@@ -1403,7 +1403,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev,
kfree(vp->bpf->filter);
vp->bpf->filter = NULL;
} else {
- vp->bpf = kmalloc(sizeof(struct sock_fprog), GFP_KERNEL);
+ vp->bpf = kmalloc(sizeof(struct sock_fprog), GFP_ATOMIC);
if (vp->bpf == NULL) {
netdev_err(dev, "failed to allocate memory for firmware\n");
goto flash_fail;
@@ -1415,7 +1415,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev,
if (request_firmware(&fw, efl->data, &vdevice->pdev.dev))
goto flash_fail;
- vp->bpf->filter = kmemdup(fw->data, fw->size, GFP_KERNEL);
+ vp->bpf->filter = kmemdup(fw->data, fw->size, GFP_ATOMIC);
if (!vp->bpf->filter)
goto free_buffer;
--
2.1.0
_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] um: vector: Use GFP_ATOMIC under spin lock
2020-06-19 5:20 [PATCH] um: vector: Use GFP_ATOMIC under spin lock Tiezhu Yang
@ 2020-09-21 14:36 ` Anton Ivanov
0 siblings, 0 replies; 2+ messages in thread
From: Anton Ivanov @ 2020-09-21 14:36 UTC (permalink / raw)
To: Tiezhu Yang, Jeff Dike, Richard Weinberger
Cc: Xuefeng Li, linux-um, linux-kernel
On 19/06/2020 06:20, Tiezhu Yang wrote:
> Use GFP_ATOMIC instead of GFP_KERNEL under spin lock to fix possible
> sleep-in-atomic-context bugs.
>
> Fixes: 9807019a62dc ("um: Loadable BPF "Firmware" for vector drivers")
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
> arch/um/drivers/vector_kern.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
> index 8735c46..555203e 100644
> --- a/arch/um/drivers/vector_kern.c
> +++ b/arch/um/drivers/vector_kern.c
> @@ -1403,7 +1403,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev,
> kfree(vp->bpf->filter);
> vp->bpf->filter = NULL;
> } else {
> - vp->bpf = kmalloc(sizeof(struct sock_fprog), GFP_KERNEL);
> + vp->bpf = kmalloc(sizeof(struct sock_fprog), GFP_ATOMIC);
> if (vp->bpf == NULL) {
> netdev_err(dev, "failed to allocate memory for firmware\n");
> goto flash_fail;
> @@ -1415,7 +1415,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev,
> if (request_firmware(&fw, efl->data, &vdevice->pdev.dev))
> goto flash_fail;
>
> - vp->bpf->filter = kmemdup(fw->data, fw->size, GFP_KERNEL);
> + vp->bpf->filter = kmemdup(fw->data, fw->size, GFP_ATOMIC);
> if (!vp->bpf->filter)
> goto free_buffer;
>
>
Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com>
--
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/
_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-21 14:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-19 5:20 [PATCH] um: vector: Use GFP_ATOMIC under spin lock Tiezhu Yang
2020-09-21 14:36 ` Anton Ivanov
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).