Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3599047pxv; Mon, 28 Jun 2021 08:16:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2rQs35J5/J8CyA+o6mbALUA2ICu6OAxRDuIPA7oAfmD3H8I96Q9oNkOjv7zg6pMjhM9zA X-Received: by 2002:a5e:930e:: with SMTP id k14mr21710872iom.136.1624893398207; Mon, 28 Jun 2021 08:16:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624893398; cv=none; d=google.com; s=arc-20160816; b=DApEtOe+mAlBBUn2Q7nTeEZllk/o2W36iL8JNHRWoCb/mUMPtneTNwo9BCSwY46xes YRpid+V4fGNvFrp0f6ahpJOsDMBgwDkNOK1vuKlqkSBNzCEA806NYu61im0po/iwgjvh /uQdxiAdcdOjRFsTIR8DvUvx3lmswcTM0OlEa4Vwe7mmqrEPgdu30GiTccRveUeT7Dcv MzUFBFl+arzmFltMq2HvPWFnhJ0NAs0WATKFYcmhrD/7ECO0o3B12HFnaGf8N+M4kM2q z8vUODO0LDVg/nqwsu4sUdM6Ep23BPls4zLmMTIzvhjob0IDTnUsr21FTIcipJg9DE98 yVsQ== 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=I09qYHycohxw5M+RJkVBu9CNTFRFI75HJQ8ny6R4zqY=; b=QnfJr4AMUP5G9A3lAt4LZAB4gXxPy6N3s6w1Hzzq6q/lVCTeZRyzpwdDaRVHls83Pm IlBUxin0k4FUAMxXG+gQdHk/yFXJTVU/nsFx4KkiZepvrJYVNVrRjw4jxHdvQeKxxsKQ bbYAGIsn+33SUR+h67zcxk7KRBgIfyq5z5NF1nR6lk2Fz0VSEA4bdbYg9qlKPYlLBIEf axgLzjw9fn47zoLM9mEvfox/cDVZ5lDvRDlTae4CM3I9bg+2iOGb05Z5YOJw3DIzCMct 3mi4JTxqHYzLH/d5aPiSx4uWAzO/JnYMFW2EWz4eEQhQhFp+5ORB9HQtwXuKUoMch01R 0eXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LKv0lC+m; 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.16.16; Mon, 28 Jun 2021 08:16:38 -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=LKv0lC+m; 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 S235522AbhF1PQR (ORCPT + 99 others); Mon, 28 Jun 2021 11:16:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:59412 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236178AbhF1Oyz (ORCPT ); Mon, 28 Jun 2021 10:54:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EE05961D48; Mon, 28 Jun 2021 14:37:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624891056; bh=WH9gcW9Z1imxQPF+CrvliwExfi0LugZSfydWpHfsRJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LKv0lC+maBbURfoLQkUT8VcveZ9PhhBzI2mBlrVjqqP/DN2ZMs3M71DtGdcRG5xEg 97RCbPiU9g3zTCO5BXDtN+OdZSnrZQ7TcsNXHuzTNRcqqa5HYdijGMwZ6ZrCHV77KJ MWRWzY3B1hKXPcI3CGMPWR/u65qjOSPMud6pEdkpcLSA9ee3Ag5zo/bR5edLyeWRQg 7gzYSAwV33muzm7fbGwtAuFssnxKBDpTQNeeVG1XcLSx1l4jpq5KLo4pNXSDMdVwFG 1SJqr2g2qW1IgrMLzKC0bt5pDEkkhpjr7DRoBDyk03zizO6ZvXj+G+3+ZczqBUVIZK ueWw22rXXcsnA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pavel Skripkin , syzbot+f303e045423e617d2cad@syzkaller.appspotmail.com, "David S . Miller" , Sasha Levin Subject: [PATCH 4.14 77/88] net: caif: fix memory leak in ldisc_open Date: Mon, 28 Jun 2021 10:36:17 -0400 Message-Id: <20210628143628.33342-78-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 58af3d3d54e87bfc1f936e16c04ade3369d34011 ] Syzbot reported memory leak in tty_init_dev(). The problem was in unputted tty in ldisc_open() static int ldisc_open(struct tty_struct *tty) { ... ser->tty = tty_kref_get(tty); ... result = register_netdevice(dev); if (result) { rtnl_unlock(); free_netdev(dev); return -ENODEV; } ... } Ser pointer is netdev private_data, so after free_netdev() this pointer goes away with unputted tty reference. So, fix it by adding tty_kref_put() before freeing netdev. Reported-and-tested-by: syzbot+f303e045423e617d2cad@syzkaller.appspotmail.com Signed-off-by: Pavel Skripkin Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/caif/caif_serial.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c index ce76ed50a1a2..1516d621e040 100644 --- a/drivers/net/caif/caif_serial.c +++ b/drivers/net/caif/caif_serial.c @@ -360,6 +360,7 @@ static int ldisc_open(struct tty_struct *tty) rtnl_lock(); result = register_netdevice(dev); if (result) { + tty_kref_put(tty); rtnl_unlock(); free_netdev(dev); return -ENODEV; -- 2.30.2