Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3667319pxv; Mon, 26 Jul 2021 09:02:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1xMECmJgoATcqjmtEDmHGM1PQeFu4xC8R18lJui+7SYzo0ITdPi2j+eXDy3gigoZOjjY3 X-Received: by 2002:a05:6402:430b:: with SMTP id m11mr3121594edc.55.1627315379660; Mon, 26 Jul 2021 09:02:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627315379; cv=none; d=google.com; s=arc-20160816; b=IELk7ouan4krBfW6IX0xgvup5LCJfrlR64INP9KE3k51+pPDqS5TS/OxEsGH/EUh3N ruJ0iAW2HE0yupj4pe4/s4sisLS6PllBTPxAjRKVQslIJR/GveJrMjdooRpnw0WXlktL My9fu8wqiIYgYbdXtTmochxk/2mEjqPqCActhTRKp1iv6YHq6WZyIFIGL6RdeVcxhGeq btG0lJRx/3pVgID5iGmrSyKUlqQsKeBe/sa/6VtCMmFqiYJJt4eedHiQhb4dhFuEynoo lXiIGdP2VDJLywEoNQ3MVpwVVNltAI9drBf0B5MNRnbUq/EQfQ+YlUGl3cVwvsEzXESZ XC6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/wCsmQup114czrzKcB1d+cnNSbLvz0RV1iCwPU9h0r0=; b=oLx4PSbw8+F0ha8ycZicYPN3DmD5n3XBeb3VdqVdCD7UKUjm4kZmnjAHUigNwqB6IV /X12FSm4tYuV6Yco9L1wTKcgOe7N3AqGOXI2Wr+GIPh98jRKkvKbskvf88qiB7Xx33EV r5NlCPwIy3famIh/+/65yOMIBcrLaWbapyFxZ8pyd5uTRUfj89jUcO/32yQAbl9QYMHf 1B/vNFjv8wDENwNK/67VxiW1WsTdkKMDUEoOCsVm95QbxqK4WhdAURJn8yOQm7voAynO pILRyemJOuAg/6knN2NjyhWyQ95Ip7sQP+9f4lIFtJUkknqIcKPzj7p6ikNBPAVUkw3o GI5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CnPCY7D0; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h13si298261ede.550.2021.07.26.09.02.35; Mon, 26 Jul 2021 09:02: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=@linuxfoundation.org header.s=korg header.b=CnPCY7D0; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236459AbhGZPSV (ORCPT + 99 others); Mon, 26 Jul 2021 11:18:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:50732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237039AbhGZPKL (ORCPT ); Mon, 26 Jul 2021 11:10:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8DE456056C; Mon, 26 Jul 2021 15:50:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627314640; bh=Qw19aLmwjbQ/wEhpzwi7cscgJrpLdQ4eDTm33qriIX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CnPCY7D0NWk9rnjlh6b7ezPlRHeRmM7ZJtLD31y9OsHyrucRNtEXLEfXaGZoRTwzZ r4eymg9xvcddVciJv0HwrOs+Vc9VtOJ4xKhBJSwnRXUemedtAhxVSLczeqawpJ3iUo jDuX5cqjcC//ogXoRZaFLRpVCdLT4cR6N3VfLUg4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vasily Averin , Florian Westphal , Pablo Neira Ayuso Subject: [PATCH 4.19 039/120] netfilter: ctnetlink: suspicious RCU usage in ctnetlink_dump_helpinfo Date: Mon, 26 Jul 2021 17:38:11 +0200 Message-Id: <20210726153833.649863937@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153832.339431936@linuxfoundation.org> References: <20210726153832.339431936@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vasily Averin commit c23a9fd209bc6f8c1fa6ee303fdf037d784a1627 upstream. Two patches listed below removed ctnetlink_dump_helpinfo call from under rcu_read_lock. Now its rcu_dereference generates following warning: ============================= WARNING: suspicious RCU usage 5.13.0+ #5 Not tainted ----------------------------- net/netfilter/nf_conntrack_netlink.c:221 suspicious rcu_dereference_check() usage! other info that might help us debug this: rcu_scheduler_active = 2, debug_locks = 1 stack backtrace: CPU: 1 PID: 2251 Comm: conntrack Not tainted 5.13.0+ #5 Call Trace: dump_stack+0x7f/0xa1 ctnetlink_dump_helpinfo+0x134/0x150 [nf_conntrack_netlink] ctnetlink_fill_info+0x2c2/0x390 [nf_conntrack_netlink] ctnetlink_dump_table+0x13f/0x370 [nf_conntrack_netlink] netlink_dump+0x10c/0x370 __netlink_dump_start+0x1a7/0x260 ctnetlink_get_conntrack+0x1e5/0x250 [nf_conntrack_netlink] nfnetlink_rcv_msg+0x613/0x993 [nfnetlink] netlink_rcv_skb+0x50/0x100 nfnetlink_rcv+0x55/0x120 [nfnetlink] netlink_unicast+0x181/0x260 netlink_sendmsg+0x23f/0x460 sock_sendmsg+0x5b/0x60 __sys_sendto+0xf1/0x160 __x64_sys_sendto+0x24/0x30 do_syscall_64+0x36/0x70 entry_SYSCALL_64_after_hwframe+0x44/0xae Fixes: 49ca022bccc5 ("netfilter: ctnetlink: don't dump ct extensions of unconfirmed conntracks") Fixes: 0b35f6031a00 ("netfilter: Remove duplicated rcu_read_lock.") Signed-off-by: Vasily Averin Reviewed-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_conntrack_netlink.c | 3 +++ 1 file changed, 3 insertions(+) --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c @@ -213,6 +213,7 @@ static int ctnetlink_dump_helpinfo(struc if (!help) return 0; + rcu_read_lock(); helper = rcu_dereference(help->helper); if (!helper) goto out; @@ -228,9 +229,11 @@ static int ctnetlink_dump_helpinfo(struc nla_nest_end(skb, nest_helper); out: + rcu_read_unlock(); return 0; nla_put_failure: + rcu_read_unlock(); return -1; }