Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2235210ybi; Thu, 20 Jun 2019 11:20:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4+IJB7Tjh3Kx7cu34ntb8KsvWBkEkK5wRvtA2mPlTdM84vXsm0TaOf3NxelEAFh7IIfxc X-Received: by 2002:a17:90a:7d04:: with SMTP id g4mr1011302pjl.41.1561054830096; Thu, 20 Jun 2019 11:20:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561054830; cv=none; d=google.com; s=arc-20160816; b=x/gZsRaIZ0ok9dMrH+L1oLqR/3i9GIN9J5iSODin/m0RM8kz3o1mNRrS3cKn8pjaqp D7P3haIwvIG+POeKKSzIxfyzz3d9A3uSr0wxzG/I5CGZjeKPszsGFIqPNpR/RPxvmqag X+m9GD4ddagyP6S+5F+dXuP4vyscY05AFDZe7N2cysm8ww7IYZbYMETGZfyBvUUnwsAn NT6WjwxGIrvJ0t3yJiro5L3JkB/YFwo7ew7Kl4QIEdaPWQjbAoj94Z3yabtXwbAehvNj uP/DTfhD/mF+bXGBgQae3sy4ClqE+MlGiQ5iECUALcxKrufXFduhc6Bsu1tkiHL/Msuq EgDA== 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=R7A9cu/8HXzvn3kWQy8vbjEnj6jlWh9S4vJT90FFjYk=; b=BPo4l/BiLAGZp9V6OOM8iJk/8RCd+MW5YGVJgd4VDFzwIWlS0q+1/9deguO93Dim5f TkEDw9Ikciu3IB+yHkIM+OQT+wklpLh/oO5y9LWfxTqja5ESlIPEqPDEY+T9vXoe+0GG StSnpkZjFilPQJbjrZboaYVVB8PLdGeGQv3X50bPOdTjeGLXa70le7lDUXUfKuLmO3pK stimTlj89ot5xcNYkvusCD71JamfjXTn2I+9gVqSHqaJ6jJNlF3rFRD4mz60Vgf+aLPu i9jbUAejseT5bdtQEhgnr1JyC/r3MIje/Le1t4Qb7Yp8f5a27Uev4u0y+HhoYrxulRcs NG2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fpdddb6v; 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 j25si176140pfr.11.2019.06.20.11.20.14; Thu, 20 Jun 2019 11:20:30 -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=fpdddb6v; 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 S1729380AbfFTSOD (ORCPT + 99 others); Thu, 20 Jun 2019 14:14:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:42170 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729081AbfFTSOB (ORCPT ); Thu, 20 Jun 2019 14:14:01 -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 311F5205F4; Thu, 20 Jun 2019 18:14:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561054440; bh=6ijn6mL8RusQO+kHen1qojezEJ0W/LWwviffWpE/j+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fpdddb6v7Bb5RDdM58VoDodQ7CXddoLvDU8Yu01BbHMGvAALXELZsEbMwK98BngvL d3GaxAkOYLIcc6wyQNSZcsIof8q9RfSmcW0Frvs9tXNhBgaNMGB8P/Tb3Zpq31sSrK 78ypo2zZZ+730Qu1tIPoEczffMZwDHYdXxlNFZfY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot , Willem de Bruijn , "David S. Miller" Subject: [PATCH 5.1 30/98] net: correct udp zerocopy refcnt also when zerocopy only on append Date: Thu, 20 Jun 2019 19:56:57 +0200 Message-Id: <20190620174350.484033329@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190620174349.443386789@linuxfoundation.org> References: <20190620174349.443386789@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 522924b583082f51b8a2406624a2f27c22119b20 ] The below patch fixes an incorrect zerocopy refcnt increment when appending with MSG_MORE to an existing zerocopy udp skb. send(.., MSG_ZEROCOPY | MSG_MORE); // refcnt 1 send(.., MSG_ZEROCOPY | MSG_MORE); // refcnt still 1 (bar frags) But it missed that zerocopy need not be passed at the first send. The right test whether the uarg is newly allocated and thus has extra refcnt 1 is not !skb, but !skb_zcopy. send(.., MSG_MORE); // send(.., MSG_ZEROCOPY); // refcnt 1 Fixes: 100f6d8e09905 ("net: correct zerocopy refcnt with udp MSG_MORE") Reported-by: syzbot Signed-off-by: Willem de Bruijn Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/ip_output.c | 2 +- net/ipv6/ip6_output.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -923,7 +923,7 @@ static int __ip_append_data(struct sock uarg = sock_zerocopy_realloc(sk, length, skb_zcopy(skb)); if (!uarg) return -ENOBUFS; - extra_uref = !skb; /* only extra ref if !MSG_MORE */ + extra_uref = !skb_zcopy(skb); /* only ref on new uarg */ if (rt->dst.dev->features & NETIF_F_SG && csummode == CHECKSUM_PARTIAL) { paged = true; --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -1344,7 +1344,7 @@ emsgsize: uarg = sock_zerocopy_realloc(sk, length, skb_zcopy(skb)); if (!uarg) return -ENOBUFS; - extra_uref = !skb; /* only extra ref if !MSG_MORE */ + extra_uref = !skb_zcopy(skb); /* only ref on new uarg */ if (rt->dst.dev->features & NETIF_F_SG && csummode == CHECKSUM_PARTIAL) { paged = true;