Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1238111pxu; Mon, 23 Nov 2020 15:36:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJyUKUZxK5lTE0VHijlZdbKdD8c/YpcwhbbwpIvm0iKGED2HRhKPGQLZxnFCLfTIse5Ca5Zr X-Received: by 2002:a17:906:6a4e:: with SMTP id n14mr1808335ejs.194.1606174572106; Mon, 23 Nov 2020 15:36:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606174572; cv=none; d=google.com; s=arc-20160816; b=RpWtxTmxR1B+vKExsVTEkj5abqIeMUNlTY6749lxtH+LejBHqqZ2+df/yygVq4iB1d sjhDjewOVvcRSWKWSifHnvS6o6uViUpSwqHnogT5E2q6tskQ7z5MYT3Q8cA1grlZw8UX J9kZeyjblQ0aWF+fj9xcYKetDndmsMeHr5ZNgV+/+axopUdLi9nrmPg9Qp771rm/lM3E JvUnmtYAAbNRxWY43CpaEOGk9r613j+/Y+2qsE29X6Zl6Va/M1DxZxuONthUKUSQG/Pm 0gdjs8jeCTq1mMQYxsdsGxYqSd82e5D+zbiopBkgf4iuKTokJxn4bzq0yxX9S8lAfg/n P9vg== 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=2zCoehkMHX1dCKDd2Cf8HENHQrdfyoJkDiBi7D58jxU=; b=O7QO2rncb2I7Qq87tpIgq1Hz4BCLovVFluTq/C6hSkRkibOKZUdgUOFQNfR7Y8mk0K ylofBan3k8aTse/oLtJFFiSKUKRz1ssYgxeV1Io5siH2gEHSQ81xfFWy3FmTt8IwaYZY mHvdMfXU1/EUiu2nC7h2GVF7J/KsGoWY2Rzb6Bcuuu1noX9/cDW9smHVbkhoHzj8ah05 JHpTv5+utXpfq0OGiY5qRR4Zupf2t5lGQZfece3EqQyN1C047e8BiVJSllczWb3/bfJe 1+LUqE4EckTubXeKLmci7pBGqr8B56FOcRQQzEvN8PHayUjhUtyGnIhWBa6Q7uGffLoW 5GYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Rnah4LZt; 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 g18si7290939edh.40.2020.11.23.15.35.49; Mon, 23 Nov 2020 15:36:12 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Rnah4LZt; 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 S1731393AbgKWMeg (ORCPT + 99 others); Mon, 23 Nov 2020 07:34:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:46280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731378AbgKWMec (ORCPT ); Mon, 23 Nov 2020 07:34:32 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6EBDC208DB; Mon, 23 Nov 2020 12:34:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606134871; bh=fbKZ/v1f/Y69Fi5kPOfTz3hmzaxaZOrXbwLaHvmEm0I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rnah4LZtmuKp5kZCwgR+NJOhV5g07yTd0PCphcXHgpuFCxqyyzsDTTeUz6fcolymP FMm7WHTvjBqHsorGYuV6hD4tC5HOZSriq2YO96GSjMEIbf/sNsAcruP0TUWH+pv9qy 399mgy7vSAyeTloGabba4wvPPokWxiUAHlPACJ1I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Tranchetti , Subash Abhinov Kasiviswanathan , Jakub Kicinski Subject: [PATCH 5.4 020/158] net: qualcomm: rmnet: Fix incorrect receive packet handling during cleanup Date: Mon, 23 Nov 2020 13:20:48 +0100 Message-Id: <20201123121820.910719364@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121819.943135899@linuxfoundation.org> References: <20201123121819.943135899@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: Subash Abhinov Kasiviswanathan [ Upstream commit fc70f5bf5e525dde81565f0a30d5e39168062eba ] During rmnet unregistration, the real device rx_handler is first cleared followed by the removal of rx_handler_data after the rcu synchronization. Any packets in the receive path may observe that the rx_handler is NULL. However, there is no check when dereferencing this value to use the rmnet_port information. This fixes following splat by adding the NULL check. Unable to handle kernel NULL pointer dereference at virtual address 000000000000000d pc : rmnet_rx_handler+0x124/0x284 lr : rmnet_rx_handler+0x124/0x284 rmnet_rx_handler+0x124/0x284 __netif_receive_skb_core+0x758/0xd74 __netif_receive_skb+0x50/0x17c process_backlog+0x15c/0x1b8 napi_poll+0x88/0x284 net_rx_action+0xbc/0x23c __do_softirq+0x20c/0x48c Fixes: ceed73a2cf4a ("drivers: net: ethernet: qualcomm: rmnet: Initial implementation") Signed-off-by: Sean Tranchetti Signed-off-by: Subash Abhinov Kasiviswanathan Link: https://lore.kernel.org/r/1605298325-3705-1-git-send-email-subashab@codeaurora.org Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c @@ -188,6 +188,11 @@ rx_handler_result_t rmnet_rx_handler(str dev = skb->dev; port = rmnet_get_port_rcu(dev); + if (unlikely(!port)) { + atomic_long_inc(&skb->dev->rx_nohandler); + kfree_skb(skb); + goto done; + } switch (port->rmnet_mode) { case RMNET_EPMODE_VND: