* [PATCH] sctp: fix refcount bug in sctp_wfree
@ 2020-03-16 3:53 ` Qiujun Huang
0 siblings, 0 replies; 8+ messages in thread
From: Qiujun Huang @ 2020-03-16 3:53 UTC (permalink / raw)
To: vyasevich, nhorman, marcelo.leitner, davem, kuba
Cc: linux-sctp, netdev, linux-kernel, Qiujun Huang
Do accounting for skb's real sk.
In some case skb->sk != asoc->base.sk.
Reported-and-tested-by: syzbot+cea71eec5d6de256d54d@syzkaller.appspotmail.com
Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
---
net/sctp/socket.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 1b56fc4..5f5c28b 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -9080,7 +9080,7 @@ static void sctp_wfree(struct sk_buff *skb)
{
struct sctp_chunk *chunk = skb_shinfo(skb)->destructor_arg;
struct sctp_association *asoc = chunk->asoc;
- struct sock *sk = asoc->base.sk;
+ struct sock *sk = skb->sk;
sk_mem_uncharge(sk, skb->truesize);
sk->sk_wmem_queued -= skb->truesize + sizeof(struct sctp_chunk);
@@ -9109,7 +9109,7 @@ static void sctp_wfree(struct sk_buff *skb)
}
sock_wfree(skb);
- sctp_wake_up_waiters(sk, asoc);
+ sctp_wake_up_waiters(asoc->base.sk, asoc);
sctp_association_put(asoc);
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] sctp: fix refcount bug in sctp_wfree
@ 2020-03-16 3:53 ` Qiujun Huang
0 siblings, 0 replies; 8+ messages in thread
From: Qiujun Huang @ 2020-03-16 3:53 UTC (permalink / raw)
To: vyasevich, nhorman, marcelo.leitner, davem, kuba
Cc: linux-sctp, netdev, linux-kernel, Qiujun Huang
Do accounting for skb's real sk.
In some case skb->sk != asoc->base.sk.
Reported-and-tested-by: syzbot+cea71eec5d6de256d54d@syzkaller.appspotmail.com
Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
---
net/sctp/socket.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 1b56fc4..5f5c28b 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -9080,7 +9080,7 @@ static void sctp_wfree(struct sk_buff *skb)
{
struct sctp_chunk *chunk = skb_shinfo(skb)->destructor_arg;
struct sctp_association *asoc = chunk->asoc;
- struct sock *sk = asoc->base.sk;
+ struct sock *sk = skb->sk;
sk_mem_uncharge(sk, skb->truesize);
sk->sk_wmem_queued -= skb->truesize + sizeof(struct sctp_chunk);
@@ -9109,7 +9109,7 @@ static void sctp_wfree(struct sk_buff *skb)
}
sock_wfree(skb);
- sctp_wake_up_waiters(sk, asoc);
+ sctp_wake_up_waiters(asoc->base.sk, asoc);
sctp_association_put(asoc);
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] sctp: fix refcount bug in sctp_wfree
2020-03-16 3:53 ` Qiujun Huang
@ 2020-03-17 1:25 ` David Miller
-1 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2020-03-17 1:25 UTC (permalink / raw)
To: hqjagain
Cc: vyasevich, nhorman, marcelo.leitner, kuba, linux-sctp, netdev,
linux-kernel
From: Qiujun Huang <hqjagain@gmail.com>
Date: Mon, 16 Mar 2020 11:53:24 +0800
> Do accounting for skb's real sk.
> In some case skb->sk != asoc->base.sk.
>
> Reported-and-tested-by: syzbot+cea71eec5d6de256d54d@syzkaller.appspotmail.com
> Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
SCTP folks, please review.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] sctp: fix refcount bug in sctp_wfree
@ 2020-03-17 1:25 ` David Miller
0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2020-03-17 1:25 UTC (permalink / raw)
To: hqjagain
Cc: vyasevich, nhorman, marcelo.leitner, kuba, linux-sctp, netdev,
linux-kernel
From: Qiujun Huang <hqjagain@gmail.com>
Date: Mon, 16 Mar 2020 11:53:24 +0800
> Do accounting for skb's real sk.
> In some case skb->sk != asoc->base.sk.
>
> Reported-and-tested-by: syzbot+cea71eec5d6de256d54d@syzkaller.appspotmail.com
> Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
SCTP folks, please review.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] sctp: fix refcount bug in sctp_wfree
2020-03-16 3:53 ` Qiujun Huang
@ 2020-03-17 4:15 ` Marcelo Ricardo Leitner
-1 siblings, 0 replies; 8+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-03-17 4:15 UTC (permalink / raw)
To: Qiujun Huang
Cc: vyasevich, nhorman, davem, kuba, linux-sctp, netdev, linux-kernel
On Mon, Mar 16, 2020 at 11:53:24AM +0800, Qiujun Huang wrote:
> Do accounting for skb's real sk.
> In some case skb->sk != asoc->base.sk.
This is a too simple description. Please elaborate how this can
happen in sctp_wfree. Especially considering the construct for
migrating the tx queue on sctp_sock_migrate(), as both sockets are
locked while moving the chunks around and the asoc itself is only
moved in between decrementing and incrementing the refcount:
lock_sock_nested(newsk, SINGLE_DEPTH_NESTING);
sctp_for_each_tx_datachunk(assoc, sctp_clear_owner_w);
sctp_assoc_migrate(assoc, newsk);
sctp_for_each_tx_datachunk(assoc, sctp_set_owner_w);
...
>
> Reported-and-tested-by: syzbot+cea71eec5d6de256d54d@syzkaller.appspotmail.com
I can't see a positive test result, though. If I didn't loose any
email, your last test with a patch similar to this one actually
failed.
I'm talking about syzbot test result at Message-ID: <000000000000e7736205a0e041f5@google.com>
> Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
> ---
> net/sctp/socket.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 1b56fc4..5f5c28b 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -9080,7 +9080,7 @@ static void sctp_wfree(struct sk_buff *skb)
> {
> struct sctp_chunk *chunk = skb_shinfo(skb)->destructor_arg;
> struct sctp_association *asoc = chunk->asoc;
> - struct sock *sk = asoc->base.sk;
> + struct sock *sk = skb->sk;
>
> sk_mem_uncharge(sk, skb->truesize);
> sk->sk_wmem_queued -= skb->truesize + sizeof(struct sctp_chunk);
> @@ -9109,7 +9109,7 @@ static void sctp_wfree(struct sk_buff *skb)
> }
>
> sock_wfree(skb);
> - sctp_wake_up_waiters(sk, asoc);
> + sctp_wake_up_waiters(asoc->base.sk, asoc);
>
> sctp_association_put(asoc);
> }
> --
> 1.8.3.1
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] sctp: fix refcount bug in sctp_wfree
@ 2020-03-17 4:15 ` Marcelo Ricardo Leitner
0 siblings, 0 replies; 8+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-03-17 4:15 UTC (permalink / raw)
To: Qiujun Huang
Cc: vyasevich, nhorman, davem, kuba, linux-sctp, netdev, linux-kernel
On Mon, Mar 16, 2020 at 11:53:24AM +0800, Qiujun Huang wrote:
> Do accounting for skb's real sk.
> In some case skb->sk != asoc->base.sk.
This is a too simple description. Please elaborate how this can
happen in sctp_wfree. Especially considering the construct for
migrating the tx queue on sctp_sock_migrate(), as both sockets are
locked while moving the chunks around and the asoc itself is only
moved in between decrementing and incrementing the refcount:
lock_sock_nested(newsk, SINGLE_DEPTH_NESTING);
sctp_for_each_tx_datachunk(assoc, sctp_clear_owner_w);
sctp_assoc_migrate(assoc, newsk);
sctp_for_each_tx_datachunk(assoc, sctp_set_owner_w);
...
>
> Reported-and-tested-by: syzbot+cea71eec5d6de256d54d@syzkaller.appspotmail.com
I can't see a positive test result, though. If I didn't loose any
email, your last test with a patch similar to this one actually
failed.
I'm talking about syzbot test result at Message-ID: <000000000000e7736205a0e041f5@google.com>
> Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
> ---
> net/sctp/socket.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 1b56fc4..5f5c28b 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -9080,7 +9080,7 @@ static void sctp_wfree(struct sk_buff *skb)
> {
> struct sctp_chunk *chunk = skb_shinfo(skb)->destructor_arg;
> struct sctp_association *asoc = chunk->asoc;
> - struct sock *sk = asoc->base.sk;
> + struct sock *sk = skb->sk;
>
> sk_mem_uncharge(sk, skb->truesize);
> sk->sk_wmem_queued -= skb->truesize + sizeof(struct sctp_chunk);
> @@ -9109,7 +9109,7 @@ static void sctp_wfree(struct sk_buff *skb)
> }
>
> sock_wfree(skb);
> - sctp_wake_up_waiters(sk, asoc);
> + sctp_wake_up_waiters(asoc->base.sk, asoc);
>
> sctp_association_put(asoc);
> }
> --
> 1.8.3.1
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] sctp: fix refcount bug in sctp_wfree
2020-03-17 4:15 ` Marcelo Ricardo Leitner
@ 2020-03-17 4:44 ` Qiujun Huang
-1 siblings, 0 replies; 8+ messages in thread
From: Qiujun Huang @ 2020-03-17 4:44 UTC (permalink / raw)
To: Marcelo Ricardo Leitner
Cc: vyasevich, nhorman, David S. Miller, Jakub Kicinski, linux-sctp,
netdev, LKML
On Tue, Mar 17, 2020 at 12:15 PM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
>
> On Mon, Mar 16, 2020 at 11:53:24AM +0800, Qiujun Huang wrote:
> > Do accounting for skb's real sk.
> > In some case skb->sk != asoc->base.sk.
>
> This is a too simple description. Please elaborate how this can
> happen in sctp_wfree. Especially considering the construct for
> migrating the tx queue on sctp_sock_migrate(), as both sockets are
> locked while moving the chunks around and the asoc itself is only
> moved in between decrementing and incrementing the refcount:
>
> lock_sock_nested(newsk, SINGLE_DEPTH_NESTING);
> sctp_for_each_tx_datachunk(assoc, sctp_clear_owner_w);
> sctp_assoc_migrate(assoc, newsk);
> sctp_for_each_tx_datachunk(assoc, sctp_set_owner_w);
> ...
Yeah, the description is too simple. I'll send v2.
>
> >
> > Reported-and-tested-by: syzbot+cea71eec5d6de256d54d@syzkaller.appspotmail.com
>
> I can't see a positive test result, though. If I didn't loose any
> email, your last test with a patch similar to this one actually
> failed.
> I'm talking about syzbot test result at Message-ID: <000000000000e7736205a0e041f5@google.com>
I told with syzbot privately avoiding noise :p
Thanks!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] sctp: fix refcount bug in sctp_wfree
@ 2020-03-17 4:44 ` Qiujun Huang
0 siblings, 0 replies; 8+ messages in thread
From: Qiujun Huang @ 2020-03-17 4:44 UTC (permalink / raw)
To: Marcelo Ricardo Leitner
Cc: vyasevich, nhorman, David S. Miller, Jakub Kicinski, linux-sctp,
netdev, LKML
On Tue, Mar 17, 2020 at 12:15 PM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
>
> On Mon, Mar 16, 2020 at 11:53:24AM +0800, Qiujun Huang wrote:
> > Do accounting for skb's real sk.
> > In some case skb->sk != asoc->base.sk.
>
> This is a too simple description. Please elaborate how this can
> happen in sctp_wfree. Especially considering the construct for
> migrating the tx queue on sctp_sock_migrate(), as both sockets are
> locked while moving the chunks around and the asoc itself is only
> moved in between decrementing and incrementing the refcount:
>
> lock_sock_nested(newsk, SINGLE_DEPTH_NESTING);
> sctp_for_each_tx_datachunk(assoc, sctp_clear_owner_w);
> sctp_assoc_migrate(assoc, newsk);
> sctp_for_each_tx_datachunk(assoc, sctp_set_owner_w);
> ...
Yeah, the description is too simple. I'll send v2.
>
> >
> > Reported-and-tested-by: syzbot+cea71eec5d6de256d54d@syzkaller.appspotmail.com
>
> I can't see a positive test result, though. If I didn't loose any
> email, your last test with a patch similar to this one actually
> failed.
> I'm talking about syzbot test result at Message-ID: <000000000000e7736205a0e041f5@google.com>
I told with syzbot privately avoiding noise :p
Thanks!
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-03-17 4:44 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-16 3:53 [PATCH] sctp: fix refcount bug in sctp_wfree Qiujun Huang
2020-03-16 3:53 ` Qiujun Huang
2020-03-17 1:25 ` David Miller
2020-03-17 1:25 ` David Miller
2020-03-17 4:15 ` Marcelo Ricardo Leitner
2020-03-17 4:15 ` Marcelo Ricardo Leitner
2020-03-17 4:44 ` Qiujun Huang
2020-03-17 4:44 ` Qiujun Huang
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.