From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,T_DKIMWL_WL_HIGH,USER_AGENT_GIT autolearn=unavailable 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 54CC7C282DD for ; Thu, 23 May 2019 19:11:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 20071217D7 for ; Thu, 23 May 2019 19:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558638663; bh=njElPnaRJo7QnNe5tpGga1zWZ+5KlMYoj1hGS/wQWmY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=qPIgsJ/Z24p/bfr2UjbPviYKpbTf9WzYhAv32f9b/Wl59MM/XjdJ5TRtcivRzMHzE CiemIC2gnsSgC+2GbHNk1ZEqNE19euvJBZNj1YT0pDAUgW/mQqB1lEXczYmR8XVRSJ BG+XCHrcImziidS2OcSOur9N2Q7KVoEFZ9C88w04= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388053AbfEWTLC (ORCPT ); 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); }