Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp989497pxv; Fri, 25 Jun 2021 03:01:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/DwqTyeBE+2xwxmAahNAaB9W7EetsbfxeiDvG4F6YIt4aGwL/q+nna7iwffcfC2iMQ8ib X-Received: by 2002:a17:907:7662:: with SMTP id kk2mr9825409ejc.218.1624615259726; Fri, 25 Jun 2021 03:00:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624615259; cv=none; d=google.com; s=arc-20160816; b=vpuEGkweHDFs2qJcyz5np0plX+R11woJP81N+IoMe7CWu8dpV6l/gHEkIwjmHqVdT3 QnK/dd8VhMgsoXkB5OFXpQvontN/idlJ2EoaQ/ouZt0DqV2OrR8HOA531tGTGPOG7krN ccdwX7hcjExrocEwSNXnL7W4Tsre0bH+BI9rsu/J25+d0CvBxShWs3mdRFyYtWGNalEK kibrGeKF+u6Ouc3/SrXwnmZurKXctfXIeH2Oht8mwQFZN9v+KE4FXJi+g43g5oCMPKxN 2NM7X4l+8o35zYqlmjGtZiFZrgPqb8W3bfCrIloMdMdqgy73Oo7Ox4Y+a6Vbr6nwXwfn n0Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=qFPjxinxMtQeDj5/w8/lqotDJyc/wyG/gK8nNVr0yw0=; b=zL89EbnGBfCZkTSLCY2M/KMnwxikQB5+5hx8t7vbSooJ1eGf5sxBqNr4FrJ6cKte9z dpbrcJS/jBN3nwPgIwUcuG6gbjDZHn81Tvv1sXobHpattmZuxIaXod8713OFQguOtdQS LShsoOoRK3F4jtbBVkFIav18e6O/E7YhgqR14KtLQlBYe4htcq60pHXPn1hhUuFnesFJ GPsojC2OodmdXJZzX2fZy/Gk6mcyp3O2GN8Rg5MNwMsnLeleJ4ecDDQwkDG/ddPDaFa7 snrKmyYNDciB2VaqGmR3Z+wLa00xuLhuK78ZmA2vWhHDw3uPuc4GPIbjbztl7kcuj9Z2 IekA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=uJdik+PZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i4si5273544ejo.162.2021.06.25.03.00.35; Fri, 25 Jun 2021 03:00:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=uJdik+PZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231139AbhFYKBv (ORCPT + 99 others); Fri, 25 Jun 2021 06:01:51 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:52052 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229902AbhFYKBu (ORCPT ); Fri, 25 Jun 2021 06:01:50 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15P9oTUp015650; Fri, 25 Jun 2021 09:59:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=qFPjxinxMtQeDj5/w8/lqotDJyc/wyG/gK8nNVr0yw0=; b=uJdik+PZbr0cXt46QpIU1NlJvNEA9NH4vJQFNEhW6nHO7lgNIo84Z1Spk3b1O3pCjsF8 T7PgCmL6JT6ahh+oFtbrjRS5ojzNTm0WeOpLiEdSZD2di+Vtc1QmIYUkVTsqmGVeh2Tr pPYXa3LJbEc2Cnz+ogSGyXZve75BSvNuZY9O3Ld25llB1ywkNx30UChCrlCvC2x4Bail AvGsavJ8v/p81akP0dxNjPCHV1ESsuTEf+NwDaNRt/z+k1TRCxZb5ItC1hjN4c1k5t2N mP9qO33TXHbhRhUKARb6CUtpCRxRmtQI6KmeiK85Gb2mCKT4euVSfX8JAjUfPPbH2ENw TA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 39d24a9112-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Jun 2021 09:59:14 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 15P9tOME097326; Fri, 25 Jun 2021 09:59:13 GMT Received: from pps.reinject (localhost [127.0.0.1]) by userp3030.oracle.com with ESMTP id 39d23xtvmf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Jun 2021 09:59:13 +0000 Received: from userp3030.oracle.com (userp3030.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 15P9xCMl109076; Fri, 25 Jun 2021 09:59:12 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 39d23xtvm1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Jun 2021 09:59:12 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 15P9x9M7007589; Fri, 25 Jun 2021 09:59:09 GMT Received: from kadam (/102.222.70.252) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 25 Jun 2021 09:59:09 +0000 Date: Fri, 25 Jun 2021 12:59:01 +0300 From: Dan Carpenter To: Colin King Cc: Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S . Miller" , Jakub Kicinski , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH][next] netfilter: nf_tables: Fix dereference of null pointer flow Message-ID: <20210625095901.GH2040@kadam> References: <20210624195718.170796-1-colin.king@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210624195718.170796-1-colin.king@canonical.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-GUID: bi0xJpBda37N-dmz3NNMc3-XuxtaYumR X-Proofpoint-ORIG-GUID: bi0xJpBda37N-dmz3NNMc3-XuxtaYumR Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Btw, why is there no clean up if nft_table_validate() fails? net/netfilter/nf_tables_api.c 3432 list_add_tail_rcu(&rule->list, &old_rule->list); 3433 else 3434 list_add_rcu(&rule->list, &chain->rules); 3435 } 3436 } 3437 kvfree(expr_info); 3438 chain->use++; 3439 3440 if (flow) 3441 nft_trans_flow_rule(trans) = flow; 3442 3443 if (nft_net->validate_state == NFT_VALIDATE_DO) 3444 return nft_table_validate(net, table); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The cleanup for this would be quite involved unfortunately... Not necessarily something to attempt without being able to test the code. 3445 3446 return 0; 3447 3448 err_destroy_flow_rule: 3449 nft_flow_rule_destroy(flow); 3450 err_release_rule: 3451 nf_tables_rule_release(&ctx, rule); 3452 err_release_expr: 3453 for (i = 0; i < n; i++) { 3454 if (expr_info[i].ops) { 3455 module_put(expr_info[i].ops->type->owner); 3456 if (expr_info[i].ops->type->release_ops) 3457 expr_info[i].ops->type->release_ops(expr_info[i].ops); 3458 } 3459 } 3460 kvfree(expr_info); 3461 3462 return err; 3463 } regards, dan carpenter