Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1416551imm; Thu, 5 Jul 2018 23:01:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd+CJ1MSav3hyT5RCFr4te6xQ/wSymul/7U6SmThIgARN8AC0NFpW/q164TcE76W6mQMiwl X-Received: by 2002:a62:a50e:: with SMTP id v14-v6mr9298372pfm.121.1530856862585; Thu, 05 Jul 2018 23:01:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530856862; cv=none; d=google.com; s=arc-20160816; b=DWWyZxTyG8WZgEPFK2elNy4pqbjYFUifRuELfl6OGXUm4TOb9atlJsglzhT8mDjNp6 p7zm+9+m3f2n64yREoN6/DNznradEfH4NLdEZ8otfYOO/T1V373xrwarUlfnMfo5Q/zw S/A0veN9+y8qUmwdjUfFBJLctkBWJk3bligGeqF9HzIYLsNFzdgCQIIL+fC8CLHIiSq5 Ib1t8IDP3IgLy53YDD8gAiOZSvLSx8C2zF6/aJn/SOidsbfEu56hrcdcAd9rGZT1pWQg kTgXR10eAkoYe3qLW5uob8WuKxO29Bl+4H0/BjK9Ib633tKQAwOc+0zTUk1eryENXeo+ 7iIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=y+8QFEvkPG1Lr7w88FOkNI1r3L2BnTy6C7ZLKK6lQOI=; b=UkOpG3e6YzkBQmsfEOrLg07HYWWAsFxGfOtmFkYBxgwvY4hwKu/apfCzeWlnIBcQE8 e1PiDE9m5zMy0DhQhTKZO5vy2GYCYPhPt+ky8X41oG4ksqp4FGYB66eMhrOJ1QfN56Oq fVlov7raTS1SnI80amLj4Ori9Q9rphkJYORn6qXgt4EF90vFeyQwMQ7qSGm9bN4EJbZs 1FpKFI8Lzc1JQqrgc1vs3s1mStdXDUTKnFXdrXvlEbIW+8w1XpmeTcHvkddldgylmBYy JZ9gCZnvhMzoqxYt47WtMBoTELoSDoKgqJr0QNYHn86rdJ0ocTgx4eUAKFqlHT1QpMPz /GMA== ARC-Authentication-Results: i=1; mx.google.com; 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 k18-v6si7040014pgl.364.2018.07.05.23.00.48; Thu, 05 Jul 2018 23:01:02 -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; 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 S934192AbeGFFvP (ORCPT + 99 others); Fri, 6 Jul 2018 01:51:15 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33218 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933516AbeGFFvM (ORCPT ); Fri, 6 Jul 2018 01:51:12 -0400 Received: from localhost (D57D388D.static.ziggozakelijk.nl [213.125.56.141]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B02FBBC6; Fri, 6 Jul 2018 05:51:11 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , Florian Westphal , Pablo Neira Ayuso Subject: [PATCH 4.14 33/61] netfilter: nf_tables: fix NULL-ptr in nf_tables_dump_obj() Date: Fri, 6 Jul 2018 07:46:57 +0200 Message-Id: <20180706054713.603352386@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180706054712.332416244@linuxfoundation.org> References: <20180706054712.332416244@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Taehee Yoo commit 360cc79d9d299ce297b205508276285ceffc5fa8 upstream. The table field in nft_obj_filter is not an array. In order to check tablename, we should check if the pointer is set. Test commands: %nft add table ip filter %nft add counter ip filter ct1 %nft reset counters Splat looks like: [ 306.510504] kasan: CONFIG_KASAN_INLINE enabled [ 306.516184] kasan: GPF could be caused by NULL-ptr deref or user memory access [ 306.524775] general protection fault: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN PTI [ 306.528284] Modules linked in: nft_objref nft_counter nf_tables nfnetlink ip_tables x_tables [ 306.528284] CPU: 0 PID: 1488 Comm: nft Not tainted 4.17.0-rc4+ #17 [ 306.528284] Hardware name: To be filled by O.E.M. To be filled by O.E.M./Aptio CRB, BIOS 5.6.5 07/08/2015 [ 306.528284] RIP: 0010:nf_tables_dump_obj+0x52c/0xa70 [nf_tables] [ 306.528284] RSP: 0018:ffff8800b6cb7520 EFLAGS: 00010246 [ 306.528284] RAX: 0000000000000000 RBX: ffff8800b6c49820 RCX: 0000000000000000 [ 306.528284] RDX: 0000000000000000 RSI: dffffc0000000000 RDI: ffffed0016d96e9a [ 306.528284] RBP: ffff8800b6cb75c0 R08: ffffed00236fce7c R09: ffffed00236fce7b [ 306.528284] R10: ffffffff9f6241e8 R11: ffffed00236fce7c R12: ffff880111365108 [ 306.528284] R13: 0000000000000000 R14: ffff8800b6c49860 R15: ffff8800b6c49860 [ 306.528284] FS: 00007f838b007700(0000) GS:ffff88011b600000(0000) knlGS:0000000000000000 [ 306.528284] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 306.528284] CR2: 00007ffeafabcf78 CR3: 00000000b6cbe000 CR4: 00000000001006f0 [ 306.528284] Call Trace: [ 306.528284] netlink_dump+0x470/0xa20 [ 306.528284] __netlink_dump_start+0x5ae/0x690 [ 306.528284] ? nf_tables_getobj+0x1b3/0x740 [nf_tables] [ 306.528284] nf_tables_getobj+0x2f5/0x740 [nf_tables] [ 306.528284] ? nft_obj_notify+0x100/0x100 [nf_tables] [ 306.528284] ? nf_tables_getobj+0x740/0x740 [nf_tables] [ 306.528284] ? nf_tables_dump_flowtable_done+0x70/0x70 [nf_tables] [ 306.528284] ? nft_obj_notify+0x100/0x100 [nf_tables] [ 306.528284] nfnetlink_rcv_msg+0x8ff/0x932 [nfnetlink] [ 306.528284] ? nfnetlink_rcv_msg+0x216/0x932 [nfnetlink] [ 306.528284] netlink_rcv_skb+0x1c9/0x2f0 [ 306.528284] ? nfnetlink_bind+0x1d0/0x1d0 [nfnetlink] [ 306.528284] ? debug_check_no_locks_freed+0x270/0x270 [ 306.528284] ? netlink_ack+0x7a0/0x7a0 [ 306.528284] ? ns_capable_common+0x6e/0x110 [ ... ] Fixes: e46abbcc05aa8 ("netfilter: nf_tables: Allow table names of up to 255 chars") Signed-off-by: Taehee Yoo Acked-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Florian Westphal Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_tables_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -4614,7 +4614,7 @@ static int nf_tables_dump_obj(struct sk_ if (idx > s_idx) memset(&cb->args[1], 0, sizeof(cb->args) - sizeof(cb->args[0])); - if (filter && filter->table[0] && + if (filter && filter->table && strcmp(filter->table, table->name)) goto cont; if (filter &&