Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp650547pxb; Thu, 21 Oct 2021 06:58:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcvzANL5ePs/Tcq4E6jhCgYLMUjZmCO1Y9IjPJAgNrEbb4Y26pcVsRDtbeskKsisERyY36 X-Received: by 2002:aa7:de8f:: with SMTP id j15mr7872654edv.347.1634824722062; Thu, 21 Oct 2021 06:58:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634824722; cv=none; d=google.com; s=arc-20160816; b=xhaogGiprmiuPm6oNyUaUIenmKCYtilvQQmcnVuDsLr4YAc4ffPmdHiSW+byfDqIHB rAYoNqw+lP3wVLsb9tKaHodZHfVmtG5yhQhq92UyhQCYCTAa989hx/bnHBoGTkcrHKlp g3NjGB4DKHXbT7kG+o8Bp2365LCleNdpG2euEaJoPos2808NmxMr3FwdhO4RmJZR8T49 bvQMVV08owP2uwhptO2AxLsLZ1T11CBxyPWdLNF4eeRKmCG/7vQU1sUHwii8p9PPa2Q1 AV0urY8ygLuUd5JTT/q9w+FsGeYHKj/p22JwIsx7l28i3hXal/p/a60Wc9SRD/tRpfNZ cyvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=NOOzkHu+cXortVZZr+naVV4w3ObiVCbUviYShwIqgMU=; b=KKPTzowHZ3eFvSG7Q+f7qcpOhLybSKfAhjj6sDRBBXMVcUE5+2dCA5CvV5+yiXBdZz B+ep/WnrNaSKD+VrjFG8s7My4MWxt/XFPBczH3eszTJjz6B2jN2rW1jiq/ekcdCh2MlN 8ztPHDRH8xwK5PkmY/vKLwk9aD6kHbBY7g4mwUKcqkIQcH4Qaxx2USJPqBs9LsR/5f/+ inULnWHhEudvnGWD2JCurw/dzA4zFk6i+W+GGnO9KW06213WuGcBAm3jjjGAVZG7rgf2 nZ5LOXMZ2YcDBr7zf+dMHitJfoTHmbrpZVe+Q7X+e/Ofn96V0ook9KY2/k/hp/LIeTa0 dpJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c10si8206551ejf.406.2021.10.21.06.58.17; Thu, 21 Oct 2021 06:58:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231522AbhJUN4c (ORCPT + 99 others); Thu, 21 Oct 2021 09:56:32 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:29923 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231331AbhJUN4c (ORCPT ); Thu, 21 Oct 2021 09:56:32 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4HZpkV4CwwzbnFr; Thu, 21 Oct 2021 21:49:38 +0800 (CST) Received: from dggpeml500006.china.huawei.com (7.185.36.76) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Thu, 21 Oct 2021 21:54:12 +0800 Received: from compute.localdomain (10.175.112.70) by dggpeml500006.china.huawei.com (7.185.36.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Thu, 21 Oct 2021 21:54:12 +0800 From: Zhang Changzhong To: Robin van der Gracht , Oleksij Rempel , , Oliver Hartkopp , Marc Kleine-Budde , "David S. Miller" , Jakub Kicinski CC: Zhang Changzhong , , , Subject: [PATCH net 2/3] can: j1939: j1939_can_recv(): ignore messages with invalid source address Date: Thu, 21 Oct 2021 22:04:16 +0800 Message-ID: <1634825057-47915-3-git-send-email-zhangchangzhong@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1634825057-47915-1-git-send-email-zhangchangzhong@huawei.com> References: <1634825057-47915-1-git-send-email-zhangchangzhong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.112.70] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500006.china.huawei.com (7.185.36.76) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org According to SAE-J1939-82 2015 (A.3.6 Row 2), a receiver should never send TP.CM_CTS to the global address, so we can add a check in j1939_can_recv() to drop messages with invalid source address. Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol") Signed-off-by: Zhang Changzhong --- net/can/j1939/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/can/j1939/main.c b/net/can/j1939/main.c index 08c8606..4f1e4bb 100644 --- a/net/can/j1939/main.c +++ b/net/can/j1939/main.c @@ -75,6 +75,10 @@ static void j1939_can_recv(struct sk_buff *iskb, void *data) skcb->addr.pgn = (cf->can_id >> 8) & J1939_PGN_MAX; /* set default message type */ skcb->addr.type = J1939_TP; + if (!j1939_address_is_valid(skcb->addr.sa)) + /* ignore messages whose sa is broadcast address */ + goto done; + if (j1939_pgn_is_pdu1(skcb->addr.pgn)) { /* Type 1: with destination address */ skcb->addr.da = skcb->addr.pgn; -- 2.9.5