Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1236406pxu; Mon, 23 Nov 2020 15:33:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzsBRoBiOx749oHS4LXgh6s9mz8v0WoHAfJV1a4xK/a9Il/IhX7tX73XEIC7YNhrevZH5OE X-Received: by 2002:a17:906:660b:: with SMTP id b11mr1929554ejp.190.1606174406970; Mon, 23 Nov 2020 15:33:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606174406; cv=none; d=google.com; s=arc-20160816; b=sMbsECY6WR/B+KKcxIFo716O4UHyRaP6qmQevrx4sJYW7PYxHvEzSkGlzkCXs6ob6C UNBBxGfCRVRFOrOO8Ou5KxEW5US0ZQw1NbdTHWObwNk9Jv/0dQySxdSJBF7Nt/vs8tRQ JNoeswAIenX7OyV4By+MJvDgHf28jK8twEe2p6bRDr4Rs37ibpu6M5aXFvQOR690NQDu XYX4IDbXes1JuzubQUnjse7ccMIOAyXa5NraMuv0v+lYFi/OKYi6rv6YvHAGQFO1M4FH SGB7f81rftPJ4hpTa7nBfD+Ee+5viyw9yT2tPJlBqPQa7T9VSF8U8n42ZMJMCp673UaB RhIQ== 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=CCq83RW+9u3+WZACny+CuE/7NG08R7ytdp6er49RBSQ=; b=k5u/WlaatYgMxEIkysbRvAJPqKdVHm4oP+vB7dsmpcMTrz7U57DFaMU0cOhWxYkenI dY5jXLwNjx08KgbHBkJ4/y/nnggRDVOE7T7ZxWy/JWD+alAYp3IA1XuBE0mmqCUU5uks C0bGmaj1zagky0xEC6MGEmsaWE0Jg23zm5t/tSGzIiEqPcYcWeJ83OM4Qo1UmxLBy60m kAlkbme94bwMNl/BN3rQKRBUGzu4CdvqtakZ05P2WmQD8WQ9vO6SkGvHjCWreAtjWO8J z7K5wVYJ2248r3jjRNWhqfzO40XymH+jBbU4+lorsbjr2POTKKVwig833fHiIKYk7NoK DmKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BDJQzgP9; 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 v7si7362310edq.305.2020.11.23.15.33.04; Mon, 23 Nov 2020 15:33:26 -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=BDJQzgP9; 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 S1730647AbgKWMaB (ORCPT + 99 others); Mon, 23 Nov 2020 07:30:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:40696 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730674AbgKWMaA (ORCPT ); Mon, 23 Nov 2020 07:30:00 -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 B4F33217A0; Mon, 23 Nov 2020 12:29:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606134598; bh=gFYKp9oCnoY+gznxezB/CM7o+fWi9PE7Rvso+R0FRiE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BDJQzgP9fcCggplqJ4vwWJwc95giuW8+NRmdqZpyng/gjnUVPYoiiGBWswSUhNKD/ cThD4wpk7pIOSAY0LWq7B40pJbW+9S/5YF6kRy3y5mCmhS3DY6P+vUEPOoGiNw5/ga xDdR5rwO2cyOfRQI5JomGWSfa3USC9enDuAIWZkI= 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 4.19 16/91] net: qualcomm: rmnet: Fix incorrect receive packet handling during cleanup Date: Mon, 23 Nov 2020 13:21:36 +0100 Message-Id: <20201123121810.094422752@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121809.285416732@linuxfoundation.org> References: <20201123121809.285416732@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 @@ -197,6 +197,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: