Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3213187pxb; Mon, 9 Nov 2020 05:45:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJy++K1/WUdo1l8BWb4IvpNOb9uVPEVFsz/qJyQcYTlwc6keQwwbUFkZM2INCJY3uOTTyq6M X-Received: by 2002:aa7:c2d7:: with SMTP id m23mr15601621edp.230.1604929508757; Mon, 09 Nov 2020 05:45:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604929508; cv=none; d=google.com; s=arc-20160816; b=DuIpvLWoMvQdo51cCCo9rKm0wc59W5lJafWaMizlmBUoM1dqgoEhmqK6Fh/qnGEK76 rZD/2wquJvTlz618gC0vG0RVxcdm2myljZuI+oJKtpaUXoJyiOXKQncPt1hrGuifrq4z YgCrcnb7q/7VwSYZUvtVn7pE6Vu4qC80K1sdRQgb9BRIapKV94Rrk3zYkUzT3AgA6Ot2 KDT6BojIGHH7HSgsWXXb7C+sgZD+uAak6jZvZxebe7g4EwjBtR7+XiolFvGKHydp46Rq J/3UVM2qdimRdwGrnZcidpeRff7r9kRCKo5MBRnHVVkKZmrcEzhonPEK/86C40QoZq1u Asmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:user-agent:date:message-id:cc:to:subject:from; bh=6uNdJHqqpzXcoOQ9bo/6dYvgjhnrjGfGXQAFjvT3tLk=; b=GuoYwwGGkAo4TKgRH5+le3D11MJWw9r621gJoCwmfv0gjDPAtDQ2LS3ryftKFe9LaE Q+o6o0iTYIcUWMlYh9mwnq6KH/WlYWnsFqjqMbhdlAbWgri1V8MrXunmqFDk3e4ReydQ Q8iaDcSIlc3FwqEFBNULGCzn5gTEU4qZxuI63Bz6lK4cpnCdLzfPGXc1GoBGw4XYnpt1 VuVXtuI3+w6sXKuCPGmBQAdBaJPfSdXt8QsVF6IVqCgA+J2wcv0N97vLSP8lYkcpVGLR j6TbjVB6KG0POJhutbdV87pGmLNd2vDgrGlQwB3NCu8mWHbt7e6ARx+TEAK0IEFFUp8T lwKA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f10si7087289edx.567.2020.11.09.05.44.45; Mon, 09 Nov 2020 05:45:08 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732180AbgKINlP (ORCPT + 99 others); Mon, 9 Nov 2020 08:41:15 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:52638 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730631AbgKINjB (ORCPT ); Mon, 9 Nov 2020 08:39:01 -0500 Received: from 1.general.cking.uk.vpn ([10.172.193.212]) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kc7Nr-0000EE-UK; Mon, 09 Nov 2020 13:38:59 +0000 From: Colin Ian King Subject: re: net: dsa: hellcreek: Add support for hardware timestamping To: Kamil Alkhouri , Kurt Kanzenbach , Richard Cochran , Jakub Kicinski Cc: Andrew Lunn , ivien Didelot , Florian Fainelli , Vladimir Oltean , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "kernel-janitors@vger.kernel.org" Message-ID: <7c4b526c-b229-acdf-d22a-2bf4a206be5b@canonical.com> Date: Mon, 9 Nov 2020 13:38:59 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Static analysis on linux-next with Coverity has detected a potential null pointer dereference issue on the following commit: commit f0d4ba9eff75a79fccb7793f4d9f12303d458603 Author: Kamil Alkhouri Date: Tue Nov 3 08:10:58 2020 +0100 net: dsa: hellcreek: Add support for hardware timestamping The analysis is as follows: 323 /* Get nanoseconds from ptp packet */ 324 type = SKB_PTP_TYPE(skb); 4. returned_null: ptp_parse_header returns NULL (checked 10 out of 12 times). 5. var_assigned: Assigning: hdr = NULL return value from ptp_parse_header. 325 hdr = ptp_parse_header(skb, type); Dereference null return value (NULL_RETURNS) 6. dereference: Dereferencing a pointer that might be NULL hdr when calling hellcreek_get_reserved_field. 326 ns = hellcreek_get_reserved_field(hdr); 327 hellcreek_clear_reserved_field(hdr); This issue can only occur if the type & PTP_CLASS_PMASK is not one of PTP_CLASS_IPV4, PTP_CLASS_IPV6 or PTP_CLASS_L2. I'm not sure if this is a possibility or not, but I'm assuming that it would be useful to perform the null check just in case, but I'm not sure how this affects the hw timestamping code in this function. Colin