Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp15662333rwd; Sun, 25 Jun 2023 22:44:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4IN5GNVP42PPkcEug0+BeIryt1McRPF/qQ50atldi6PXmxw5+j70QCgDUxD6GI7Labg/W9 X-Received: by 2002:a17:90a:7bc7:b0:262:ec71:b88f with SMTP id d7-20020a17090a7bc700b00262ec71b88fmr1887237pjl.25.1687758261168; Sun, 25 Jun 2023 22:44:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687758261; cv=none; d=google.com; s=arc-20160816; b=H6gsJEnBRfoQRXallhBdFD9qSK4hCT+ZiQs2BOsz49+jtwSlbLM6GZ4xczaFys1jw+ p5klTclJTeMIfqQUSFcsV+9wWPdS0aQTE8uLxvrGVLJAfZD2TAQxFuPpFjzGzb2b/wcs SCnh57o+fPwLudm5hNb5yw1Q9X+U2M3j7Ww0G3FK/diqc629qs7gvh6JDmf22SCL5Q5g Vqyy83G67PwO7wRy1J/jRsKmjKmXyMYkkpN4VDODNaE6cltfG9EJm3kkDaC4aqHMxli4 yjUkijypB+n3SB3KSjkPHTVJL6n9Wp7ba6kZX9KpXwVHjN7gQh179Ui2J3rSokwgbhmt T3LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:dkim-signature; bh=WvTDUE7jzjCtM4ERqmNGNQF0ZOQywyapP+ehoBQlBus=; fh=HRT9eT0YEF/EUQUGLhrGW5Th89tw5qSrBZbX22e3EUQ=; b=nu1ZlxfOgOijhsdFSftDops7kHmLYE9q7nJXhhIpwdOr5tByhW5xFgOuT7bcmNytsB tqh5W9BeRYkZ/PIsC7RHNuGeBavHLyE6F28jFMg5jDPb2DVjksYixW+JLYsWrhnI6crs fZFA0uPEctaOgONDGFVbrS3Ekndok0SoClcRAdXYBhGQvN/NPjU95CKe/hKqD5S2N1k6 /ikNXvs5r/W4Fle6A4trC58tmDMPGMgvRolM99RDB+AEAg3lJ7jp6jXBFSo+kcQYGieL TfKDn5R1cfNx6Zlh0t470ZRMVE9FXNWQBcH1BwiQG/rx+F3H+I3+bkk8qogXaYT2f0aQ dzGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@43-1.org header.s=2019 header.b="NUgI0vT/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=43-1.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s14-20020a170902a50e00b001a94b91f412si4031276plq.164.2023.06.25.22.44.09; Sun, 25 Jun 2023 22:44:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@43-1.org header.s=2019 header.b="NUgI0vT/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=43-1.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229761AbjFZFb0 (ORCPT + 99 others); Mon, 26 Jun 2023 01:31:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229727AbjFZFbY (ORCPT ); Mon, 26 Jun 2023 01:31:24 -0400 X-Greylist: delayed 500 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 25 Jun 2023 22:31:18 PDT Received: from tsukuyomi.43-1.org (tsukuyomi.43-1.org [116.203.33.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7D04E44; Sun, 25 Jun 2023 22:31:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=43-1.org; i=@43-1.org; q=dns/txt; s=2019; t=1687756972; h=from : to : cc : subject : in-reply-to : references : date : message-id : mime-version : content-type : from; bh=Eq4k6m+p07AiJXh4wBi2hik11r7Xs7nEHyzRzDKtkag=; b=NUgI0vT/PM49fItVgX9+3ne7CAVuWcZ2azz+OC2gdh6Z/z8WGBcH1Yxu2BP5PcWdcqbaD /2cSrI/nMbkSoBywV/4dBeAUV0gqTOjbhczJkf6pxtSL62RxONgXyONN7SdAses43lUD7iV 9/Z5rLIfcOgQKth2mnle3+GxAKmBBc0+kaNAMs41Hh0Z3k93LxJ9xKGiEaBrVxiD1ExMrIJ y5O1072Sec5G9Inj5ZmPRgiCY+uHJSP3D1fLaNi3CFNo0O1SIauQqfoQdDs3JgEYmD/bbGc Uso8ddxYK1WjsR7/f0mqNWy+5TEJ90jlzckIWBD65k4Ua3NzEF8ZLDS2pHtg== From: Matthias Maier To: Pablo Neira Ayuso Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, netfilter-devel@vger.kernel.org Subject: Re: Kernel oops with netfilter: nf_tables: incorrect error path handling with NFT_MSG_NEWRULE In-Reply-To: (Pablo Neira Ayuso's message of "Mon, 26 Jun 2023 01:05:41 +0200") References: <87cz1j5tof.fsf@43-1.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Date: Mon, 26 Jun 2023 00:22:51 -0500 Message-ID: <87ttuuajbo.fsf@43-1.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Pablo, Thanks a lot for the quick reponse! On Sun, Jun 25, 2023, at 18:05 CDT, Pablo Neira Ayuso wrote: > [...] > > Could you give a try to these two fixes on top? > > 26b5a5712eb8 netfilter: nf_tables: add NFT_TRANS_PREPARE_ERROR to deal with bound set/chain > 4bedf9eee016 netfilter: nf_tables: fix chain binding transaction logic These two patches alone were not enough, I had to apply the third patch you mentioned: > https://patchwork.ozlabs.org/project/netfilter-devel/patch/20230625224219.64876-1-pablo@netfilter.org/ With all three patches I do not run into the oops any more. Nevertheless, please find below a (somehwat minimal) reproducer. Loading this ruleset into nft_tables via $ nft -f reproducer.ruleset previously oopsed the kernel. Best, Matthias define guarded_ports = {ssh} table inet portknock { set clients_ipv4 { type ipv4_addr flags timeout } set candidates_ipv4 { type ipv4_addr . inet_service flags timeout } chain input { type filter hook input priority -10; policy accept; tcp dport 10001 add @candidates_ipv4 {ip saddr . 10002 timeout 1s} tcp dport 10002 ip saddr . tcp dport @candidates_ipv4 add @candidates_ipv4 {ip saddr . 10003 timeout 1s} tcp dport 10003 ip saddr . tcp dport @candidates_ipv4 add @candidates_ipv4 {ip saddr . 10004 timeout 1s} tcp dport 10004 ip saddr . tcp dport @candidates_ipv4 add @candidates_ipv4 {ip saddr . 10005 timeout 1s} tcp dport 10005 ip saddr . tcp dport @candidates_ipv4 add @clients_ipv4 {ip saddr timeout 600s} log prefix "Successful portknock: " tcp dport $guarded_ports ip saddr @clients_ipv4 counter accept tcp dport $guarded_ports ct state established,related counter accept tcp dport $guarded_ports reject with tcp reset } }