Received: by 2002:a05:6520:45c5:b0:135:a20d:b557 with SMTP id t5csp2134659lkv; Mon, 23 Aug 2021 10:29:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxgQb1Jb+vJ0YscJBpI8pysbgxVGsPB3ICPZdVVG8LPp2vB0R/f5Nc0qMdCLjPALIhdMto X-Received: by 2002:a50:fd87:: with SMTP id o7mr39069375edt.289.1629739776552; Mon, 23 Aug 2021 10:29:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629739776; cv=none; d=google.com; s=arc-20160816; b=tiQ3S6wNYVrKtrDpRekWusq8x6vjC1qAlQX+2FnxF92mJ9fbHqkpr0a3udk1/Bj0Nz qqGB7S+/6byIWOsb/fyeHIDdhXthP4KYtT7RfOb6HLXyOMCfIC6GVwtstfcmyXs0AwAs NDOb2HcVL0kovAv5WtGjArzosokCmKBoKArs715ZB66Y2xj66DGFdhFIwdW0eP6+9B56 zq5mCNh1wKG5fkeaFurSaHbvXZKOP47S6b3kMnK6MDMllzlxWth9HC6P2GfVAcGooVOz BjpukytVLaMH/q2RUF7cxVkWIDBjO+s4k49T6M/xVfK7pQmUBvulTj0NpX8v5158uzL0 QceQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Tn0lc6r/k3tCfWO6f7rPJPlrsVx45yPIfTd+tcFrbJo=; b=LyREJNZGdmiQRzVvaVBOKMeav//CuwBbLQ23Cb2jGfGHKlBUWQxVUuRD2TMrgzjcZd O+qwDxTifYQMYI850BzNvwAEKYDZ/7mUUv874GyN/bGu5vC5UckjrfjOcQLog0L+k7ST OGUppHM1EM7LwD8RGjXpZ2OgwecNAnKGRGVqB3NsybOYailJzEFyAl8BoIIW8D2exfJi TUJOaG8e+l7iWifctQ2FenZ1dI7NW1KVsb0nu3G43OCIgPAZbnbJCSzZIm7Js53MHFKg 9X30GlX6AhFR8QwAwHSe3Eqs79F8tjgBCyGiTeLxrMTmn7QfRY7R5TBLDZW8KQLegkTf 47sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="AG/Zg8l9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k18si14669011ejx.275.2021.08.23.10.29.12; Mon, 23 Aug 2021 10:29:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="AG/Zg8l9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230447AbhHWR0k (ORCPT + 99 others); Mon, 23 Aug 2021 13:26:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbhHWR0j (ORCPT ); Mon, 23 Aug 2021 13:26:39 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89EA0C061575; Mon, 23 Aug 2021 10:25:56 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id n12so27318898edx.8; Mon, 23 Aug 2021 10:25:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Tn0lc6r/k3tCfWO6f7rPJPlrsVx45yPIfTd+tcFrbJo=; b=AG/Zg8l9PaDXmc4D/DOzzON5OglkFRojuTDyHl1iOkFSZMpGTmo9Dy4bxNJsiIbp/Y KsUvgMcqUsNFY0zyrqoSLJUHvJhfIJAvalDs/y5ZOObj3yBjsklZE0xDyxeM6AfYfHaf sxn8X2T++0A+8doFpXX977UuUf7M6g8ej5fLwiJ5dt4JDW9UUINV1iBeLy/7q4EwhJhn FXxCm60B3MWqB2I5pobH2d3u41IA7ItOpDEB3TKJ7nmY8kylLj8pKrkAVF0L4CF2o93W LAbYxQ73FU/OYUapYu7vN+sBHomDcouL5YsnTnGNcSgqahZ9C73Jx1TQrexII6Hp+jyp NxLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Tn0lc6r/k3tCfWO6f7rPJPlrsVx45yPIfTd+tcFrbJo=; b=ca9wPfG/73vAXlGKLqQNgsy4XgrWmXSRgwqTkAbU3fCrD9pigJ2h2iWvZ2yJHQWhRt GAwvJjkZDzAF1j4/4UXOXifPQTiekkP2o3VRmXJwnQMvipPVcR/DnFQfxyZkxo1eQpzS n6ZLxwCFV27ALFDRrPthzW4wpClvXyWfPjNmx0KYdm1AtlOMJabhJEPTjSF+V9BSrSQr 5cbvvc5JdTlv19cj+uHvHODa3s2FWfhjlo8WGOUeFLEM5KBpIMbK2zH8aN6r8hGQpc0T LMXkjqCzmmA0uhSztcKPOwsSjXqe3jz1U+wsLObZGldsX8zC0A5fZonj5VO8lwAygooN LM2Q== X-Gm-Message-State: AOAM533xlQwSs5QD2fGpqG+QgizcUr4Xkh/K5Rc+wuYbRgp/fjK+qr1S 57GQDFNO8jMBqp1LEJPtwDJ5xTmtNv8+5iLI6TFVr43it6gPuw== X-Received: by 2002:aa7:d681:: with SMTP id d1mr39260570edr.186.1629739554952; Mon, 23 Aug 2021 10:25:54 -0700 (PDT) MIME-Version: 1.0 References: <6858f130-e6b4-1ba7-ed6f-58c00152be69@virtuozzo.com> In-Reply-To: From: Christoph Paasch Date: Mon, 23 Aug 2021 10:25:43 -0700 Message-ID: Subject: Re: [PATCH NET-NEXT] ipv6: skb_expand_head() adjust skb->truesize incorrectly To: Vasily Averin Cc: "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , Eric Dumazet , netdev , LKML , kernel@openvz.org, Julian Wiedmann Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Mon, Aug 23, 2021 at 12:56 AM Vasily Averin wrote: > > Christoph Paasch reports [1] about incorrect skb->truesize > after skb_expand_head() call in ip6_xmit. > This happen because skb_set_owner_w() for newly clone skb is called > too early, before pskb_expand_head() where truesize is adjusted for > (!skb-sk) case. > > [1] https://lkml.org/lkml/2021/8/20/1082 > > Reported-by: Christoph Paasch > Signed-off-by: Vasily Averin > --- > net/core/skbuff.c | 24 +++++++++++++----------- > 1 file changed, 13 insertions(+), 11 deletions(-) > > diff --git a/net/core/skbuff.c b/net/core/skbuff.c > index f931176..508d5c4 100644 > --- a/net/core/skbuff.c > +++ b/net/core/skbuff.c > @@ -1803,6 +1803,8 @@ struct sk_buff *skb_realloc_headroom(struct sk_buff *skb, unsigned int headroom) > > struct sk_buff *skb_expand_head(struct sk_buff *skb, unsigned int headroom) > { > + struct sk_buff *oskb = skb; > + struct sk_buff *nskb = NULL; > int delta = headroom - skb_headroom(skb); > > if (WARN_ONCE(delta <= 0, > @@ -1811,21 +1813,21 @@ struct sk_buff *skb_expand_head(struct sk_buff *skb, unsigned int headroom) > > /* pskb_expand_head() might crash, if skb is shared */ > if (skb_shared(skb)) { > - struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC); > - > - if (likely(nskb)) { > - if (skb->sk) > - skb_set_owner_w(nskb, skb->sk); > - consume_skb(skb); > - } else { > - kfree_skb(skb); > - } > + nskb = skb_clone(skb, GFP_ATOMIC); > skb = nskb; > } > if (skb && > - pskb_expand_head(skb, SKB_DATA_ALIGN(delta), 0, GFP_ATOMIC)) { > - kfree_skb(skb); > + pskb_expand_head(skb, SKB_DATA_ALIGN(delta), 0, GFP_ATOMIC)) > skb = NULL; > + > + if (!skb) { > + kfree_skb(oskb); > + if (nskb) > + kfree_skb(nskb); > + } else if (nskb) { > + if (oskb->sk) > + skb_set_owner_w(nskb, oskb->sk); > + consume_skb(oskb); sorry, this does not fix the problem. The syzkaller repro still triggers the WARN. When it happens, the skb in ip6_xmit() is not shared as it comes from __tcp_transmit_skb, where it is skb_clone()'d. Christoph > } > return skb; > } > -- > 1.8.3.1 >