Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3920779pxj; Mon, 21 Jun 2021 09:24:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1+vDy+7ZbRFG4lj1P/QTgO6tntb4nkuf1ELXaOuzPND5nn2kiYoBmy0OtnN/XGYggeydR X-Received: by 2002:a17:906:a20b:: with SMTP id r11mr25435772ejy.221.1624292646524; Mon, 21 Jun 2021 09:24:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624292646; cv=none; d=google.com; s=arc-20160816; b=y2DjV5iIBr49RJjv4YmNxxorw/Zt+Pup1oBKTwOEKwyBmX0Pkui82A4TdkP0iiHlbM UDxhbrB+E/2WuvwlfBXJ5+8wzzpjt6MFl4qkyiUSHM3zTlNcG75qv6U3BOvcdXNnWEYY +X2QGADq4K7ESYpFCagoLPvnfPbXWiXsFLcuUoOMPszul43k8YVDsvVzV6/WppsWIRRc 0ptBU4j74xbFgvgjvKFKYKcVVIzzodBlJq1f+yqF37mkAyhRcGINulIUIcm8GJf2gKbZ /CuinUE+gRCrNi63qmUueRfhouQJratnS71Nw2Ey8cV7yKwsPN0SZKGgteBgvq8ReJ8K HVIQ== 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=USDvsWIJMqQlJTW7k2OpeU5hJqIvda/O1g86FaN1dEc=; b=sNiln811tSi3sFqLRocD9Z2RIkFV4QLToxrJuwafRgYBvsBOnYlxAr/MZlwhzD6dUi Or+D7H67IQSkMJb4KXzoqQ9IL0mux9f2TSfdPKpJKT62XVqYaaw+3uwUe4bQXVqaPz85 xQ+oFq3hSLqzonadgTRsYkKCbmBohvDYlEdhilSD+uFB6j+NbFaO/JkqCGK6lDjUDTxS FtAAordA2OBTD6fQWoSUb6lm6IPBRTh8eHOzFkXOPlcKE/kqBX7Y4oZFopKCWpnCwxML WgpYZrZIXtREG1fS3bO7xV8eV7lf/h1t6LrRGWXmGfyHfA7uSgFXUWmgDXmVkUwqaYX7 WBPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jASoRYjt; 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 gz10si11434156ejc.389.2021.06.21.09.23.44; Mon, 21 Jun 2021 09:24:06 -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=jASoRYjt; 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 S231894AbhFUQWW (ORCPT + 99 others); Mon, 21 Jun 2021 12:22:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:42214 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231697AbhFUQVO (ORCPT ); Mon, 21 Jun 2021 12:21:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0B8D461351; Mon, 21 Jun 2021 16:18:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292336; bh=RFB042bcX/DPn83t5Dgqy/pme1S1QtyqarEQjOxVpng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jASoRYjt+MmyCMiMeAG4zVlFjU2ycDDIiy7cZnezZG4c0x4uPRAOlbZYCNj41GblK gc5YtC1uX7mozivPafLVCKvLDswgB8ADYID3tp7guIbX/+wDdi0FFdi1Xm4LnGnPea sAxtE366Xz6jtqjd5ra6F6Kzq1oISZhpK9E1HluA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Skripkin , "David S. Miller" , Sasha Levin Subject: [PATCH 5.4 36/90] net: hamradio: fix memory leak in mkiss_close Date: Mon, 21 Jun 2021 18:15:11 +0200 Message-Id: <20210621154905.348731123@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154904.159672728@linuxfoundation.org> References: <20210621154904.159672728@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: 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 deef14215110..352f9e75954c 100644 --- a/drivers/net/hamradio/mkiss.c +++ b/drivers/net/hamradio/mkiss.c @@ -800,6 +800,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