Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp5850930ybn; Sun, 29 Sep 2019 07:04:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxHzYh5JelRNLEzot6ATuIqqhrZk4LIA8oi+CgORFQBCBG5pt9plXuLHJWaM7QFRwDLbIMb X-Received: by 2002:a17:906:65c2:: with SMTP id z2mr13418933ejn.31.1569765875156; Sun, 29 Sep 2019 07:04:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569765875; cv=none; d=google.com; s=arc-20160816; b=GBmw7rrU3ecrlaLo6m3MU5zGNjJzCnQLlPl5VoU4Qrdi95YgLLiU1SkbFcJs8vgNIL JV6HiSE2jC2cUHu6MdWLE1RYNKKKLVtoBBfnYTdaV5UCBEamKcUq7M5CevMBQ3B/Vot0 O9bRlYTB58lHiwjhGYm4y6ClDlx7pA0n3qvQ0Vj9+40UNEharHg8G8ZMaw/p3119jEij ZLAgSpzQPc4AjEG4nMhCRD89qyfVGYjHz1z+923fSD2+PYLJj1tU+eY4Z4wiOLYGx+JG W2Vq0KRNMNSQ7ymBarQHWjyf/m0e8ZsGQJdbW1eswrHlKlRp9oQ/CmCIOcGh+eTa7pOn 9jow== 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=wDUjV2QOKEezHQOX3JPTFgOnK/pcmacFg6OELfqm2Bg=; b=CSeRQ3pTCVabxqHqnvwG2c8ry2MjhkSvU17qk+xgxkZU0cQnKX/I7Ehyb6AMQ1Jc/5 AwzULw5WhcHTA7/6NclE2hYydaXeTPlY3WWv6puEeyzySKM1EB6Y5QMe/jfDGY6NQYFs E9E5xUbNL8axIk1gDFDW9h2ozqu0qVJogL6hDivyClzLY6VIunBxshee2PQnbKFv90WZ dA3ReUGXKOxrTjesPBnkK8vO3Qm7xZ5kL2eucSNwjyWJk9X5XtKoamVWiCeF+JTZd5XH rjaA0ia+Wmz2zMWqMkCvnW5+hRP2hoGfQoGzqxvt9CXha7LAF+Eial9U7o1x3QR1nyrD 5Cpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=v+FEns+u; 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 i24si2695108ejh.35.2019.09.29.07.04.08; Sun, 29 Sep 2019 07:04:35 -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=v+FEns+u; 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 S1729701AbfI2OCn (ORCPT + 99 others); Sun, 29 Sep 2019 10:02:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:45492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729662AbfI2OCm (ORCPT ); Sun, 29 Sep 2019 10:02:42 -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 C36E52082F; Sun, 29 Sep 2019 14:02:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569765761; bh=vB8PEykiLTpJVoylB+3/isI7qp+NEDMc4CvjjxdfpbI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v+FEns+uvSzJ3Pc+DP341+uhcgeg0XadkGt5XKlWYj4Sna3HXGHpAwL4gUyzkSef4 uyEAa0bxPZbksuZTj3wlwIoi+U240hXA9TfQ4luyDAqRtGClUIRH5/3/3ILGt+3pcc ePpJLIfDJMm6cDgjm+N/NQly5E2U4xuI1PJaaBUM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fernando Fernandez Mancera , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.2 42/45] netfilter: nft_socket: fix erroneous socket assignment Date: Sun, 29 Sep 2019 15:56:10 +0200 Message-Id: <20190929135033.655419389@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190929135024.387033930@linuxfoundation.org> References: <20190929135024.387033930@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: Fernando Fernandez Mancera [ Upstream commit 039b1f4f24ecc8493b6bb9d70b4b78750d1b35c2 ] The socket assignment is wrong, see skb_orphan(): When skb->destructor callback is not set, but skb->sk is set, this hits BUG(). Link: https://bugzilla.redhat.com/show_bug.cgi?id=1651813 Fixes: 554ced0a6e29 ("netfilter: nf_tables: add support for native socket matching") Signed-off-by: Fernando Fernandez Mancera Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nft_socket.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/netfilter/nft_socket.c b/net/netfilter/nft_socket.c index d7f3776dfd719..637ce3e8c575c 100644 --- a/net/netfilter/nft_socket.c +++ b/net/netfilter/nft_socket.c @@ -47,9 +47,6 @@ static void nft_socket_eval(const struct nft_expr *expr, return; } - /* So that subsequent socket matching not to require other lookups. */ - skb->sk = sk; - switch(priv->key) { case NFT_SOCKET_TRANSPARENT: nft_reg_store8(dest, inet_sk_transparent(sk)); @@ -66,6 +63,9 @@ static void nft_socket_eval(const struct nft_expr *expr, WARN_ON(1); regs->verdict.code = NFT_BREAK; } + + if (sk != skb->sk) + sock_gen_put(sk); } static const struct nla_policy nft_socket_policy[NFTA_SOCKET_MAX + 1] = { -- 2.20.1