net: qrtr: Prevent stale ports from sending

In order to prevent messages from stale sockets being sent, check if
ENETRESET has been set on the socket and drop the packet.

Change-Id: Ie9abc6c51139e82d3c9ebd4d546d1acd7269875e
Signed-off-by: Chris Lew <quic_clew@quicinc.com>
This commit is contained in:
Chris Lew 2022-10-03 09:57:50 -07:00
parent 9edfe6657f
commit 2ec1e4ae67

View File

@ -919,6 +919,7 @@ static int qrtr_local_enqueue(struct qrtr_node *node, struct sk_buff *skb,
{
struct qrtr_sock *ipc;
struct qrtr_cb *cb;
struct sock *sk = skb->sk;
ipc = qrtr_port_lookup(to->sq_port);
if (!ipc || &ipc->sk == skb->sk) { /* do not send to self */
@ -928,6 +929,15 @@ static int qrtr_local_enqueue(struct qrtr_node *node, struct sk_buff *skb,
return -ENODEV;
}
/* Keep resetting NETRESET until socket is closed */
if (sk && sk->sk_err == ENETRESET) {
sk->sk_err = ENETRESET;
sk_error_report(sk);
qrtr_port_put(ipc);
kfree_skb(skb);
return 0;
}
cb = (struct qrtr_cb *)skb->cb;
cb->src_node = from->sq_node;
cb->src_port = from->sq_port;