Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9171644pxu; Mon, 28 Dec 2020 08:21:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxzCG/+DYgvmW948UQZd0Ohh1uXolVzUVSL3wPnXYkEkap3EHH1WyxsTTwvUiEjd6E2en02 X-Received: by 2002:a05:6402:229b:: with SMTP id cw27mr42280327edb.23.1609172463527; Mon, 28 Dec 2020 08:21:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609172463; cv=none; d=google.com; s=arc-20160816; b=z03oLJCssrKmHGuqj1gfi1Y76MXxHxHlLJYhnK8vExd/KpLNEE2ZCy1GAgsFw5+KIr DHkmyoa3GPL5UdXTMVDkNdeUelWgcLbypvDbjfueji72AH7ajMw1iqVwingD9ZPDzMYX V3ykLe94juZfwrAMpW85pKDbUzLLlzNz1mOqdEvw/FTfAo8kefBHJ4rj53onhBbd8bLb dShk+OscYAfPAcFyj7F4ufdWaE+Q8WKJ4r+SmR69eHrDqJBsVDHwTavfjBMeGF5PtaMT qQjhjfDQoPVsBOue9o4e1a/IGlfBEZq3Ttd3hN71CtT0FA6VBC1cSShszLakmTsT6gfJ gkNg== 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=1VFadaBdw8/XZnv7yvug86YQZQ3ZgBf+Rtak5IVEQEU=; b=sPJBJ90sq8M3675XQJG/PR1EowxvmR0oUnnP0DXqJuHGO89xORSfA7tXVFZT2IXRLZ akcMn83g7uCSa6Xw0iojRHHfI9XCiQjM6Q9a+eZ0erkclH3KMdxEc5D2jhtVjyWXRbap ZBm6/H5V7DAUmqcAF93nwv+YxvkGBTTaYJbgBwbMsY2W3u1UVJjqQ/yAT2TTHNQNDAvu MuRWZde+gQ09j5qhEHodDwkFXnhGyqcG3NvslUrxTvU8o4sRW7sxVFbZ9sXD8YQGWi7p gND5c1y40rIs9U6hEB965DokG49aFQ+bAFZHY1yvwP0h4JSZ2lXQFW8ghBLdnT61mhqs cRCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xCPY+ErR; 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 lr8si2257680ejb.29.2020.12.28.08.20.40; Mon, 28 Dec 2020 08:21:03 -0800 (PST) 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=xCPY+ErR; 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 S2633075AbgL1QTA (ORCPT + 99 others); Mon, 28 Dec 2020 11:19:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:43560 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731826AbgL1NPT (ORCPT ); Mon, 28 Dec 2020 08:15:19 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9747F2076D; Mon, 28 Dec 2020 13:14:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161278; bh=4jLqyF3EjFvGTRYAS3QjW9dDV4q6T3QEhnp5c8bsMhY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xCPY+ErRdNhjTteEcRM9ry2ajIbK4H+3j7d15OnqL8On7G6sCGo4bxXpHJGhoMYPw xmx76RBjsId7sRii1ue6ymm4go57iphtSfdPUV+YIw/iRR1BoC5/e4/JJieFAxyzjU bf8nQKcLcuD6EuSsLg5DJ0Zj1KxewoGk/aMt6kRs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anton Ivanov , Richard Weinberger , Sasha Levin Subject: [PATCH 4.14 161/242] um: chan_xterm: Fix fd leak Date: Mon, 28 Dec 2020 13:49:26 +0100 Message-Id: <20201228124912.624507220@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@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: Anton Ivanov [ Upstream commit 9431f7c199ab0d02da1482d62255e0b4621cb1b5 ] xterm serial channel was leaking a fd used in setting up the port helper This bug is prehistoric - it predates switching to git. The "fixes" header here is really just to mark all the versions we would like this to apply to which is "Anything from the Cretaceous period onwards". No dinosaurs were harmed in fixing this bug. Fixes: b40997b872cd ("um: drivers/xterm.c: fix a file descriptor leak") Signed-off-by: Anton Ivanov Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- arch/um/drivers/xterm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/um/drivers/xterm.c b/arch/um/drivers/xterm.c index 20e30be44795b..e3b422ebce09f 100644 --- a/arch/um/drivers/xterm.c +++ b/arch/um/drivers/xterm.c @@ -18,6 +18,7 @@ struct xterm_chan { int pid; int helper_pid; + int chan_fd; char *title; int device; int raw; @@ -33,6 +34,7 @@ static void *xterm_init(char *str, int device, const struct chan_opts *opts) return NULL; *data = ((struct xterm_chan) { .pid = -1, .helper_pid = -1, + .chan_fd = -1, .device = device, .title = opts->xterm_title, .raw = opts->raw } ); @@ -149,6 +151,7 @@ static int xterm_open(int input, int output, int primary, void *d, goto out_kill; } + data->chan_fd = fd; new = xterm_fd(fd, &data->helper_pid); if (new < 0) { err = new; @@ -206,6 +209,8 @@ static void xterm_close(int fd, void *d) os_kill_process(data->helper_pid, 0); data->helper_pid = -1; + if (data->chan_fd != -1) + os_close_file(data->chan_fd); os_close_file(fd); } -- 2.27.0