From patchwork Wed May 14 14:23:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 4175291 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5F035BFF02 for ; Wed, 14 May 2014 14:24:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8EF6F20265 for ; Wed, 14 May 2014 14:24:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 887B22017D for ; Wed, 14 May 2014 14:24:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753296AbaENOX4 (ORCPT ); Wed, 14 May 2014 10:23:56 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:34644 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752064AbaENOXz (ORCPT ); Wed, 14 May 2014 10:23:55 -0400 Received: by mail-pa0-f48.google.com with SMTP id rd3so1743232pab.21 for ; Wed, 14 May 2014 07:23:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :content-type:content-transfer-encoding:mime-version; bh=xVZRFL41BR9+bcnVIlr60Fj40XaA2x3YSYbBQyZpZnU=; b=02xVjBG0z+rzRDAgbB8KjjKpXI/vlFZN/iW1daghnNDkCPVMtVK9omVfKJOqS3zwrL Qgm3cL5vvHgduSej7pwE+nFrB2eSz0gadU7M01Pumm69zKGnCRxa/0+at8BIPov6QdYy +7HzVa1HbabY34Zu+c3JAWOragZUm3228t/k277nasaDgNWSdArcIO1/KX7a9doZ5OYE XIQPu7WDdQGM3X4rdt9GZdDhCkgLHZUBlIeEECmBn3Q2g27Ut+Oj4e5qwwBq1BYmssBX FCD64Gmyy+YMPPVPsmA+CamkBKPm19bHAU+9vj8TOwvvyEZUcFVPnhfyWZypwKybZvkZ b7sw== X-Received: by 10.66.136.71 with SMTP id py7mr4995568pab.2.1400077434550; Wed, 14 May 2014 07:23:54 -0700 (PDT) Received: from [172.19.251.78] ([172.19.251.78]) by mx.google.com with ESMTPSA id ei4sm3833852pbb.42.2014.05.14.07.23.51 for (version=SSLv3 cipher=RC4-SHA bits=128/128); Wed, 14 May 2014 07:23:52 -0700 (PDT) Message-ID: <1400077432.7973.85.camel@edumazet-glaptop2.roam.corp.google.com> Subject: Re: Moving frags and SKBTX_DEV_ZEROCOPY skbs From: Eric Dumazet To: Zoltan Kiss Cc: netdev@vger.kernel.org, "xen-devel@lists.xenproject.org" , kvm@vger.kernel.org, David Miller Date: Wed, 14 May 2014 07:23:52 -0700 In-Reply-To: <53737266.5040601@citrix.com> References: <53737266.5040601@citrix.com> X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, 2014-05-14 at 14:40 +0100, Zoltan Kiss wrote: > Hi, > > Recently I've investigated issues around SKBTX_DEV_ZEROCOPY skbs where > the frags list were modified. I came across this function skb_shift(), > which moves frags between skbs. And there are a lot more of such kind, > skb_split or skb_try_coalesce, for example. > It could be a dangerous thing if a frag is referenced from an skb which > doesn't have the original destructor_arg, and to avoid that > skb_orphan_frags should be called. Although probably these functions are > not normally touched in usual usecases, I think it would be useful to > review core skb functions proactively and add an skb_orphan_frags > everywhere where the frags could be referenced from other places. > Any opinion about this? For skb_shift(), it is currently used from tcp stack only, where this SKBTX_DEV_ZEROCOPY thing is not used, so I do not think there is a bug for the moment. I already gave a patch for skb_try_coalesce() : For this one we do not wan skb_orphan_frags() overhead. Its simply better in this case to abort. --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 1b62343f5837..85995a14aafc 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -3838,7 +3839,10 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from, return true; } - if (skb_has_frag_list(to) || skb_has_frag_list(from)) + if (skb_has_frag_list(to) || + skb_has_frag_list(from) || + (skb_shinfo(to)->tx_flags & SKBTX_DEV_ZEROCOPY) || + (skb_shinfo(from)->tx_flags & SKBTX_DEV_ZEROCOPY)) return false; if (skb_headlen(from) != 0) {