From: Pavel Skripkin <hidden> Date: 2021-07-22 16:16:35
Syzbot reported memory leak in qrtr. The problem was in unputted
struct sock. qrtr_local_enqueue() function calls qrtr_port_lookup()
which takes sock reference if port was found. Then there is the following
check:
if (!ipc || &ipc->sk == skb->sk) {
...
return -ENODEV;
}
Since we should drop the reference before returning from this function and
ipc can be non-NULL inside this if, we should add qrtr_port_put() inside
this if.
Fixes: bdabad3e363d ("net: Add Qualcomm IPC router")
Reported-and-tested-by: syzbot+35a511c72ea7356cdcf3@syzkaller.appspotmail.com
Signed-off-by: Pavel Skripkin <redacted>
---
net/qrtr/qrtr.c | 2 ++
1 file changed, 2 insertions(+)
@@ -839,6 +839,8 @@ static int qrtr_local_enqueue(struct qrtr_node *node, struct sk_buff *skb,ipc=qrtr_port_lookup(to->sq_port);if(!ipc||&ipc->sk==skb->sk){/* do not send to self */+if(ipc)+qrtr_port_put(ipc);kfree_skb(skb);return-ENODEV;}
On Thu, Jul 22, 2021 at 07:16:25PM +0300, Pavel Skripkin wrote:
Syzbot reported memory leak in qrtr. The problem was in unputted
struct sock. qrtr_local_enqueue() function calls qrtr_port_lookup()
which takes sock reference if port was found. Then there is the following
check:
if (!ipc || &ipc->sk == skb->sk) {
...
return -ENODEV;
}
Since we should drop the reference before returning from this function and
ipc can be non-NULL inside this if, we should add qrtr_port_put() inside
this if.
Fixes: bdabad3e363d ("net: Add Qualcomm IPC router")
Reported-and-tested-by: syzbot+35a511c72ea7356cdcf3@syzkaller.appspotmail.com
Signed-off-by: Pavel Skripkin <redacted>
@@ -839,6 +839,8 @@ static int qrtr_local_enqueue(struct qrtr_node *node, struct sk_buff *skb,ipc=qrtr_port_lookup(to->sq_port);if(!ipc||&ipc->sk==skb->sk){/* do not send to self */+if(ipc)+qrtr_port_put(ipc);kfree_skb(skb);return-ENODEV;}
On Thu, Jul 22, 2021 at 07:16:25PM +0300, Pavel Skripkin wrote:
quoted
Syzbot reported memory leak in qrtr. The problem was in unputted
struct sock. qrtr_local_enqueue() function calls qrtr_port_lookup()
which takes sock reference if port was found. Then there is the
following check:
if (!ipc || &ipc->sk == skb->sk) {
...
return -ENODEV;
}
Since we should drop the reference before returning from this
function and ipc can be non-NULL inside this if, we should add
qrtr_port_put() inside this if.
Fixes: bdabad3e363d ("net: Add Qualcomm IPC router")
Reported-and-tested-by:
syzbot+35a511c72ea7356cdcf3@syzkaller.appspotmail.com
Signed-off-by: Pavel Skripkin <redacted>
From: Pavel Skripkin <hidden> Date: 2021-07-23 15:32:05
Syzbot reported memory leak in qrtr. The problem was in unputted
struct sock. qrtr_local_enqueue() function calls qrtr_port_lookup()
which takes sock reference if port was found. Then there is the following
check:
if (!ipc || &ipc->sk == skb->sk) {
...
return -ENODEV;
}
Since we should drop the reference before returning from this function and
ipc can be non-NULL inside this if, we should add qrtr_port_put() inside
this if.
The similar corner case is in qrtr_endpoint_post() as Manivannan
reported. In case of sock_queue_rcv_skb() failure we need to put
port reference to avoid leaking struct sock pointer.
Fixes: e04df98adf7d ("net: qrtr: Remove receive worker")
Fixes: bdabad3e363d ("net: Add Qualcomm IPC router")
Reported-and-tested-by: syzbot+35a511c72ea7356cdcf3@syzkaller.appspotmail.com
Signed-off-by: Pavel Skripkin <redacted>
---
Changes in v2:
Added missing qrtr_port_put() in qrtr_endpoint_post() as Manivannan
reported.
---
net/qrtr/qrtr.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
@@ -850,6 +852,8 @@ static int qrtr_local_enqueue(struct qrtr_node *node, struct sk_buff *skb,ipc=qrtr_port_lookup(to->sq_port);if(!ipc||&ipc->sk==skb->sk){/* do not send to self */+if(ipc)+qrtr_port_put(ipc);kfree_skb(skb);return-ENODEV;}
On Fri, Jul 23, 2021 at 06:31:32PM +0300, Pavel Skripkin wrote:
Syzbot reported memory leak in qrtr. The problem was in unputted
struct sock. qrtr_local_enqueue() function calls qrtr_port_lookup()
which takes sock reference if port was found. Then there is the following
check:
if (!ipc || &ipc->sk == skb->sk) {
...
return -ENODEV;
}
Since we should drop the reference before returning from this function and
ipc can be non-NULL inside this if, we should add qrtr_port_put() inside
this if.
The similar corner case is in qrtr_endpoint_post() as Manivannan
reported. In case of sock_queue_rcv_skb() failure we need to put
port reference to avoid leaking struct sock pointer.
Fixes: e04df98adf7d ("net: qrtr: Remove receive worker")
Fixes: bdabad3e363d ("net: Add Qualcomm IPC router")
Reported-and-tested-by: syzbot+35a511c72ea7356cdcf3@syzkaller.appspotmail.com
Signed-off-by: Pavel Skripkin <redacted>
@@ -850,6 +852,8 @@ static int qrtr_local_enqueue(struct qrtr_node *node, struct sk_buff *skb,ipc=qrtr_port_lookup(to->sq_port);if(!ipc||&ipc->sk==skb->sk){/* do not send to self */+if(ipc)+qrtr_port_put(ipc);kfree_skb(skb);return-ENODEV;}
Hello:
This patch was applied to netdev/net.git (refs/heads/master):
On Fri, 23 Jul 2021 18:31:32 +0300 you wrote:
Syzbot reported memory leak in qrtr. The problem was in unputted
struct sock. qrtr_local_enqueue() function calls qrtr_port_lookup()
which takes sock reference if port was found. Then there is the following
check:
if (!ipc || &ipc->sk == skb->sk) {
...
return -ENODEV;
}
[...]