Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9038194pxu; Mon, 28 Dec 2020 05:07:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZjxN3ioIqT9nQwtqbgp085OV7woKShE/Mb8MpJmj7uc4wqBXAKSWiU2m/7emaW3VJeN6u X-Received: by 2002:a17:906:279a:: with SMTP id j26mr41182720ejc.203.1609160839184; Mon, 28 Dec 2020 05:07:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609160839; cv=none; d=google.com; s=arc-20160816; b=09NrQ+oiLUOvpEr1uvlpi6MstqtYCF6zbMPLKJy15Cxq/LFWJL5czKLoQQT8RwgsfY nQ5YzjNEnBnIxRR724/sJP9MCMuM9v/p0FtX6TmhTpj8Vu4XcQSQgCwSkPdyJkHya/0o OUX+a1YctzUkwngkSJR/S/UVpFemFd/GRyHsATM1LSlVmgPcdh4UaL+PQlh0MNbChkhl qYnbLHJ96+IMSyucj+vBOTIlyG6iBp5g0B72xT5+YnFLJs++l4K1zio26J4B4QmjjruE B8XSMAyXg2xJVmn1l0/liyMf79fZQPfNjE+qormafp0/A9K/y/i2DB5nb06F6NMxVo7w lwIg== 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=Jod/f0NWss7aCSiQcpLhsYd8EH42zy+FlSzeOE9JZk3RdpGP2r+aQYSmqY8lkzxyQv PY0KtpH/TD2A39yvzaa9YL1HvAJ+YZ+fcTFb5DJJaPIxske74s+nOQGSonDxK/Q6MDwn 5/L5bfqwrACHLNTB0yF4IMuGN9TdWn6rLFugThijUhfjf0Jkz/KYk8Y1crsJUyQHAh7L 6800/sFT2XGNpBydnScLUUZSaQZo0a5nIq1pdRgapef4gpW+dhi6Y/XyuOC67lenc03Y Lz10zfRdIF2ffJC262WGONZS5Ck1sWx5CT/BrwxVWnemvwOJylr8ReRbktF7LuZbGTfS 7SSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=R5lyglrA; 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 k6si18849891ejs.633.2020.12.28.05.06.56; Mon, 28 Dec 2020 05:07:19 -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=R5lyglrA; 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 S1730511AbgL1NEs (ORCPT + 99 others); Mon, 28 Dec 2020 08:04:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:60740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730463AbgL1NEe (ORCPT ); Mon, 28 Dec 2020 08:04:34 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AB5772245C; Mon, 28 Dec 2020 13:03:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160633; bh=4jLqyF3EjFvGTRYAS3QjW9dDV4q6T3QEhnp5c8bsMhY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R5lyglrAMplPiShTvTTAFg8Vf8/GPg1av48B16AyxTMxqUEWbJ1mnTTN1GbocifVX w/6vPKkUhY9VBVEtwdUMdriGI25qraN7Nw9JChynyofGPSJmlRp4pvvvI/uEyaGDIL jV1QePoiNGp1fDWjLSiImFx1RBoN4Su1wYTtZscQ= 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.9 116/175] um: chan_xterm: Fix fd leak Date: Mon, 28 Dec 2020 13:49:29 +0100 Message-Id: <20201228124858.874477091@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@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