Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1559200pxb; Fri, 22 Oct 2021 03:25:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzz6XywgUdUnczcuww4oWXwVBOfkCVglCA0wqmarQiwLPM9sqvNLPps+q4/lnySetHcapN X-Received: by 2002:a17:907:e9f:: with SMTP id ho31mr14753628ejc.156.1634898323889; Fri, 22 Oct 2021 03:25:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634898323; cv=none; d=google.com; s=arc-20160816; b=x+hH46C4UNGFpywsMZ7omWa/d9a3AoES/30HqNaX1jaVaaLhAvfmIMm1GJEWqxWEIH yuVrD1EWsuTjmRahXnw956oHJHwkHea9Zn/Te48X6rqQCdBgfkMnEuInRAk+FQvpskjf c/h1LzcZHR/8GpfmiVumcxYkochnjlO6O98963bIzwnUmpj2a6r7LXGNAF53SKOMuRny QAl0Wm+i2+7CsR2ONVT52xSv1IMdfTiSynTSbRu6ZMCDPV29ryv5xENBCQkfRQ7CzljD UHdmhJUPCOjgaEgVcF4Dw18K3+HcGu0VomRPb6OxEGui1WKwBbpQ9BXlLLSC/eT/a45D xuWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=Z/C0dSkSk01FnL4Qo1Gb4pMwOB1wCXd7I8Uv9hDmHcE=; b=uOfOMXpBvOS5ypo+evO4nVr5Kn4OaMiJ9ubJL7/5WOcYlFkZrwmGuSH1O75J4yeZAg I87DCyq70QDxPrApSEfY+PJteQkhRH9TFApOScGqQr3V1bKXh3d6syZvpwhSd9kHyK1c 5bdTxOFaXHezuHZ5StIe1bOu9tH86/fm5MzmIu110dMTXaG8BPZvIxE1+HJGdjRRB11n XDjs5OeFlK9sCsXgRKvFNLKTkHYgXL8TgYP7JHY/H48yfHjvWsyerjndOhd4rBtpSWkq lBfXB1O8B5f/N47YmiGOa9jVE4uB0CUQSxvvyKlFY+WKZBM+G7tXyxEgWRQUbb/Lov5p C40w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q5si11148502ejb.580.2021.10.22.03.25.00; Fri, 22 Oct 2021 03:25:23 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232577AbhJVKZg (ORCPT + 99 others); Fri, 22 Oct 2021 06:25:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232483AbhJVKZe (ORCPT ); Fri, 22 Oct 2021 06:25:34 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98598C061764 for ; Fri, 22 Oct 2021 03:23:17 -0700 (PDT) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mdrhb-0004xv-Ph; Fri, 22 Oct 2021 12:23:07 +0200 Received: from ore by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1mdrha-0000Bq-D4; Fri, 22 Oct 2021 12:23:06 +0200 Date: Fri, 22 Oct 2021 12:23:06 +0200 From: Oleksij Rempel To: Zhang Changzhong Cc: Robin van der Gracht , Oleksij Rempel , kernel@pengutronix.de, Oliver Hartkopp , Marc Kleine-Budde , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-can@vger.kernel.org Subject: Re: [PATCH net 2/3] can: j1939: j1939_can_recv(): ignore messages with invalid source address Message-ID: <20211022102306.GB20681@pengutronix.de> References: <1634825057-47915-1-git-send-email-zhangchangzhong@huawei.com> <1634825057-47915-3-git-send-email-zhangchangzhong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1634825057-47915-3-git-send-email-zhangchangzhong@huawei.com> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 12:22:09 up 246 days, 13:46, 123 users, load average: 0.07, 0.13, 0.15 User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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 > > > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |