Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1291742pxb; Thu, 28 Oct 2021 00:35:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxkf4BYzJo+MC6xBTAUtxmHIT3T+eJlVO+hKMRPsJhEmOQS07ZfSQGvfPtapOQ3+JxqGsk X-Received: by 2002:aa7:d31a:: with SMTP id p26mr3949652edq.264.1635406540283; Thu, 28 Oct 2021 00:35:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635406540; cv=none; d=google.com; s=arc-20160816; b=r3LcPIyloMJnSuxAr7SyDhIFM8BfHqV6LVD/JzQaheXl8oNQTMkRok2AsJHqPij4Lt QEemoLdWDKFAVF42g5jEBfU5kazKx6oiVF6kylE+NpvxAjiWSNA6MhoUltWlE8jOAdbm Mpx7ZMO4olgzyU77nO+vtDe14V92tyYvEs3sYdjHtTttwRwVH6n6+Y0NBuMGXDee/iu6 6Qn/OEsJaHBzlYU6kyhIaHt4UqZFTSM8wKs5WOJgJ3B38N0psksYP/6fvN9jS0cDmLRp Zmu9R8rgXC/50icEJeIdYva80r+HfT6vuUph6ZmIoqLiM+/zkfGpKxHi6l+4xgaMtKe1 aK/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=++iOKsPppHcpnSrs5qOmLdcVqn0YD5jl0zEnWKSqeNk=; b=mgRsH/mgYRLjcurEkwGqz2d32gX9YrY3OWf1k0qOQM2q6HiprwtNkOhKiwzlOkQVjZ J//tTCG5/60HOLVQ+wbflsIOk9br93ba5oFKcq6KrTe0rCSVdqGLBM3tvkIDQIlJjnyu nQVG3SiWaQOp3gXOYOiaZgTf6H7NWm8FjuPTEMqbS4oNcdemhwEoPZPNV+ksHetdty0m E3qZwWW2YzVs1ofuWXe7cDKPxbqm6Ul8yy3Sqf1zYfsP46g/HrMICPYVvEMm74wkx687 fcWHeAIQH3ZnxXh789y9M83RgPxk4DGAGxyGQ0A884EoN8Ry6yJ0utu/fxf7bxZit5c2 hjlA== 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 h24si3272545ejt.408.2021.10.28.00.35.16; Thu, 28 Oct 2021 00:35:40 -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 S229850AbhJ1Hfz (ORCPT + 99 others); Thu, 28 Oct 2021 03:35:55 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:26130 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbhJ1Hfz (ORCPT ); Thu, 28 Oct 2021 03:35:55 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Hfy0t2pkgz1DHpx; Thu, 28 Oct 2021 15:31:26 +0800 (CST) Received: from dggpeml500006.china.huawei.com (7.185.36.76) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Thu, 28 Oct 2021 15:33:22 +0800 Received: from [10.174.178.240] (10.174.178.240) 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, 28 Oct 2021 15:33:21 +0800 Subject: Re: [PATCH net 2/3] can: j1939: j1939_can_recv(): ignore messages with invalid source address To: Oleksij Rempel CC: Robin van der Gracht , , Oleksij Rempel , , "Marc Kleine-Budde" , , Oliver Hartkopp , Jakub Kicinski , , "David S. Miller" References: <1634825057-47915-1-git-send-email-zhangchangzhong@huawei.com> <1634825057-47915-3-git-send-email-zhangchangzhong@huawei.com> <20211022102306.GB20681@pengutronix.de> <9c636d7f-70df-18c9-66ed-46eb21f4ffbb@huawei.com> <20211028065144.GE20681@pengutronix.de> From: Zhang Changzhong Message-ID: Date: Thu, 28 Oct 2021 15:33:21 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <20211028065144.GE20681@pengutronix.de> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.178.240] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) 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 On 2021/10/28 14:51, Oleksij Rempel wrote: > Hi, > > On Mon, Oct 25, 2021 at 03:30:57PM +0800, Zhang Changzhong wrote: >> On 2021/10/22 18:23, Oleksij Rempel wrote: >>> On Thu, Oct 21, 2021 at 10:04:16PM +0800, Zhang Changzhong wrote: >>>> 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 >>> >>> NACK. This will break Address Claiming, where first message is SA == 0xff >> >> I know that 0xfe can be used as a source address, but which message has a source >> address of 0xff? >> >> According to SAE-J1939-81 2017 4.2.2.8: >> >> The network address 255, also known as the Global address, is permitted in the >> Destination Address field of the SAE J1939 message identifier but never in the >> Source Address field. > > You are right. Thx! > > Are you using any testing frameworks? > Can you please take a look here: > https://github.com/linux-can/can-tests/tree/master/j1939 > > We are using this scripts for regression testing of some know bugs. Great! I'll run these scripts before posting patches. > >> >>> >>>> --- >>>> 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; > > Please add some warning once message here. We wont to know if something bad > is happening on the bus. Will do. Thanks for your suggestions. Regards, Changzhong > >>>> + >>>> if (j1939_pgn_is_pdu1(skcb->addr.pgn)) { >>>> /* Type 1: with destination address */ >>>> skcb->addr.da = skcb->addr.pgn; >>>> -- >>>> 2.9.5 >>>> >>>> >>>> >>> >> >> > > Regards, > Oleksij >