Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2127276rwb; Wed, 30 Nov 2022 02:43:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf4DFlcYTQoIDrnTOwvibjkAVdtlfVZgkGUVS+ossFe+jE9sc0CcBHrH37b+UQ4wgTwCjrR1 X-Received: by 2002:a50:ff04:0:b0:46b:19aa:cfc4 with SMTP id a4-20020a50ff04000000b0046b19aacfc4mr13824763edu.384.1669805011677; Wed, 30 Nov 2022 02:43:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669805011; cv=none; d=google.com; s=arc-20160816; b=N48WmLms146Nah6zPAovq3EReUiAmKQpexoUTmYqVkkq1XdFWGoEZ3In1FU1U7jRGJ NQidZd0C8Jx8gQPSNSTwTQVDIkMsNn/5/Pq3Rk6aIDR4GkyDUYAwYlSdlBQzuF3TcGId JevZqsj++f1oFZnK6e+Zzeic73L9s3M6jZTNyvbgWRX4OlT2vQ3xG3n95mVEVi3plcaa xfRXu/z2IiySOI9XxlkmqeJ4kLWVTb8eKTBAkfjAXPvGCaNdT98aseFdTvBgCXM9vh+v 0Rt4abuLmLQmlhFihwWk4ungTTOkrq8N4giKtDVXD2p28/k8RcDZroNJsvg5OFe/LBnA BUqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=zVnj6waZd9x5940g8RNSxK9BY47w0+gihQ1jnFxFj9c=; b=G3nOItA0o3eodmzeipRtLBw3frOxXrS7eWsdHLtlKrI3RQNp8lU7iP3hzcHep4Tsnm aAUucAY15mu00O/zTg8tCrdBlEM9vLsrrrsHwVN7FdPIwqhZJlLs/gc3FlKDBubwTcLW YCzd+fXJ7Rved/TdFcaXDr5CHQV4/nA0NmHEPWJfQThJmL4tjHY1kc09xIXx67FzqnId ZTgoNvFqPOmV6L5muYM04n47ilE12/VQfBINYSjxKpk6BS5RUsA7q7hBNC7/95qv/Q5i sb8rZP7Zuzkv2DPgB58g3cVUk9sVHiJEkNnVeuT6px0y/1J0lIPYVBLmc58DsgRcarya tt3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=YfSfsI3F; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s21-20020aa7d795000000b0046aaf5398c8si951455edq.174.2022.11.30.02.43.09; Wed, 30 Nov 2022 02:43:30 -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=@broadcom.com header.s=google header.b=YfSfsI3F; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235421AbiK3KIN (ORCPT + 84 others); Wed, 30 Nov 2022 05:08:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235463AbiK3KII (ORCPT ); Wed, 30 Nov 2022 05:08:08 -0500 Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBAAD24085 for ; Wed, 30 Nov 2022 02:08:07 -0800 (PST) Received: by mail-yb1-xb29.google.com with SMTP id e141so20912177ybh.3 for ; Wed, 30 Nov 2022 02:08:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=zVnj6waZd9x5940g8RNSxK9BY47w0+gihQ1jnFxFj9c=; b=YfSfsI3Fh55w+bXqNJ/n/FekU8Tk7q1dJwU3lmmxbz6yNu0nVhGHXX/ju7cppG6YqS TUyubeE98b1pIcUfcdAm9355g40BlS3Tad9CbIwwvb0NBN1Gt6DFmzlYsPip9YjSPj4X w87xLUni7+BwS6dBifEOXcYxARPnFJDav7Pg0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zVnj6waZd9x5940g8RNSxK9BY47w0+gihQ1jnFxFj9c=; b=R74iha2tyie/BF07FbogPpOeUs+JXYb19Mi8BSaO2X/WPRkaj8hHyF5PMu5/GHLSER 2vgm9zBKXFvn/CY96jB4ybBJNgx0XFDJzyyW3IinFI+JB4BhIbFlhpFIL5paT8aJOJhA X4eXqMAOpOIdigEJRxdHbN7v8UMwSzC59ELdA8/ORqEico2Og/pL67YatSeSAFfjSthH m8DWuTVK5Mq5KP7UsG/SdOkFhQAptdEiiTGqLPHaEF6Os+4bMj8Ig9u4rSr8wOS0kcj1 gLFhO0ql6WPmdIuIXO9/VwpU7DSlvGBvH5kzbbWn3LKN1POK8L0t8inYQCV/qH1bXnLd IiaA== X-Gm-Message-State: ANoB5plZ615x4p/ZFxuznpYHA5FjjJ+R7rUeu4Ah5m1ODQzAi4ieo5Nz fC0E4S88ImEeOqLS37AKaSvBYiXI9xXdXCvikTLONQ== X-Received: by 2002:a5b:285:0:b0:6d3:bab1:8d32 with SMTP id x5-20020a5b0285000000b006d3bab18d32mr57265919ybl.541.1669802886911; Wed, 30 Nov 2022 02:08:06 -0800 (PST) MIME-Version: 1.0 References: <20221130084431.3299054-1-YKarpov@ispras.ru> In-Reply-To: <20221130084431.3299054-1-YKarpov@ispras.ru> From: Pavan Chebbi Date: Wed, 30 Nov 2022 15:37:56 +0530 Message-ID: Subject: Re: [PATCH] net: dsa: fix NULL pointer dereference in seq_match() To: Yuri Karpov Cc: Andrew Lunn , 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 Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="000000000000efe71405eead47cd" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE 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 --000000000000efe71405eead47cd Content-Type: text/plain; charset="UTF-8" On Wed, Nov 30, 2022 at 2:15 PM Yuri Karpov wrote: > > 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; > } You need to have the target tree in the subject. But change looks good to me. Reviewed-by: Pavan Chebbi > > static void mv88e6xxx_get_rxts(struct mv88e6xxx_chip *chip, > -- > 2.34.1 > --000000000000efe71405eead47cd Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIIQbQYJKoZIhvcNAQcCoIIQXjCCEFoCAQExDzANBglghkgBZQMEAgEFADALBgkqhkiG9w0BBwGg gg3EMIIFDTCCA/WgAwIBAgIQeEqpED+lv77edQixNJMdADANBgkqhkiG9w0BAQsFADBMMSAwHgYD VQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UE AxMKR2xvYmFsU2lnbjAeFw0yMDA5MTYwMDAwMDBaFw0yODA5MTYwMDAwMDBaMFsxCzAJBgNVBAYT AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMTEwLwYDVQQDEyhHbG9iYWxTaWduIEdDQyBS MyBQZXJzb25hbFNpZ24gMiBDQSAyMDIwMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA vbCmXCcsbZ/a0fRIQMBxp4gJnnyeneFYpEtNydrZZ+GeKSMdHiDgXD1UnRSIudKo+moQ6YlCOu4t rVWO/EiXfYnK7zeop26ry1RpKtogB7/O115zultAz64ydQYLe+a1e/czkALg3sgTcOOcFZTXk38e aqsXsipoX1vsNurqPtnC27TWsA7pk4uKXscFjkeUE8JZu9BDKaswZygxBOPBQBwrA5+20Wxlk6k1 e6EKaaNaNZUy30q3ArEf30ZDpXyfCtiXnupjSK8WU2cK4qsEtj09JS4+mhi0CTCrCnXAzum3tgcH cHRg0prcSzzEUDQ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