Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp768854ybl; Wed, 11 Dec 2019 07:14:55 -0800 (PST) X-Google-Smtp-Source: APXvYqz6wULSgdA6uHxYJ0OQPGowsDvqPj23C+CiN0Ax9VJA1BYgaOKLXP2uYX3fTFbvweIE0Pim X-Received: by 2002:a05:6830:154c:: with SMTP id l12mr2610235otp.275.1576077295893; Wed, 11 Dec 2019 07:14:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576077295; cv=none; d=google.com; s=arc-20160816; b=ZiG1chHeh5uObl602Mnlr5pBxM3daKh7ObjUTlcZkLk5egeczBbo+m0a1VA8CL4Bev P9GBC0ISDwFSgIiD9E1OXd2SxM3jjRno2ZklksEtbXkldrzJp5F2vKbPmZQYaOsXbnmB mT/v4l3XQtWI/yYTH0ek0xVLyvLoWFDnCye77090pCdiF37Y11qNNAacripsvo9XGcbg lGWOcecZEjOgO7+ZuTuZs2qUKZAW8YMooMARI7u8+WGGEtQl9QF2psLbcNCCUq0NsvfF TMDCp4GfrKQx43dHqwmcgtEB1IgNRLIQI2QKVjkehRjY442UQtOgeKPGVnowq7ohMGZS fV6A== 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=P+gIatrO5y+SSRmfg5NphCJje2XnG4okGakrhm8yeWs=; b=jQTXIk9u7XvnZlkC+cZzOUwbMoVh6m+w5n8wdRy49SDV5NCgh5xN0gPTXrGycoMhf7 2CrO/6AhuIDO0tPFPOb78h9u8Drz2OMYWyl/Qc/BmtYzbcP5tVzHFcwQiX0E0nvA2Fvi Hu61wLtegHM/OcQr/XIrjtrhNGaC4gu2xyh7C2Lok2zV/9ss0BFx4/hH8nVvmn5H7NAu rSBayJRXbKnK5dwRCvvIDABGVitRv8sisMuo+ZzqeN8AXqS0EsKtC0iNtFlSF8ifxHYM ujlUEtwgWUs/ErcPnWYpYnRvurQccqQbuU7BNHU75VE76tl8u3Urx0LN4CEBpsU7sEPU T0dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BLyllEte; 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 d67si1323782oig.112.2019.12.11.07.14.43; Wed, 11 Dec 2019 07:14:55 -0800 (PST) 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=BLyllEte; 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 S1730461AbfLKPMZ (ORCPT + 99 others); Wed, 11 Dec 2019 10:12:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:33018 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731048AbfLKPMG (ORCPT ); Wed, 11 Dec 2019 10:12:06 -0500 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 BD5D1222C4; Wed, 11 Dec 2019 15:12:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576077126; bh=VPD4dyWy+JKVBUwjhXVuIu5XtWvfaTIKqFTi8EFeecE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BLyllEteWQVMePWLqSLFXyFDdevUZUqH1ubY4A1AVEPo+6wEymTLFuQDTXlcNqrv2 T4dSRrCkijgrZWtwSM0coSyx2mfZS8UvTOB1D95PvTG2xTJ9qYaQX4IyRaLdWjJQM3 F++68EvOL8SOxa3fYhHSeSDSiLjY6795fTmf35Ew= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaodong Xu , Bo Chen , Steffen Klassert , Sasha Levin Subject: [PATCH 5.3 026/105] xfrm: release device reference for invalid state Date: Wed, 11 Dec 2019 16:05:15 +0100 Message-Id: <20191211150229.289266937@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191211150221.153659747@linuxfoundation.org> References: <20191211150221.153659747@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: Xiaodong Xu [ Upstream commit 4944a4b1077f74d89073624bd286219d2fcbfce3 ] An ESP packet could be decrypted in async mode if the input handler for this packet returns -EINPROGRESS in xfrm_input(). At this moment the device reference in skb is held. Later xfrm_input() will be invoked again to resume the processing. If the transform state is still valid it would continue to release the device reference and there won't be a problem; however if the transform state is not valid when async resumption happens, the packet will be dropped while the device reference is still being held. When the device is deleted for some reason and the reference to this device is not properly released, the kernel will keep logging like: unregister_netdevice: waiting for ppp2 to become free. Usage count = 1 The issue is observed when running IPsec traffic over a PPPoE device based on a bridge interface. By terminating the PPPoE connection on the server end for multiple times, the PPPoE device on the client side will eventually get stuck on the above warning message. This patch will check the async mode first and continue to release device reference in async resumption, before it is dropped due to invalid state. v2: Do not assign address family from outer_mode in the transform if the state is invalid v3: Release device reference in the error path instead of jumping to resume Fixes: 4ce3dbe397d7b ("xfrm: Fix xfrm_input() to verify state is valid when (encap_type < 0)") Signed-off-by: Xiaodong Xu Reported-by: Bo Chen Tested-by: Bo Chen Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/xfrm/xfrm_input.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c index 6088bc2dc11e3..fcd4b1f36e669 100644 --- a/net/xfrm/xfrm_input.c +++ b/net/xfrm/xfrm_input.c @@ -480,6 +480,9 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type) else XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEINVALID); + + if (encap_type == -1) + dev_put(skb->dev); goto drop; } -- 2.20.1