Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2026097rwb; Wed, 30 Nov 2022 01:00:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf4GGwWIMKtxPksZhSyXl+bk9rE2fdtgu5ikrB7bnK8JyfFZLIboARGMHh6eQhC/a3RmOq2I X-Received: by 2002:a63:e510:0:b0:470:60a5:146d with SMTP id r16-20020a63e510000000b0047060a5146dmr41686310pgh.156.1669798848840; Wed, 30 Nov 2022 01:00:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669798848; cv=none; d=google.com; s=arc-20160816; b=qT3iTXvkAyxkcs0zsRXSCUfe/V6LvE2hPOXYukDUoQIOnH78aWanhm5Y3vkdX3WLgR YDuHx3dPx/dok2EFpZswKfk3eKJWB6M5ELvzYEBWpb7O3FnP5fsFQqcaQBZDNPiprj8I wOJ52tjn2HZu4waOG+9szsu6RTk9y1n0Pu3bZToZiC6fZpSrgXvGKAfEBMAgoFHXOS4u 0x3bPw+7MIqYHjrfxgxdWPj+JvNChUfBKD7Kqp9wMHD2ZDL7k3xPmEqL18/nlO+TCxbT nURuQAEbLoWbOvAbvV/Z+h4i+dE1zvO68AfawlTgWS228GfaRJsL9jugZNpHLjHWEz8N Ttzg== 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:dkim-filter; bh=r3Rg2YhNmfjZGaScA5OcxaOz3tJEP+T11CxUAPtKqrI=; b=FXAL1icmFxWYBf1WHuhhNNvUGadfmIx+9xU3OmgASaV9uqefkIpV7pmRXNH3v79vJ2 cse9GMzqGizV9UsF7FAFr5jgo098CD8p5JhnRbQ/GrzV6FKo8iYvWJN9VUGTx99J8uZ4 3px29xolFVPq4IFQq+ntVtMCm41bjz229GWe1DCyn0+xUmCx5TauIUoQntZdzv2OPITu fi2GfCw9SkyiHu4hoqzoZu7sgOdLN47zLN3keAOJme9s5Hsi14bJNptu0mA1zbx1rASR 7da/t02886Kb/y3H9tMuWoq2pbcYf4HuxcXwu97+tHzP/pxU5z5JEvTJIG2OY49zGNua AdFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=hpkfxYnE; 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=NONE sp=NONE dis=NONE) header.from=ispras.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h15-20020a170902f54f00b00176d5b20ebesi777702plf.355.2022.11.30.01.00.37; Wed, 30 Nov 2022 01:00:48 -0800 (PST) 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=@ispras.ru header.s=default header.b=hpkfxYnE; 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=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233982AbiK3Ipr (ORCPT + 84 others); Wed, 30 Nov 2022 03:45:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236924AbiK3IpV (ORCPT ); Wed, 30 Nov 2022 03:45:21 -0500 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F95630F58; Wed, 30 Nov 2022 00:45:15 -0800 (PST) Received: from ykarpov.intra.ispras.ru (unknown [10.10.2.71]) by mail.ispras.ru (Postfix) with ESMTPSA id 7867A40D403D; Wed, 30 Nov 2022 08:45:11 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 7867A40D403D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1669797911; bh=r3Rg2YhNmfjZGaScA5OcxaOz3tJEP+T11CxUAPtKqrI=; h=From:To:Cc:Subject:Date:From; b=hpkfxYnEjSReIcIiVajn4hcK9ueNnjTwjcBMwyyLcH2d2JVxpcir1hX6UbqGcZ+FU xnIAYlSTYc2dj6/fddzRKpFupf/qZpbwweZHBbWkJasQdHk7pRoKwOuHZWRmAeA+Xa rvuXQOSRN537ymkTDz1fh8AFggEIQBkUGtSe4aRU= From: Yuri Karpov To: Andrew Lunn Cc: Yuri Karpov , Florian Fainelli , Vladimir Oltean , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] net: dsa: fix NULL pointer dereference in seq_match() Date: Wed, 30 Nov 2022 11:44:31 +0300 Message-Id: <20221130084431.3299054-1-YKarpov@ispras.ru> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,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 ptp_parse_header() result is not checked in seq_match() that can lead to NULL pointer dereferense. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: c6fe0ad2c349 ("net: dsa: mv88e6xxx: add rx/tx timestamping support") Signed-off-by: Yuri Karpov --- drivers/net/dsa/mv88e6xxx/hwtstamp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/mv88e6xxx/hwtstamp.c b/drivers/net/dsa/mv88e6xxx/hwtstamp.c index 331b4ca089ff..97f30795a2bb 100644 --- a/drivers/net/dsa/mv88e6xxx/hwtstamp.c +++ b/drivers/net/dsa/mv88e6xxx/hwtstamp.c @@ -246,7 +246,7 @@ static int seq_match(struct sk_buff *skb, u16 ts_seqid) hdr = ptp_parse_header(skb, type); - return ts_seqid == ntohs(hdr->sequence_id); + return hdr ? ts_seqid == ntohs(hdr->sequence_id) : 0; } static void mv88e6xxx_get_rxts(struct mv88e6xxx_chip *chip, -- 2.34.1