Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4588817pja; Thu, 21 Nov 2019 22:24:00 -0800 (PST) X-Google-Smtp-Source: APXvYqwYWY4ROsZ54gTGi1Tt8WjtoUdwUIJ8EK8lED+LPwU6M21wqXiW4i4QTGxbrIqL5ujRmHUK X-Received: by 2002:a17:907:371:: with SMTP id rs17mr19010171ejb.0.1574403840383; Thu, 21 Nov 2019 22:24:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574403840; cv=none; d=google.com; s=arc-20160816; b=NHEsMqdnhggNVC62+IN4g6pDLzGleZmXJUTKAL/+THpjsVF0SHlH3Kwe4ZK18le0Qn o/4YSvIAeUj8n6io39jRbNERrUYeG7157WeFzQiX3Sp14zaqAlgQZO3R6Nu5Gb4U1AM4 zVM3V1tPGzSXHxoOLGCvyPD2c8yRhghLe6db3dA8I2YT7pj52hLIvY7sgiGOjRrJe3sr YkTwhu4ZkFPSfZ42/5ow+p/bxR4NysV0PCKUu+BuRL3jMYLnqXO7PINP5PVLc2msQIqT qrQMmosNQ5BD/98Oafro/JhAXAvK2AeFwYPWnF4HvOWevlokoL85/Yt3X8zthT+VIVAZ UdyQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MMv7H6Ehbfg9pmEiZ5+sR1nkxb1Em14mSZTeEX+9Ks0=; b=J7iOpZC6fTD/BVZOnxJ2g5/FklSWQ+0M91zSmuw3o2RJhiIRFRgDniKTrhgah6aTeP mCIV5v0AmiGl7ugnZxPqy/OfMjpsbztBioH2I+wgoa1YWJC9/ShwO1jZ64rpflLBFX0G /d6Dwjp2d/fDlvrlaEeOOkmzp3snoGdeDoSNLwl2abAUAJqwU+phde14Dqckbomeq57m 9pvxF5JGIjX3h+9qdDyL9cK3TWgoyTOPdm9wlgtN36VQSVAgDOagZ0Vm6Ffz75ZZFacT vmXtMva8zK9G39rub7RAAm4QtXdZbt2XQXKCTpUc5gv+w5J3XQucr4xtBWDa0Aib/93Y iscg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lxg4wGct; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b17si703476edj.417.2019.11.21.22.23.12; Thu, 21 Nov 2019 22:24:00 -0800 (PST) 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=lxg4wGct; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729256AbfKVGVF (ORCPT + 99 others); Fri, 22 Nov 2019 01:21:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:58216 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728543AbfKVFw2 (ORCPT ); Fri, 22 Nov 2019 00:52:28 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4972A2071B; Fri, 22 Nov 2019 05:52:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574401948; bh=P5MK6TYywY9tI5CraYsnaK8zbolAgZwzdiJIM/eB5SE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lxg4wGctMrUlUAQrKpEu32Ci0OwLbqGALtWSoo184QaMH2ohO6C0ZJT3WMRmz52dH xPBMyW4El4ahCvsT5eme5xdSXAphxC3SZvBAqpOqZ7dVwChap6iW7g886V0fC9rTtd x2PIX3Ycm9kQrgBvtCsDP7zc35qz8gIczDnlx4yo= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Konstantin Khlebnikov , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 171/219] net/core/neighbour: tell kmemleak about hash tables Date: Fri, 22 Nov 2019 00:48:23 -0500 Message-Id: <20191122054911.1750-164-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122054911.1750-1-sashal@kernel.org> References: <20191122054911.1750-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Konstantin Khlebnikov [ Upstream commit 85704cb8dcfd88d351bfc87faaeba1c8214f3177 ] This fixes false-positive kmemleak reports about leaked neighbour entries: unreferenced object 0xffff8885c6e4d0a8 (size 1024): comm "softirq", pid 0, jiffies 4294922664 (age 167640.804s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 20 2c f3 83 ff ff ff ff ........ ,...... 08 c0 ef 5f 84 88 ff ff 01 8c 7d 02 01 00 00 00 ..._......}..... backtrace: [<00000000748509fe>] ip6_finish_output2+0x887/0x1e40 [<0000000036d7a0d8>] ip6_output+0x1ba/0x600 [<0000000027ea7dba>] ip6_send_skb+0x92/0x2f0 [<00000000d6e2111d>] udp_v6_send_skb.isra.24+0x680/0x15e0 [<000000000668a8be>] udpv6_sendmsg+0x18c9/0x27a0 [<000000004bd5fa90>] sock_sendmsg+0xb3/0xf0 [<000000008227b29f>] ___sys_sendmsg+0x745/0x8f0 [<000000008698009d>] __sys_sendmsg+0xde/0x170 [<00000000889dacf1>] do_syscall_64+0x9b/0x400 [<0000000081cdb353>] entry_SYSCALL_64_after_hwframe+0x49/0xbe [<000000005767ed39>] 0xffffffffffffffff Signed-off-by: Konstantin Khlebnikov Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/core/neighbour.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/net/core/neighbour.c b/net/core/neighbour.c index c52d6e6b341cf..4721793babed5 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -18,6 +18,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include #include #include @@ -363,12 +364,14 @@ static struct neigh_hash_table *neigh_hash_alloc(unsigned int shift) ret = kmalloc(sizeof(*ret), GFP_ATOMIC); if (!ret) return NULL; - if (size <= PAGE_SIZE) + if (size <= PAGE_SIZE) { buckets = kzalloc(size, GFP_ATOMIC); - else + } else { buckets = (struct neighbour __rcu **) __get_free_pages(GFP_ATOMIC | __GFP_ZERO, get_order(size)); + kmemleak_alloc(buckets, size, 0, GFP_ATOMIC); + } if (!buckets) { kfree(ret); return NULL; @@ -388,10 +391,12 @@ static void neigh_hash_free_rcu(struct rcu_head *head) size_t size = (1 << nht->hash_shift) * sizeof(struct neighbour *); struct neighbour __rcu **buckets = nht->hash_buckets; - if (size <= PAGE_SIZE) + if (size <= PAGE_SIZE) { kfree(buckets); - else + } else { + kmemleak_free(buckets); free_pages((unsigned long)buckets, get_order(size)); + } kfree(nht); } -- 2.20.1