From patchwork Thu Jul 6 20:25:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Sojka X-Patchwork-Id: 785257 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3x3TmH57n0z9s76 for ; Fri, 7 Jul 2017 06:26:39 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Nxf4kgkl"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:Message-Id: Date:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=4Exuu2OcASXl20lTXNu2UbrLMcF9bHdi2EZUwu3vm8g=; b=Nxf4kgklCUiaCb GMSI9v56u8IILbgOVLhjjeZcZIZ0Bxg//SDYY0KIBQFHFBjmY/ZODyZidJAH6DeT0jxUZGQ40D88n koSNYSz3OHm8+7EucFCsIvc6jADOclhOILC61Fy8izI5GnXPXiqaBhYUb8UbzQV1Y4nOD3OmWkqq3 jfrYM5VDoDFY8mzi4Sx6CUwigqfMvYF7ocyJQcc/2aHFM1imea/1LN/3nrjkvRT2ygioDfQ1sWGEV lHwmu48DtZZSUo3s0kKabSh9oHym+Zj+LSdyAaBFGWLuYJEP5Sd4i0FruH5F5OFEZlvU5rmBUZirQ qdTvjDvk982T6puhIcKA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dTDM0-0003bb-HQ; Thu, 06 Jul 2017 20:26:24 +0000 Received: from smtpx.feld.cvut.cz ([147.32.192.33]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dTDLa-0003Z9-OC for lede-dev@lists.infradead.org; Thu, 06 Jul 2017 20:26:01 +0000 Received: from localhost (unknown [192.168.200.7]) by smtpx.feld.cvut.cz (Postfix) with ESMTP id E5B96DC3CF; Thu, 6 Jul 2017 22:25:33 +0200 (CEST) X-Virus-Scanned: IMAP STYX AMAVIS Received: from smtpx.feld.cvut.cz ([192.168.200.6]) by localhost (styx.feld.cvut.cz [192.168.200.7]) (amavisd-new, port 10054) with ESMTP id yIVrZrX0htjq; Thu, 6 Jul 2017 22:25:32 +0200 (CEST) Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34]) by smtpx.feld.cvut.cz (Postfix) with ESMTP id 7BF36DC3C1; Thu, 6 Jul 2017 22:25:32 +0200 (CEST) Received: from wsh by steelpick.2x.cz with local (Exim 4.89) (envelope-from ) id 1dTDLA-0001LU-13; Thu, 06 Jul 2017 22:25:32 +0200 From: Michal Sojka To: lede-dev@lists.infradead.org Date: Thu, 6 Jul 2017 22:25:16 +0200 Message-Id: <20170706202516.5135-1-sojkam1@fel.cvut.cz> X-Mailer: git-send-email 2.13.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170706_132558_989234_0D9F233D X-CRM114-Status: UNSURE ( 5.66 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [147.32.192.33 listed in list.dnswl.org] -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Subject: [LEDE-DEV] [PATCH] procd: Do not leak pipe file descriptors to children X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Sojka , john@phrozen.org MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Without this change, a process started by procd can have access to stdout/err of processes started by procd before. Signed-off-by: Michal Sojka --- rcS.c | 1 + service/instance.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/rcS.c b/rcS.c index 4ecf0c1..b1202bf 100644 --- a/rcS.c +++ b/rcS.c @@ -82,6 +82,7 @@ static void q_initd_run(struct runqueue *q, struct runqueue_task *t) if (pid) { close(pipefd[1]); + fcntl(pipefd[0], F_SETFD, FD_CLOEXEC); s->fd.stream.string_data = true, s->fd.stream.notify_read = pipe_cb, runqueue_process_add(q, &s->proc, pid); diff --git a/service/instance.c b/service/instance.c index e5c4830..bb766ea 100644 --- a/service/instance.c +++ b/service/instance.c @@ -444,11 +444,13 @@ instance_start(struct service_instance *in) if (opipe[0] > -1) { ustream_fd_init(&in->_stdout, opipe[0]); closefd(opipe[1]); + fcntl(opipe[0], F_SETFD, FD_CLOEXEC); } if (epipe[0] > -1) { ustream_fd_init(&in->_stderr, epipe[0]); closefd(epipe[1]); + fcntl(epipe[0], F_SETFD, FD_CLOEXEC); } service_event("instance.start", in->srv->name, in->name);