Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp577311img; Fri, 22 Mar 2019 04:24:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqypyl9RAznvrg2jDIVRVrEZXrxsMYJW66+YuBWx5dA+hPeYu1LSBHBJfFu8i7GUKTqTWGkx X-Received: by 2002:a62:a219:: with SMTP id m25mr8614092pff.197.1553253865421; Fri, 22 Mar 2019 04:24:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553253865; cv=none; d=google.com; s=arc-20160816; b=unY66KquOpfP0nnB+RqMSvsJiYgEF5xNwVduYq9PSawozRS/i7cvaQS+601ptgAtf1 7Q1ClNblJO+FmFkFUXk3/5guh/p+DOQFSa+XZkX8nhQlpUTJe8e5xX4QH0BMJVXcmmHm Ba+6RjX2Mn0pd3As+U5NlqLgrJHTwzC+jpKLch4lYkUxfz67KIm4iBlAN8HiebJDd6eN ZPuDWVAL4ZqLrN7aXWTXbLrdpytmE0uOY+U9BaYEGXFNNvk1qlwySz8ptY1Zc5M++RMB WDB3NvI3lIphnB9LjRr6XnHYppEZeP39Mz/icMVNl4aNxoO6qetQTqVkaS48SHdF1+XU uv+g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=usnd8a4JbD3tx+xW/+LvOvapJhc89wMDBBK9h1qKAEQ=; b=ewOPBR4JT7pMalgNncsJrL/9mehvoDTKIitEGOiYmOeg3r8m0/Sy1Grg0wMdq23BZM NjUWcS4iKugp+sIxNWX0g5GZs9jyvCd4qj0QfhQsu7Az0bnrCx1NWgsrKreX1yCWN+D+ 52lMD5xanDFN/sJH54sDOndkn+9Btjl/bI/sCwcuF9R7+fLqHHEY1PoJ6DIZAVu1RjOP SaAN1aPwtZOpnR2vn7d0KG7sFNqx7hM36mzwo5M9vhMDw9ieUiqkXampAJSRn4WWy77V ZZfgrgLXExSc9rV4TkQFG55jT5vjjo3Cts2Qx6rEpvtrP1icFHufmUNBOqE7+jtTq+fx 6O6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=F09pd14u; 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 z11si6693766pgc.145.2019.03.22.04.24.06; Fri, 22 Mar 2019 04:24:25 -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; dkim=pass header.i=@kernel.org header.s=default header.b=F09pd14u; 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 S1728836AbfCVLWg (ORCPT + 99 others); Fri, 22 Mar 2019 07:22:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:49280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728808AbfCVLWb (ORCPT ); Fri, 22 Mar 2019 07:22:31 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C5C9F218D4; Fri, 22 Mar 2019 11:22:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553253751; bh=lHP5V2AX/du/Qwilwc+t3bOPrAJFhuRg0pISt1gb4ks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F09pd14uh1KWwhb24mf5Fdeg5b3Guj/cCZeqrP6cSpeTcbom7U5ZIuaOBZcyUeihZ 0REbrfKk6XrdnprtxsuvER33db2V5xc5kzkKfdxb5NSj9hrpennk/o5xtB86G+ZDkX uAQoRmDLwKDikKbCcy5h1Ls3lYuidlAporhJcR0E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , YueHaibing , "David S. Miller" Subject: [PATCH 3.18 044/134] net-sysfs: Fix mem leak in netdev_register_kobject Date: Fri, 22 Mar 2019 12:14:17 +0100 Message-Id: <20190322111213.084688100@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111210.465931067@linuxfoundation.org> References: <20190322111210.465931067@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: YueHaibing [ Upstream commit 895a5e96dbd6386c8e78e5b78e067dcc67b7f0ab ] syzkaller report this: BUG: memory leak unreferenced object 0xffff88837a71a500 (size 256): comm "syz-executor.2", pid 9770, jiffies 4297825125 (age 17.843s) hex dump (first 32 bytes): 00 00 00 00 ad 4e ad de ff ff ff ff 00 00 00 00 .....N.......... ff ff ff ff ff ff ff ff 20 c0 ef 86 ff ff ff ff ........ ....... backtrace: [<00000000db12624b>] netdev_register_kobject+0x124/0x2e0 net/core/net-sysfs.c:1751 [<00000000dc49a994>] register_netdevice+0xcc1/0x1270 net/core/dev.c:8516 [<00000000e5f3fea0>] tun_set_iff drivers/net/tun.c:2649 [inline] [<00000000e5f3fea0>] __tun_chr_ioctl+0x2218/0x3d20 drivers/net/tun.c:2883 [<000000001b8ac127>] vfs_ioctl fs/ioctl.c:46 [inline] [<000000001b8ac127>] do_vfs_ioctl+0x1a5/0x10e0 fs/ioctl.c:690 [<0000000079b269f8>] ksys_ioctl+0x89/0xa0 fs/ioctl.c:705 [<00000000de649beb>] __do_sys_ioctl fs/ioctl.c:712 [inline] [<00000000de649beb>] __se_sys_ioctl fs/ioctl.c:710 [inline] [<00000000de649beb>] __x64_sys_ioctl+0x74/0xb0 fs/ioctl.c:710 [<000000007ebded1e>] do_syscall_64+0xc8/0x580 arch/x86/entry/common.c:290 [<00000000db315d36>] entry_SYSCALL_64_after_hwframe+0x49/0xbe [<00000000115be9bb>] 0xffffffffffffffff It should call kset_unregister to free 'dev->queues_kset' in error path of register_queue_kobjects, otherwise will cause a mem leak. Reported-by: Hulk Robot Fixes: 1d24eb4815d1 ("xps: Transmit Packet Steering") Signed-off-by: YueHaibing Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/core/net-sysfs.c | 3 +++ 1 file changed, 3 insertions(+) --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -1241,6 +1241,9 @@ static int register_queue_kobjects(struc error: netdev_queue_update_kobjects(dev, txq, 0); net_rx_queue_update_kobjects(dev, rxq, 0); +#ifdef CONFIG_SYSFS + kset_unregister(dev->queues_kset); +#endif return error; }