Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1199377rdb; Wed, 20 Sep 2023 02:28:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFnZbXYLQ2E12Di+8YcbplyiYOQLO7i1GskUVgly7UWi7GBZmfT9+mNQhf9eH8TzzM3BxEe X-Received: by 2002:a05:6358:7212:b0:13a:a85b:a4dc with SMTP id h18-20020a056358721200b0013aa85ba4dcmr2897002rwa.29.1695202087575; Wed, 20 Sep 2023 02:28:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695202087; cv=none; d=google.com; s=arc-20160816; b=cluBSYGDGuFoPLt8D82hGErwo2vsBDkL7nkA3SDEsqQzZgITV6KaRycny8O37JahiL 4tB37cLYtSpV1i5zjqkEiVMO6kXKADo1KqyWQKWSM5uRLz+Jl2Fdqmz46ZCckNQY4myM LKX0F42+M8fQ2q/qWseiACVO3l9dOnp2UlU9nW2lX4on7m8+Wd3Wo8Jr7wucgyMoJE41 exXU1N/Wjd4MpivyN1W7gcHeOXhkCvL7SWfubtooQqco81Ojhu7HPwoBJmKQYtCnbIuC y19eZ0sEojq8R5DEqMkNlwZVDFP6i8WU1iSTsn/FZD+yUPQQkjcdKxyuQytq9kPhubJs HIuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=3/6AWyd9D4BQks9/JB6+hpqykfLei1uUUZywWvNoP54=; fh=3/Cr/cjNEjzG01nDDMkDvxS1Et50HUdXOTZsvdxrAtM=; b=b2WFR+S+Ew1hVx2Ws2AUmEebpbWNtqLOtAkzhQ2JAX4qAX9HYhUiZ+7MT5MmU+qQfM 6bl5AG4fBEriSQJjFJaAaRcc1YdLqOWO+BCNx6K8d0Mi0+C2ZTGLD/ZOEUeVkzxaTBGg wPGMfttsalPn25ZXy2NYKqDQHWBii31j311pawRxSif0iO3vAPj2w6XgoPYGwQ7A0Rnf vUicYkqVggRWWas82emQRCpCRD5BvMg8IJW08fE1eAaXqoHI45Jx7EBhyuJbWPXG6Lwe rvZj3+2Qpv/ClqCmWSOAkbAE9GMViEvEWLrvv5tWCuE/xU/ho6DiE999tDL8zLsa3zNH FWoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=oVPNR5CH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id f20-20020a631014000000b0054fdb18c877si11394586pgl.607.2023.09.20.02.28.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 02:28:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=oVPNR5CH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id C64D38219C20; Tue, 19 Sep 2023 22:34:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232717AbjITFeD (ORCPT + 99 others); Wed, 20 Sep 2023 01:34:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230021AbjITFd7 (ORCPT ); Wed, 20 Sep 2023 01:33:59 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8137B90; Tue, 19 Sep 2023 22:33:53 -0700 (PDT) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38K5NPjN025085; Wed, 20 Sep 2023 05:33:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=3/6AWyd9D4BQks9/JB6+hpqykfLei1uUUZywWvNoP54=; b=oVPNR5CHUZFEqyCA+Xm+Y7vKK6jTF9sF5yw6T8S7PtqqgqKTf8sBCN64ObgzH4Zn0Vbd Qk590fbbgEG3eUtRKSiszCb1BKdGH5evwkYQ60jbqoXkFDAbHbUT6dzibSbWbzAOa7Q0 AAa1JODNG4wgH0bOd19woyCPIQdIgFChF3iG5neTqYAKR8l2dz/JULZHNZLxaA+FSTND g3cLGvD1B97U8wdr/dLwQXB8IY/XJHWzL12kDYRaG/4jpq34VfVLubA5TE8Kwc9MJz/b AHSXcfAC6xK4TS1IDA4ASdbNaNAI7kfSfMoc3vQx4GvaHXAy4qrmTfWouLNTMNOcTknE TA== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t746g2k1q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Sep 2023 05:33:46 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38K5XjPR030182 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Sep 2023 05:33:45 GMT Received: from win-platform-upstream01.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Tue, 19 Sep 2023 22:33:41 -0700 From: Sricharan Ramabadhran To: , , , , , , , , , , , Subject: [PATCH V2 net-next 1/2] net: qrtr: Prevent stale ports from sending Date: Wed, 20 Sep 2023 11:03:16 +0530 Message-ID: <20230920053317.2165867-2-quic_srichara@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230920053317.2165867-1-quic_srichara@quicinc.com> References: <20230920053317.2165867-1-quic_srichara@quicinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: tfuVV2sKRcB5dtVPV02vko5dpcSzoi0V X-Proofpoint-GUID: tfuVV2sKRcB5dtVPV02vko5dpcSzoi0V X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-20_02,2023-09-19_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 spamscore=0 mlxlogscore=999 impostorscore=0 adultscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309200044 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 19 Sep 2023 22:34:21 -0700 (PDT) From: Chris Lew If some client tries to initialize a QRTR socket during QRTR init, the socket will become stale after the ns(namespace server) binds to the QRTR control port. The client should close and reopen the QRTR socket once ENETRESET is posted to the stale socket. There is a possibility that a client tries to send to the NS before processing the ENETRESET. In the case of a NEW_SERVER control message, the control message will reach the NS and be forwarded to the firmware. The client will then process the ENETRESET closing and re-opening the socket which triggers a DEL_SERVER and then a second NEW_SERVER. This scenario will give an unnecessary disconnect to the clients on the firmware who were able to initialize on the first NEW_SERVER. This was seen when qrtr-ns was a separate application, but there is still a potential gap between AF_QIPCRTR socket register and when qrtr_ns_init binds to the socket where this issue can still occur. Signed-off-by: Chris Lew Signed-off-by: Vignesh Viswanathan Signed-off-by: Sricharan Ramabadhran --- [v2] Added more appropriate commit text, Removed a redundant check and fixed local variables in reverse-christmas tree order. Added 'Chris Lew' Signed-off tag. net/qrtr/af_qrtr.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/qrtr/af_qrtr.c b/net/qrtr/af_qrtr.c index 41ece61eb57a..e5cf4245c3dc 100644 --- a/net/qrtr/af_qrtr.c +++ b/net/qrtr/af_qrtr.c @@ -849,6 +849,7 @@ static int qrtr_local_enqueue(struct qrtr_node *node, struct sk_buff *skb, int type, struct sockaddr_qrtr *from, struct sockaddr_qrtr *to) { + struct sock *sk = skb->sk; struct qrtr_sock *ipc; struct qrtr_cb *cb; @@ -860,6 +861,14 @@ 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_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; -- 2.34.1