Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751646AbcLBQPK (ORCPT ); Fri, 2 Dec 2016 11:15:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57290 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751290AbcLBQN7 (ORCPT ); Fri, 2 Dec 2016 11:13:59 -0500 Date: Fri, 02 Dec 2016 11:05:10 -0500 (EST) Message-Id: <20161202.110510.316320127082862142.davem@redhat.com> To: basil@pacabunga.com Cc: jreuter@yaina.de, ralf@linux-mips.org, linux-hams@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, ed@wizkers.io, mcdermj@xenotropic.com Subject: Re: [PATCH 1/1] ax25: Fix segfault when receiving an iframe with net2kiss loaded From: David Miller In-Reply-To: <20161130111525.13f74728@brox.localnet> References: <20161130111525.13f74728@brox.localnet> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 02 Dec 2016 16:05:13 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 883 Lines: 23 From: Basil Gunn Date: Wed, 30 Nov 2016 11:15:25 -0800 > AX.25 uses sock_queue_rcv_skb() to queue an iframe received packet. > This routine writes NULL to the socket buffer device structure > pointer. The socket buffer is subsequently serviced by > __netif_receiv_skb_core() which dereferences the device structure > pointer & segfaults. > > The fix puts the ax25 device structure pointer back in the socket > buffer struct after sock_queue_rcv_skb() is called. You cannot do this. We have no reference count held on the device object, therefore once access to this SKB leaves the receive packet processing path and thus the RCU protected region, we must set skb->dev to NULL. Queueing the SKB to the socket causes the SKB to leave the receive processing path. You will have to find another way to propagate this device pointer to the code that needs it.