Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3929652imm; Mon, 8 Oct 2018 11:51:48 -0700 (PDT) X-Google-Smtp-Source: ACcGV60kSf+rFRMwfKHtsVdyjPVFlEfyikjtbdivdwcW+Wbh/pH0sPAbuVpHSBUR6nwq0cXIwZ8V X-Received: by 2002:a63:1c64:: with SMTP id c36-v6mr21739923pgm.354.1539024707975; Mon, 08 Oct 2018 11:51:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539024707; cv=none; d=google.com; s=arc-20160816; b=FnXCL/1Zv5itq5ZIeX5AFnJDSE3MZejaO2Sw2xdphW5UAaCQ0UBFYfKM0AZi6aY7xE sFKt+tBeKtwfZfer2TsfH3egKw4Y/8veEbQ4z5oCaN84rznaBJ+gS/Oget5KQn4gVkjF ByvTO+7KG9YpQCt9RcSbFrhcISzj811uvf3GeA/ZeEU9eF9k1ypfDu3ycEyKRgwt9oBC gyDlLhLIG0tLiAKokMOsMbSf7P+SDuplcL2/Is2PSFio+RIYXttUi6782VhSf/o1hUoF qcdt5cSzJpxVtMSapTcFYbgIcX1pG8C+lC8fs2L2zWaytdeHGJG03x41YR+xm/kVW86q rWTQ== 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=E9l2LsnPgy4CgdgLIep6Q+OaJtyks8LtyOcXSxOcoQU=; b=nTIwDesazuHmy0AmzvEcCQ5lelRddJouKeuDsZc+PiR/95BI/ObwCe/Ie6mE7AGC7s tVrsKBjc35LAO8bJAzwWeD+5sHjEeOobzGgQS3MEjVcmgbWQR5feXLQXeo0/99uVRdSy kE9NEATLKCA2E1sGLS4II+e4vpmmQSc2mEQIJup1/ACw+mXnIkug8/TeaTjomHOvVpi/ dOxqg0UpgvcTlsgjDMyYmxtzYz4y+AXE+N8VCSFVW87Nxba5pJj1qje1f2blsKBwxty3 rs48a8q8rQ9gICe4tonEh26yuB4E6xwJDA6iIIu15QKj/9ZOjw1T8nhuq8kJYUfR3Dkv 8iaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mVbpFB5G; 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 g5-v6si13899265pgl.419.2018.10.08.11.51.33; Mon, 08 Oct 2018 11:51:47 -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=mVbpFB5G; 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 S1732024AbeJICDQ (ORCPT + 99 others); Mon, 8 Oct 2018 22:03:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:52706 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726391AbeJICDQ (ORCPT ); Mon, 8 Oct 2018 22:03:16 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (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 0E65A21479; Mon, 8 Oct 2018 18:50:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024608; bh=BGcGgymoOxRCFnvvFmj34I4jSpv+j2laMYU7mhdLnD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mVbpFB5GwOyI7NTvvpQPgrpT24uSKByo6JGlQ9UARjgSaduAZVR7ZCF0+ZaW6pz8j elYDsMEJzKNjxkw0nJHYKYAPw22VtbACVjQrsBMjSvyOmLqUUqYVNhT6T5F4Td9ryA V+giDw8wPzvXTZelc1dy6Unl8IscNNbtAv9TuRIM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.18 095/168] netfilter: nf_tables: release chain in flushing set Date: Mon, 8 Oct 2018 20:31:15 +0200 Message-Id: <20181008175623.673426930@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175620.043587728@linuxfoundation.org> References: <20181008175620.043587728@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Taehee Yoo [ Upstream commit 7acfda539c0b9636a58bfee56abfb3aeee806d96 ] When element of verdict map is deleted, the delete routine should release chain. however, flush element of verdict map routine doesn't release chain. test commands: %nft add table ip filter %nft add chain ip filter c1 %nft add map ip filter map1 { type ipv4_addr : verdict \; } %nft add element ip filter map1 { 1 : jump c1 } %nft flush map ip filter map1 %nft flush ruleset splat looks like: [ 4895.170899] kernel BUG at net/netfilter/nf_tables_api.c:1415! [ 4895.178114] invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN PTI [ 4895.178880] CPU: 0 PID: 1670 Comm: nft Not tainted 4.18.0+ #55 [ 4895.178880] RIP: 0010:nf_tables_chain_destroy.isra.28+0x39/0x220 [nf_tables] [ 4895.178880] Code: fc ff df 53 48 89 fb 48 83 c7 50 48 89 fa 48 c1 ea 03 0f b6 04 02 84 c0 74 09 3c 03 7f 05 e8 3e 4c 25 e1 8b 43 50 85 c0 74 02 <0f> 0b 48 89 da 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03 80 3c 02 [ 4895.228342] RSP: 0018:ffff88010b98f4c0 EFLAGS: 00010202 [ 4895.234841] RAX: 0000000000000001 RBX: ffff8801131c6968 RCX: ffff8801146585b0 [ 4895.234841] RDX: 1ffff10022638d37 RSI: ffff8801191a9348 RDI: ffff8801131c69b8 [ 4895.234841] RBP: ffff8801146585a8 R08: 1ffff1002323526a R09: 0000000000000000 [ 4895.234841] R10: 0000000000000000 R11: 0000000000000000 R12: dead000000000200 [ 4895.234841] R13: dead000000000100 R14: ffffffffa3638af8 R15: dffffc0000000000 [ 4895.234841] FS: 00007f6d188e6700(0000) GS:ffff88011b600000(0000) knlGS:0000000000000000 [ 4895.234841] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 4895.234841] CR2: 00007ffe72b8df88 CR3: 000000010e2d4000 CR4: 00000000001006f0 [ 4895.234841] Call Trace: [ 4895.234841] nf_tables_commit+0x2704/0x2c70 [nf_tables] [ 4895.234841] ? nfnetlink_rcv_batch+0xa4f/0x11b0 [nfnetlink] [ 4895.234841] ? nf_tables_setelem_notify.constprop.48+0x1a0/0x1a0 [nf_tables] [ 4895.323824] ? __lock_is_held+0x9d/0x130 [ 4895.323824] ? kasan_unpoison_shadow+0x30/0x40 [ 4895.333299] ? kasan_kmalloc+0xa9/0xc0 [ 4895.333299] ? kmem_cache_alloc_trace+0x2c0/0x310 [ 4895.333299] ? nfnetlink_rcv_batch+0xa4f/0x11b0 [nfnetlink] [ 4895.333299] nfnetlink_rcv_batch+0xdb9/0x11b0 [nfnetlink] [ 4895.333299] ? debug_show_all_locks+0x290/0x290 [ 4895.333299] ? nfnetlink_net_init+0x150/0x150 [nfnetlink] [ 4895.333299] ? sched_clock_cpu+0xe5/0x170 [ 4895.333299] ? sched_clock_local+0xff/0x130 [ 4895.333299] ? sched_clock_cpu+0xe5/0x170 [ 4895.333299] ? find_held_lock+0x39/0x1b0 [ 4895.333299] ? sched_clock_local+0xff/0x130 [ 4895.333299] ? memset+0x1f/0x40 [ 4895.333299] ? nla_parse+0x33/0x260 [ 4895.333299] ? ns_capable_common+0x6e/0x110 [ 4895.333299] nfnetlink_rcv+0x2c0/0x310 [nfnetlink] [ ... ] Fixes: 591054469b3e ("netfilter: nf_tables: revisit chain/object refcounting from elements") Signed-off-by: Taehee Yoo Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_tables_api.c | 1 + 1 file changed, 1 insertion(+) --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -4582,6 +4582,7 @@ static int nft_flush_set(const struct nf } set->ndeact++; + nft_set_elem_deactivate(ctx->net, set, elem); nft_trans_elem_set(trans) = set; nft_trans_elem(trans) = *elem; list_add_tail(&trans->list, &ctx->net->nft.commit_list);