From patchwork Fri Nov 4 07:50:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Hartkopp X-Patchwork-Id: 15417 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp239915wru; Fri, 4 Nov 2022 01:04:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4wv7qCvPj0xO0lm2hiTp1jGkk/GbzMb7ANXyXFmLVwL4JlyLxVzlRp189scfG4kxSUZTdC X-Received: by 2002:a17:907:6296:b0:787:d066:9fcf with SMTP id nd22-20020a170907629600b00787d0669fcfmr31101492ejc.692.1667549083312; Fri, 04 Nov 2022 01:04:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667549083; cv=none; d=google.com; s=arc-20160816; b=ZGyIrancT2kiJUdtwx2eIophO4/VL6GET6HpKaJ1j4oxvTcL5pbQgxczNWUTPC2p6U trGxEs0yobbJkDREpVLH1VR4Hg/DrO/HXzQPUjseOl0VgVB3CxvQUVAO9vPh4/ANl45X 5XmZP5qLeeA6YON17beaKm+pjbIYuIutcI+3ZYtZT/Rtu2IabRmBTTxRAkaHhb8WXm4n h3HZwnJEjs4xv1TVXRKJrb0XYssemMeLdKW5QJrDc5uvMJ6c/QR8KcooQrQADPW/vGb4 taotLjpz5qC0Q9Ij7g4ynD0dswK0abPa3V1+nG1Y5mX23uFHTbOQ0HSNyenfBktL0rNG 1V/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:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=7n/shGnfP1l0uRtNIQNgUJX4uMoz9OqYhtqOImv6qnk=; b=GJe+OScZiP21e6Lw7vmnVMGdTMcg4QzDjKP9vkfcd58PqmEAujYtIr9dmFVa7/89G6 4bqGpXaoz5YOZmKgSAZ6LSgz0/K+qBnjnKVNHOWYtVx0pz9iO4o9cDrR/95hL8aw6goH rDThHGCEDNhxDOa76dqEdWe7Yl9x5pHmT/0LC6J1DYY0FA5l6TNKhruhEz3OaA89PlhM bCu5j52euV/Ycjm4XdO56akEtQLWK136rrlTReahfbualy8dVrFXp+GA/Ba0+NQ+08Sq sD8LM5DETE+9Vn3CktPul/yRkjboc/dZ97nkaqXVXi0R//rsOd8vEwXAf9JWlZGhUJz1 2LKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hartkopp.net header.s=strato-dkim-0002 header.b=JhUQ6jLt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=hartkopp.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020a056402524800b00458ab54baa5si5144450edd.503.2022.11.04.01.04.20; Fri, 04 Nov 2022 01:04:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@hartkopp.net header.s=strato-dkim-0002 header.b=JhUQ6jLt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=hartkopp.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229985AbiKDHxi (ORCPT + 99 others); Fri, 4 Nov 2022 03:53:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbiKDHxf (ORCPT ); Fri, 4 Nov 2022 03:53:35 -0400 X-Greylist: delayed 184 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 04 Nov 2022 00:53:32 PDT Received: from mo4-p00-ob.smtp.rzone.de (mo4-p00-ob.smtp.rzone.de [81.169.146.219]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B551E15; Fri, 4 Nov 2022 00:53:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1667548219; s=strato-dkim-0002; d=hartkopp.net; h=Message-Id:Date:Subject:Cc:To:From:Cc:Date:From:Subject:Sender; bh=7n/shGnfP1l0uRtNIQNgUJX4uMoz9OqYhtqOImv6qnk=; b=JhUQ6jLty4ryG0uaVYXYC6wuQ1KgBnaVJwLIe2DIyTrJftW4MURaUGlOJoBp/Zb8Or TqAECd/s8jr4xIw51uLWlVxwRzTmLtpT7dhKqGE6odrXr+QtAJw3vazDObRGD1Eexogt owmIF92Bc3PZa/uPC5Ou/Z3LKPf0mNL68MeT4Ju4oV3OfklxEIGgJxrFRUMAKkyQ8raz L6lM+sMCKJa5LKdktwBHNqlK0lHKJ8FIlHExzHNWREkps69mUXNgGKXfBHVx/jvvEeKy NiC9ObJQLG31QDEb9mex79P6bnmFyJGfb4KEnjLdOvsxBuXv5J4z1dKURw4xzPEWuaMu V+hg== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":P2MHfkW8eP4Mre39l357AZT/I7AY/7nT2yrDxb8mjGrp7owjzFK3JbFk1mS/xvEBL7X5sbo3UIh9JiLceSWJaYxMWqfZ" X-RZG-CLASS-ID: mo00 Received: from silver.lan by smtp.strato.de (RZmta 48.2.1 AUTH) with ESMTPSA id Dde783yA47oJPCK (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Fri, 4 Nov 2022 08:50:19 +0100 (CET) From: Oliver Hartkopp To: netdev@vger.kernel.org, linux-can@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Oliver Hartkopp , Oleksij Rempel , syzbot+d168ec0caca4697e03b1@syzkaller.appspotmail.com Subject: [PATCH] can: j1939: fix missing CAN header initialization Date: Fri, 4 Nov 2022 08:50:00 +0100 Message-Id: <20221104075000.105414-1-socketcan@hartkopp.net> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748551947631149223?= X-GMAIL-MSGID: =?utf-8?q?1748551947631149223?= The read access to struct canxl_frame::len inside of a j1939 created skbuff revealed a missing initialization of reserved and later filled elements in struct can_frame. This patch initializes the 8 byte CAN header with zero. Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol") Cc: Oleksij Rempel Link: https://lore.kernel.org/linux-can/20221104052235.GA6474@pengutronix.de/T/#t Reported-by: syzbot+d168ec0caca4697e03b1@syzkaller.appspotmail.com Signed-off-by: Oliver Hartkopp --- net/can/j1939/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/can/j1939/main.c b/net/can/j1939/main.c index 144c86b0e3ff..821d4ff303b3 100644 --- a/net/can/j1939/main.c +++ b/net/can/j1939/main.c @@ -334,10 +334,13 @@ int j1939_send_one(struct j1939_priv *priv, struct sk_buff *skb) dlc = skb->len; /* re-claim the CAN_HDR from the SKB */ cf = skb_push(skb, J1939_CAN_HDR); + /* initialize header structure */ + memset(cf, 0, J1939_CAN_HDR); + /* make it a full can frame again */ skb_put(skb, J1939_CAN_FTR + (8 - dlc)); canid = CAN_EFF_FLAG | (skcb->priority << 26) |