Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3594707pxv; Mon, 28 Jun 2021 08:11:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfnIH9D8/sksrBeCHJxINYvTCjnu9TmUPImBggi9WoPp0g17+yYmoiw47S7Xl0eCW4R8uL X-Received: by 2002:a92:dd05:: with SMTP id n5mr8073361ilm.72.1624893085940; Mon, 28 Jun 2021 08:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624893085; cv=none; d=google.com; s=arc-20160816; b=oIVMIZ7YEPAb19PW07ZEdOGnVg9a7lDSGWFOmEaxuRDx+9K1toCCN2nP/LTWyE6Hgu KOjJ/m+L50K90vi9ZpBPGUGki2/VdvhkmVW6Qm2kIcFgirbX4X9SIskWdv1LMRAl6hUD L9sn9+bk0/ECaOeF5WhTQ2MRwiKsDZSsBpNx0pawrvaiYfRg0AxQrzdb1T2lBojeA9XY 4YA2t5VXblVC2keuNgb+MjJIQ8JVKiECs8QyHgtNDI9di3s2KWnUYfGgcG/IqO9vMCYK PJoprTCHphflMxBotJ/fbL8lYLLfRo6tJkgmUVpExf3IPQ0fD4E4W/q54JPUXXlXcNWX b1Xg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XfeAHpcAGi++Caeofid+jen69/rUvVcAEoPCdWdYtks=; b=oGlnfzNvmBnzY/nBgD9zKN/va0Pq4YzamqLIwENYSkrt2c76JgAKJicrDnBpaFUgi9 tJri8xxJgd4rhCnFzvTraQWVWvgpsDD6+k2D5uqOPigDDNYhNbS9JNqEclGHywZerI9e fDv4h0cx6298aAmDSgNH2uzf4HW3n47s+LhP/mA10oqeRRSYqrNpYN56DLsi+JShs9x9 r4GP/Q9Ukhhq2YEWlzA6f33qLCSZpP+QwF0KKk1H7GpP+Bmq02a0YxKGc+YLtKVInia4 3AcDCSlGSS4/QBP4L9pjPJo/7+qTt+cXUJIz5u+6A0TKmvoB/DWK/axrODjT+GFT3wcx dSPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tZ9t3mER; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i9si16495629ioq.17.2021.06.28.08.11.10; Mon, 28 Jun 2021 08:11:25 -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=@kernel.org header.s=k20201202 header.b=tZ9t3mER; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235464AbhF1PK6 (ORCPT + 99 others); Mon, 28 Jun 2021 11:10:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:56020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235487AbhF1Ouw (ORCPT ); Mon, 28 Jun 2021 10:50:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 65A2261D2A; Mon, 28 Jun 2021 14:37:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624891022; bh=BZyxkj/NhRkyGL3+C7mQaP/3OnLQO9AKVhWlXTDjnJY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tZ9t3mEROjunAquWiDX6TnTbHyMbEWdsJSHRdW09R35p0vEOf4TRzSX19CmnithWn TdA1EVKb2Szj4btzk34ZOhu+R468rUe0n9+wqH8GZ8ZPRqr5HkbHNQNzCdn6Km2GgQ vAhb67TjKYNdmYTsImKPp+0LwDuiLjui6Lk9S07lk9qac2+vLILuLIebStAEAa0yfT b/UDaOWSajNgVoNJiz5YASo9X1yYiettWdaQ8LLCU+8y4N8CpW16U7aU9Kl7Vle4eD UTyY5ov4ej4DLcoVYX8Hqfy+yfmx0hVMH9aujuTOipelSXAwm5/4i4uN8mzoGzQORq 2zHgHqqDTU6Gw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pavel Skripkin , "David S . Miller" , Sasha Levin Subject: [PATCH 4.14 37/88] net: hamradio: fix memory leak in mkiss_close Date: Mon, 28 Jun 2021 10:35:37 -0400 Message-Id: <20210628143628.33342-38-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628143628.33342-1-sashal@kernel.org> References: <20210628143628.33342-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.238-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.14.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.14.238-rc1 X-KernelTest-Deadline: 2021-06-30T14:36+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Skripkin [ Upstream commit 7edcc682301492380fbdd604b4516af5ae667a13 ] My local syzbot instance hit memory leak in mkiss_open()[1]. The problem was in missing free_netdev() in mkiss_close(). In mkiss_open() netdevice is allocated and then registered, but in mkiss_close() netdevice was only unregistered, but not freed. Fail log: BUG: memory leak unreferenced object 0xffff8880281ba000 (size 4096): comm "syz-executor.1", pid 11443, jiffies 4295046091 (age 17.660s) hex dump (first 32 bytes): 61 78 30 00 00 00 00 00 00 00 00 00 00 00 00 00 ax0............. 00 27 fa 2a 80 88 ff ff 00 00 00 00 00 00 00 00 .'.*............ backtrace: [] kvmalloc_node+0x61/0xf0 [] alloc_netdev_mqs+0x98/0xe80 [] mkiss_open+0xb2/0x6f0 [1] [] tty_ldisc_open+0x9b/0x110 [] tty_set_ldisc+0x2e8/0x670 [] tty_ioctl+0xda3/0x1440 [] __x64_sys_ioctl+0x193/0x200 [] do_syscall_64+0x3a/0xb0 [] entry_SYSCALL_64_after_hwframe+0x44/0xae BUG: memory leak unreferenced object 0xffff8880141a9a00 (size 96): comm "syz-executor.1", pid 11443, jiffies 4295046091 (age 17.660s) hex dump (first 32 bytes): e8 a2 1b 28 80 88 ff ff e8 a2 1b 28 80 88 ff ff ...(.......(.... 98 92 9c aa b0 40 02 00 00 00 00 00 00 00 00 00 .....@.......... backtrace: [] __hw_addr_create_ex+0x5b/0x310 [] __hw_addr_add_ex+0x1f8/0x2b0 [] dev_addr_init+0x10b/0x1f0 [] alloc_netdev_mqs+0x13b/0xe80 [] mkiss_open+0xb2/0x6f0 [1] [] tty_ldisc_open+0x9b/0x110 [] tty_set_ldisc+0x2e8/0x670 [] tty_ioctl+0xda3/0x1440 [] __x64_sys_ioctl+0x193/0x200 [] do_syscall_64+0x3a/0xb0 [] entry_SYSCALL_64_after_hwframe+0x44/0xae BUG: memory leak unreferenced object 0xffff8880219bfc00 (size 512): comm "syz-executor.1", pid 11443, jiffies 4295046091 (age 17.660s) hex dump (first 32 bytes): 00 a0 1b 28 80 88 ff ff 80 8f b1 8d ff ff ff ff ...(............ 80 8f b1 8d ff ff ff ff 00 00 00 00 00 00 00 00 ................ backtrace: [] kvmalloc_node+0x61/0xf0 [] alloc_netdev_mqs+0x777/0xe80 [] mkiss_open+0xb2/0x6f0 [1] [] tty_ldisc_open+0x9b/0x110 [] tty_set_ldisc+0x2e8/0x670 [] tty_ioctl+0xda3/0x1440 [] __x64_sys_ioctl+0x193/0x200 [] do_syscall_64+0x3a/0xb0 [] entry_SYSCALL_64_after_hwframe+0x44/0xae BUG: memory leak unreferenced object 0xffff888029b2b200 (size 256): comm "syz-executor.1", pid 11443, jiffies 4295046091 (age 17.660s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [] kvmalloc_node+0x61/0xf0 [] alloc_netdev_mqs+0x912/0xe80 [] mkiss_open+0xb2/0x6f0 [1] [] tty_ldisc_open+0x9b/0x110 [] tty_set_ldisc+0x2e8/0x670 [] tty_ioctl+0xda3/0x1440 [] __x64_sys_ioctl+0x193/0x200 [] do_syscall_64+0x3a/0xb0 [] entry_SYSCALL_64_after_hwframe+0x44/0xae Fixes: 815f62bf7427 ("[PATCH] SMP rewrite of mkiss") Signed-off-by: Pavel Skripkin Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/hamradio/mkiss.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c index 9fd7dab42a53..2074fc55a88a 100644 --- a/drivers/net/hamradio/mkiss.c +++ b/drivers/net/hamradio/mkiss.c @@ -810,6 +810,7 @@ static void mkiss_close(struct tty_struct *tty) ax->tty = NULL; unregister_netdev(ax->dev); + free_netdev(ax->dev); } /* Perform I/O control on an active ax25 channel. */ -- 2.30.2