From patchwork Tue Jan 7 20:55:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 234372 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D14FC33C9B for ; Tue, 7 Jan 2020 21:07:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E133924679 for ; Tue, 7 Jan 2020 21:07:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578431278; bh=ofr8e3gfatCCmd/bki2vXdSQ7vRODtS1BFvDJDueerU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=UfZdYTaNrUbW1SNsVmeKfo3YqdhoqXrHM4pEzYJ49qDYuLXmmWc0jbDYns1KLcwu0 590ivcHbJaP3R0lWPz9okD1y0Kc0IopU1P2cdOe5ptGkc5CtCwfNdiOhX5nixXsLAO 62X2cY5vRrrlzRXgf+j+G1840PFosSX/Z0JZ4iNw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729597AbgAGVH4 (ORCPT ); Tue, 7 Jan 2020 16:07:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:59574 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729305AbgAGVHz (ORCPT ); Tue, 7 Jan 2020 16:07:55 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 762482087F; Tue, 7 Jan 2020 21:07:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578431274; bh=ofr8e3gfatCCmd/bki2vXdSQ7vRODtS1BFvDJDueerU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p1IZtWRXqJqgbP56wMzVK9ZGiiD9KPAWJb4Y7MdVxBr6ElUgza/nBeRhMkWSS/AHq MCrZ//UlnKqUCRHudYcO93ZM99EgQdr46N7W7ApG+hLUbm+KRMqPcX5xOpS+b4XIRU X7/l+k7w3yXNU3EOpMNsKLzWW4qFKahcXt8pZ31I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+611164843bd48cc2190c@syzkaller.appspotmail.com, David Howells , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 105/115] rxrpc: Fix possible NULL pointer access in ICMP handling Date: Tue, 7 Jan 2020 21:55:15 +0100 Message-Id: <20200107205308.781757705@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200107205240.283674026@linuxfoundation.org> References: <20200107205240.283674026@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: David Howells [ Upstream commit f0308fb0708078d6c1d8a4d533941a7a191af634 ] If an ICMP packet comes in on the UDP socket backing an AF_RXRPC socket as the UDP socket is being shut down, rxrpc_error_report() may get called to deal with it after sk_user_data on the UDP socket has been cleared, leading to a NULL pointer access when this local endpoint record gets accessed. Fix this by just returning immediately if sk_user_data was NULL. The oops looks like the following: #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page ... RIP: 0010:rxrpc_error_report+0x1bd/0x6a9 ... Call Trace: ? sock_queue_err_skb+0xbd/0xde ? __udp4_lib_err+0x313/0x34d __udp4_lib_err+0x313/0x34d icmp_unreach+0x1ee/0x207 icmp_rcv+0x25b/0x28f ip_protocol_deliver_rcu+0x95/0x10e ip_local_deliver+0xe9/0x148 __netif_receive_skb_one_core+0x52/0x6e process_backlog+0xdc/0x177 net_rx_action+0xf9/0x270 __do_softirq+0x1b6/0x39a ? smpboot_register_percpu_thread+0xce/0xce run_ksoftirqd+0x1d/0x42 smpboot_thread_fn+0x19e/0x1b3 kthread+0xf1/0xf6 ? kthread_delayed_work_timer_fn+0x83/0x83 ret_from_fork+0x24/0x30 Fixes: 17926a79320a ("[AF_RXRPC]: Provide secure RxRPC sockets for use by userspace and kernel both") Reported-by: syzbot+611164843bd48cc2190c@syzkaller.appspotmail.com Signed-off-by: David Howells Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/rxrpc/peer_event.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/rxrpc/peer_event.c b/net/rxrpc/peer_event.c index dc7fdaf20445..42582a9ff81d 100644 --- a/net/rxrpc/peer_event.c +++ b/net/rxrpc/peer_event.c @@ -153,6 +153,9 @@ void rxrpc_error_report(struct sock *sk) struct rxrpc_peer *peer; struct sk_buff *skb; + if (unlikely(!local)) + return; + _enter("%p{%d}", sk, local->debug_id); skb = sock_dequeue_err_skb(sk);