* [PATCH net v2] netrom: fix sleep in atomic context bugs in timer handlers
@ 2022-07-26 3:24 Duoming Zhou
2022-07-28 1:36 ` Jakub Kicinski
0 siblings, 1 reply; 3+ messages in thread
From: Duoming Zhou @ 2022-07-26 3:24 UTC (permalink / raw)
To: linux-hams
Cc: ralf, davem, edumazet, kuba, pabeni, netdev, linux-kernel, Duoming Zhou
There are sleep in atomic context bugs in timer handlers of netrom
such as nr_t1timer_expiry(), nr_t2timer_expiry(), nr_heartbeat_expiry(),
nr_idletimer_expiry() and so on.
The root cause is kmemdup() with GFP_KERNEL parameter that may sleep
could be called by different timer handlers which is in interrupt context.
One of the call paths that could trigger bug is shown below:
(interrupt context)
nr_heartbeat_expiry
nr_write_internal
nr_transmit_buffer
nr_route_frame
nr_add_node
kmemdup(..,GFP_KERNEL) //may sleep
This patch changes gfp_t parameter of kmemdup in nr_add_node()
from GFP_KERNEL to GFP_ATOMIC in order to prevent sleep in atomic
context bugs.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
---
Changes in v2:
- Correct the "Fixes" tag.
net/netrom/nr_route.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c
index baea3cbd76c..1ddcf13de6a 100644
--- a/net/netrom/nr_route.c
+++ b/net/netrom/nr_route.c
@@ -163,7 +163,7 @@ static int __must_check nr_add_node(ax25_address *nr, const char *mnemonic,
if (ax25_digi != NULL && ax25_digi->ndigi > 0) {
nr_neigh->digipeat = kmemdup(ax25_digi,
sizeof(*ax25_digi),
- GFP_KERNEL);
+ GFP_ATOMIC);
if (nr_neigh->digipeat == NULL) {
kfree(nr_neigh);
if (nr_node)
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net v2] netrom: fix sleep in atomic context bugs in timer handlers
2022-07-26 3:24 [PATCH net v2] netrom: fix sleep in atomic context bugs in timer handlers Duoming Zhou
@ 2022-07-28 1:36 ` Jakub Kicinski
2022-07-28 2:07 ` duoming
0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2022-07-28 1:36 UTC (permalink / raw)
To: Duoming Zhou
Cc: linux-hams, ralf, davem, edumazet, pabeni, netdev, linux-kernel
On Tue, 26 Jul 2022 11:24:20 +0800 Duoming Zhou wrote:
> nr_heartbeat_expiry
> nr_write_internal
> nr_transmit_buffer
void nr_transmit_buffer(struct sock *sk, struct sk_buff *skb)
{
[...]
if (!nr_route_frame(skb, NULL)) {
> nr_route_frame
int nr_route_frame(struct sk_buff *skb, ax25_cb *ax25)
{
[...]
if (ax25 != NULL) {
ret = nr_add_node(nr_src, "", &ax25->dest_addr, ax25->digipeat,
ax25 must be NULL on this path AFAICT.
> nr_add_node
> kmemdup(..,GFP_KERNEL) //may sleep
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net v2] netrom: fix sleep in atomic context bugs in timer handlers
2022-07-28 1:36 ` Jakub Kicinski
@ 2022-07-28 2:07 ` duoming
0 siblings, 0 replies; 3+ messages in thread
From: duoming @ 2022-07-28 2:07 UTC (permalink / raw)
To: Jakub Kicinski
Cc: linux-hams, ralf, davem, edumazet, pabeni, netdev, linux-kernel
Hello,
On Wed, 27 Jul 2022 18:36:47 -0700 Jakub Kicinski wrote:
> On Tue, 26 Jul 2022 11:24:20 +0800 Duoming Zhou wrote:
> > nr_heartbeat_expiry
> > nr_write_internal
> > nr_transmit_buffer
>
> void nr_transmit_buffer(struct sock *sk, struct sk_buff *skb)
> {
> [...]
> if (!nr_route_frame(skb, NULL)) {
>
> > nr_route_frame
>
> int nr_route_frame(struct sk_buff *skb, ax25_cb *ax25)
> {
> [...]
> if (ax25 != NULL) {
> ret = nr_add_node(nr_src, "", &ax25->dest_addr, ax25->digipeat,
>
> ax25 must be NULL on this path AFAICT.
>
> > nr_add_node
> > kmemdup(..,GFP_KERNEL) //may sleep
Thank you for your time and suggestions, I understand.
Best regards,
Duoming Zhou
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-28 2:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-26 3:24 [PATCH net v2] netrom: fix sleep in atomic context bugs in timer handlers Duoming Zhou
2022-07-28 1:36 ` Jakub Kicinski
2022-07-28 2:07 ` duoming
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.