Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6137034ybi; Wed, 29 May 2019 03:27:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSxA5sfnysXZPQN17szHrSq2t/VuQcqkSwCOCFU1+FTADkhUz4UujTvIHbIDeqprp9RnXq X-Received: by 2002:aa7:8d89:: with SMTP id i9mr147166016pfr.77.1559125675310; Wed, 29 May 2019 03:27:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559125675; cv=none; d=google.com; s=arc-20160816; b=ffWgfsclmoG6hmGymR3sgKh8Rjn53DZ1+RB0i21CMFGEFVhlROpwa1cQES+Sg5Ux6S sE+JCF3KFbRiYH7lT2PJonVseqHFZruXY7c1UBAlXvDwDTBRkHAUQwLIXeCxIPQgS8kF rbxq05QjjtGzNZmG9cFuB8rYHw7yW44LCo/VmIdm/H+xPZ2XQVV7u6n7Ak2i+WOYe5R2 Uybv5TALeALwWT0be2rhgsKoCYBkx9dF0Wxd1v16Y2X/Wk5ZlrZacPHC8W/mPpMCdgjT fliJD8nYHJCuyNzokXJ4f/ANW1Il7Pq1Q61d/2NmsI/b/8OS5KDhDdfs4wTz4dQdT+Uk RqOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=o+olP4EDhYUZmN9h+6k4acKXLYgClTSuL6+7nIZkQtI=; b=rxr2/zy5Lh5Qi3YqHm//YnjmF5iCCngDG1tk1JW1btAOT187f/yuF1X7H5U2iwnXxh 4fuSMnoGXd67uE0JmVFYOHK0MNwRCz2+SYYr7RQ0+msofdPr6r8BDlCVBIrZuaghqStg qY+ZrO0vVWo6nHJV/ZWLJ7Lm1uedRuWxHVp/Zc6MsH0pIKmZASoq1l2GgitgkY+XjBDq oXIYdt9Kv91VcnHMQvBgntq76uwhV9jennkGonJk3nTLYcShD4cPgAoWPfHMfR20BBN+ ESfBYXVIOncBddF2DpoKvJ1bUZycMc7N+1Fkcc/C32DWx+Ex9GZ70eqdvKMZr5HLBXV0 EBbQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q69si6710786pjc.6.2019.05.29.03.27.38; Wed, 29 May 2019 03:27:55 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726949AbfE2K0A (ORCPT + 99 others); Wed, 29 May 2019 06:26:00 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:40611 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726043AbfE2KZr (ORCPT ); Wed, 29 May 2019 06:25:47 -0400 Received: from 1.general.smb.uk.vpn ([10.172.193.28] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1hVvmD-0003j5-I6; Wed, 29 May 2019 10:25:45 +0000 From: Stefan Bader To: stable , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Eric Dumazet , Sasha Levin , Peter Oskolkov , Ben Hutchings , Andy Whitcroft , Greg KH Subject: [PATCH 4/4] ipv6: frags: Use inet_frag_pull_head() in ip6_expire_frag_queue() Date: Wed, 29 May 2019 12:25:42 +0200 Message-Id: <20190529102542.17742-5-stefan.bader@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190529102542.17742-1-stefan.bader@canonical.com> References: <20190529102542.17742-1-stefan.bader@canonical.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With frag code shared between IPv4 and IPv6 it is now possible to use inet_frag_pull_head() in ip6_expire_frag_queue() in order to properly extract the first skb from the frags queue. Since this really takes the skb out of the list, it no longer needs to be protected against removal (which implicitly fixes a crash that will happen somewhere in the call to icmp6_send() when the use count is forcefully checked to be 1. kernel BUG at linux-4.4.0/net/core/skbuff.c:1207! RIP: 0010:[] [] pskb_expand_head+0x243/0x250 [] __pskb_pull_tail+0x50/0x350 [] _decode_session6+0x26a/0x400 [] __xfrm_decode_session+0x39/0x50 [] icmpv6_route_lookup+0xf0/0x1c0 [] icmp6_send+0x5e1/0x940 [] icmpv6_send+0x21/0x30 [] ip6_expire_frag_queue+0xe0/0x120 Signed-off-by: Stefan Bader --- net/ipv6/reassembly.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 020cf70273c9..2bd45abc2516 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c @@ -110,16 +110,14 @@ void ip6_expire_frag_queue(struct net *net, struct frag_queue *fq) IP6_INC_STATS_BH(net, __in6_dev_get(dev), IPSTATS_MIB_REASMTIMEOUT); /* Don't send error if the first segment did not arrive. */ - head = fq->q.fragments; - if (!(fq->q.flags & INET_FRAG_FIRST_IN) || !head) + if (!(fq->q.flags & INET_FRAG_FIRST_IN)) + goto out; + + head = inet_frag_pull_head(&fq->q); + if (!head) goto out; - /* But use as source device on which LAST ARRIVED - * segment was received. And do not use fq->dev - * pointer directly, device might already disappeared. - */ head->dev = dev; - skb_get(head); spin_unlock(&fq->q.lock); icmpv6_send(head, ICMPV6_TIME_EXCEED, ICMPV6_EXC_FRAGTIME, 0); -- 2.17.1