Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2153672ybm; Thu, 23 May 2019 12:14:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOg8XXSrs05r3CXF7AZjw6sfSxC3W+DkGZSmIjwbMioHoxHSJ1hxNlWfK0dhcD6rGCLTNE X-Received: by 2002:a63:c203:: with SMTP id b3mr69033231pgd.398.1558638876999; Thu, 23 May 2019 12:14:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558638876; cv=none; d=google.com; s=arc-20160816; b=RGVC5dJytGTKsJ4mTivF/IL8fL06EOu02Wvvy7S8HoVREf+JuL5ASXZIytX49m4pGr ZjJYoxtpDnCU5d/wSV1QoPXNJTG8NoUujh5cHcwAIV0j5t01mfofbb5/vhc6H1HGUwKU gPQlk31r/k6DpdWMSO3LWheGMUbByK1Tj65iulRMuvhEO3zA3xAQwn7OVKrbaDEASm0Y RXGG/ZOm8/gV7OOmjXUq51qQKfDbbDtY/iJymzIPEBHzB+uqqM0msF4uAAPDHFFNP+x8 /jiLnPmlVI4oe7dn84MzOGEWCkIz/QFO98gF7sj83LRzBt+qF2RZwSakoWsSSjFIB6rt +6Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=h88K8ADsB+DY8UAtwle5I45aEJxjkp6U8gW4QXjf3LU=; b=rcsfFzQXOBHWv+D9dm29s+BRPG1Vk1wbJXh6aWMdVazJto/Fv8IC6R5r/IwMrQLjMy 2DtljK3HSk9mSGVkxASXyvDUUhk2Heg3Cfo4GEDN50qfHjq0Z/48QarFlqzkY9Pgg7dm wqGDjB26JinmUX88C7m3PKLg6nT78k5BhC+tKFWonK+JdfBBjio/WQqYonp1Ha9MM/Ds QDQZDTumXomcN2tFKFwDvtDI26p4JZdGzWph8lE4NwKyE0I0PVVHCkpzR6RjMevxfCVl Ftz5MGDuPn+Vg6HaMqT0uwI2q3ABPv6Ehkuct+XMtV6BaAhJ0U7jKyhvQ/9zJBdXX4pT JWoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=URUcBBPY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z11si349778pjn.72.2019.05.23.12.14.22; Thu, 23 May 2019 12:14:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=URUcBBPY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388047AbfEWTLC (ORCPT + 99 others); Thu, 23 May 2019 15:11:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:44340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388028AbfEWTK7 (ORCPT ); Thu, 23 May 2019 15:10:59 -0400 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 B2EC1217D7; Thu, 23 May 2019 19:10:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558638659; bh=njElPnaRJo7QnNe5tpGga1zWZ+5KlMYoj1hGS/wQWmY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=URUcBBPY5P49/ke6iAN/4XXeKof1XDdxBGwFnhN3azWndszDQUS1RNMalveeDNAwN aX18JAZY11Rt/Q2JTe7dYmklnJQLZythB1WdMa2uzi4XKeozZs26N6UZayYqR7MU7w KV836WoQzD7eiIRT1K7Z0aSGTbwQqN8z9GH5aB9A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Willem de Bruijn , "David S. Miller" Subject: [PATCH 4.14 03/77] net: test nouarg before dereferencing zerocopy pointers Date: Thu, 23 May 2019 21:05:21 +0200 Message-Id: <20190523181720.483106584@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190523181719.982121681@linuxfoundation.org> References: <20190523181719.982121681@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Willem de Bruijn [ Upstream commit 185ce5c38ea76f29b6bd9c7c8c7a5e5408834920 ] Zerocopy skbs without completion notification were added for packet sockets with PACKET_TX_RING user buffers. Those signal completion through the TP_STATUS_USER bit in the ring. Zerocopy annotation was added only to avoid premature notification after clone or orphan, by triggering a copy on these paths for these packets. The mechanism had to define a special "no-uarg" mode because packet sockets already use skb_uarg(skb) == skb_shinfo(skb)->destructor_arg for a different pointer. Before deferencing skb_uarg(skb), verify that it is a real pointer. Fixes: 5cd8d46ea1562 ("packet: copy user buffers before orphan or clone") Signed-off-by: Willem de Bruijn Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- include/linux/skbuff.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1310,10 +1310,12 @@ static inline void skb_zcopy_clear(struc struct ubuf_info *uarg = skb_zcopy(skb); if (uarg) { - if (uarg->callback == sock_zerocopy_callback) { + if (skb_zcopy_is_nouarg(skb)) { + /* no notification callback */ + } else if (uarg->callback == sock_zerocopy_callback) { uarg->zerocopy = uarg->zerocopy && zerocopy; sock_zerocopy_put(uarg); - } else if (!skb_zcopy_is_nouarg(skb)) { + } else { uarg->callback(uarg, zerocopy); } @@ -2572,7 +2574,8 @@ static inline int skb_orphan_frags(struc { if (likely(!skb_zcopy(skb))) return 0; - if (skb_uarg(skb)->callback == sock_zerocopy_callback) + if (!skb_zcopy_is_nouarg(skb) && + skb_uarg(skb)->callback == sock_zerocopy_callback) return 0; return skb_copy_ubufs(skb, gfp_mask); }