Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp724377pxb; Mon, 25 Oct 2021 17:30:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBdBq67PRMzUWQC9S1e0ueos+ExmWwC1E4RZDcAZnQ9Ysu0zdiWDxxQBYw0v2GGCaBNSIU X-Received: by 2002:a63:d2:: with SMTP id 201mr16327448pga.400.1635208224591; Mon, 25 Oct 2021 17:30:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635208224; cv=none; d=google.com; s=arc-20160816; b=dg02sL0mdpGG51UwvbA9KQXTp5Gu9YMo/LJAMzWE7LsLfGBlyUJzUZOI6p+dhjvtFM 3g5PQirm031m1fkIYp92KxkGU2vlyUH71J7Dtk8pWJETFQwqjjt16hbE925imtQ4WzwX +UzGFGgpmtp/uytK5nnBibAFZ/o3dQZ+Vcz3sru7yNZOBKUe4/IXho/JX5J+JtwvTWmn lD8sAlHrmmcElZSIKxi68H9Wbxf8y3z+2uU9v+ehrv3JeG5H/DCtuf2wePOX2jOWCMvM I3zyIUGis5GJSTnb4sZr9pe/H6QzBqT5Qn9LKF5TRyG1wBnnNsQvY5gHCa6SUbuRwA5i N1dw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Je6B1PBbkq7mMaxyHaMJq9DnufvdEFIwYfp5OH8lzwg=; b=BvDo/dbesUaf1oMFQRqyW7u947wehNq+kXoHj5ewBaUEajIcGBNlSKZQ6IOjJ9FQT2 z9iw+krJZ2DvFnIMedX7XZXQetyOa5uJYPGNUhgM/Ux5fdw4dLSlsaxJ9JlMbiURx7oP oSaoQQEwHscRNjcdHWgUw0ZVaLXt8DpQ+5qIzMskUaeUW9T+2mNpO4r5gjg2UpAUqfrU Yb2glyp2EbrZjjaCiW4/SoM2TRt4ZB31NPbrYFCNf6Laa4EoAaW+CKmcO52C77kNWkzW j24esaMTcVfodWBVr403Z1SaJzn6aegFhol1xsY+kkM1BJ55ihQv3ux8ieuK2zUTXJoD 8fng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="y5C/sW5J"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h17si20478477plf.222.2021.10.25.17.30.12; Mon, 25 Oct 2021 17:30:24 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="y5C/sW5J"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237886AbhJYTwq (ORCPT + 99 others); Mon, 25 Oct 2021 15:52:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:38048 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237966AbhJYTq6 (ORCPT ); Mon, 25 Oct 2021 15:46:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 83CB461208; Mon, 25 Oct 2021 19:39:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635190798; bh=NrQgn9bc0tPgd+GccU8516edMKipbeF9wiI+ndUsYBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y5C/sW5J8DwtOO0yK4cC8QhBRgQUq915y3ZlQJFUxbLnwpiPphcUlBWg3x/wXeWvX Z/eRDTXNeoFugWdWcp1ZSyBhdCKiQURuz/BzHXOEd4Qbu/u75knXm7MfNzxrNDn/zq 1wlT1/sQBetIaLaLmxLPSO7pQl/NfFimEZCYZW0w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Changzhong , Oleksij Rempel , Marc Kleine-Budde Subject: [PATCH 5.14 073/169] can: j1939: j1939_xtp_rx_dat_one(): cancel session if receive TP.DT with error length Date: Mon, 25 Oct 2021 21:14:14 +0200 Message-Id: <20211025191026.654550692@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211025191017.756020307@linuxfoundation.org> References: <20211025191017.756020307@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhang Changzhong commit 379743985ab6cfe2cbd32067cf4ed497baca6d06 upstream. According to SAE-J1939-21, the data length of TP.DT must be 8 bytes, so cancel session when receive unexpected TP.DT message. Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol") Link: https://lore.kernel.org/all/1632972800-45091-1-git-send-email-zhangchangzhong@huawei.com Cc: stable@vger.kernel.org Signed-off-by: Zhang Changzhong Acked-by: Oleksij Rempel Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- net/can/j1939/transport.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/net/can/j1939/transport.c +++ b/net/can/j1939/transport.c @@ -1770,6 +1770,7 @@ static void j1939_xtp_rx_dpo(struct j193 static void j1939_xtp_rx_dat_one(struct j1939_session *session, struct sk_buff *skb) { + enum j1939_xtp_abort abort = J1939_XTP_ABORT_FAULT; struct j1939_priv *priv = session->priv; struct j1939_sk_buff_cb *skcb; struct sk_buff *se_skb = NULL; @@ -1784,9 +1785,11 @@ static void j1939_xtp_rx_dat_one(struct skcb = j1939_skb_to_cb(skb); dat = skb->data; - if (skb->len <= 1) + if (skb->len != 8) { /* makes no sense */ + abort = J1939_XTP_ABORT_UNEXPECTED_DATA; goto out_session_cancel; + } switch (session->last_cmd) { case 0xff: @@ -1884,7 +1887,7 @@ static void j1939_xtp_rx_dat_one(struct out_session_cancel: kfree_skb(se_skb); j1939_session_timers_cancel(session); - j1939_session_cancel(session, J1939_XTP_ABORT_FAULT); + j1939_session_cancel(session, abort); j1939_session_put(session); }