From patchwork Fri May 27 04:47:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique MARTINET X-Patchwork-Id: 1636130 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=ULILK6JJ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::840; helo=mail-qt1-x840.google.com; envelope-from=swupdate+bncbcwivbv7sugrbvnpygkamgqera2pgha@googlegroups.com; receiver=) Received: from mail-qt1-x840.google.com (mail-qt1-x840.google.com [IPv6:2607:f8b0:4864:20::840]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L8XN930zZz9sGC for ; Fri, 27 May 2022 14:47:20 +1000 (AEST) Received: by mail-qt1-x840.google.com with SMTP id l20-20020ac81494000000b002f91203eeacsf3512538qtj.10 for ; Thu, 26 May 2022 21:47:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1653626838; cv=pass; d=google.com; s=arc-20160816; b=TQ12x1Wmr9UB219fBq950y0WV5A7kc8iNFTfSrkexRp0aiIlTWAGIqHl6BozW/7/tr 8eiuUQasdUZk2ldp6zW4OOBFUOCieJq4Jug1GRyu5437XTx/hNNbfwJfArI4Y/S2ou0c zDVxpKISgZEiFUaOENg7GfhVcVQTI/cXp9bu4c1umKb3j/9HzJZzPSfbxNiKr2fFwbxj JCGVcLfgHR/RiaPIarbZYlN+vLFnXBQ9gu/annyp4Znlj9NHmpP5msh7SZwUSDobRlc3 QtGIRu/vRiwY8zPpg9ILCqJMgbyDFccT5X06+BFV4VZkQo73cHiLVFIn+w67eny4H/1u EdLA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=bCC20AVl8l1XBCguO3ujt9H3tTfhUkhIQjs+KVhM+lc=; b=Zeg+DGBHFMnqjvLrvkqrQxzMnH+sQMLJLIws9fTPaq3OKsB2XDG1aNnumkMlKz/Zim dwvFTctBvMH/KWKM487BML1CJ605Z2HkgPrVGgg/LnAXbk3xnCKX3JZm10JjiT8rkKA7 yeWWirbc6w07UL5YXQKvGe/MuOCzXyAiOg0xyQh6EArd6m8erwl7d8s5qVQ8Vhocc/Kl 90CO1n47wXEcztysOjFFNT9CeDLssa6CR2XkBrHG8Q5Rqoz7pfO5rOxnmgB6lhoh/FVW PP/vLOE22Z1Ef0VMalnJmkywchO2xv4fcAAV4f6F++x1JsfC7VjaIDotaMGbKpDJuFqL sFBw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=bCC20AVl8l1XBCguO3ujt9H3tTfhUkhIQjs+KVhM+lc=; b=ULILK6JJ/iFl+jfsj1UY++qRsgaLP1dO+5o240WS5ggnjQzrR4KowCil3pxk/rrlLm iecWEntiljEYzZpzmcd9UHlPtgWUehGEO0gfkTAcjdzQAwJ7kV6cLoq8XqfqvpiA5bG7 tYkv0bKmi5wiGaiORuzhGI2wxrwWVclFFG3yKMZKhH2iPheGnqFNZzeHRlDLwDInz3LI DvqsBqQubk6mxh82RBOs3byvVTxSq1poKewur0wiG8aBs4kOvCs265ykcRF/ti+gFITJ Zts0AhukdBRS/2JVjn5TXIDyOJF5LV307fmgQ0yHbRuVrMkfvYsJPYDi/FTuj0bZgTnU GfmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=bCC20AVl8l1XBCguO3ujt9H3tTfhUkhIQjs+KVhM+lc=; b=bP4KDmk/7RVFGnorbr3hP/yd/yh6aGpUTo2vNKJms0pZZg1QUl6Ekp2QnRE68mL8+k lWZLMx+MfQZ5IiMloEN8vl2vAZtJ075C6DjzDpiokMvXotrFUH9n0sbtbU4/5v4SpB8a BlrU9MXNPQqfcY7Yg/l6aI8Oytv7SFiy5dACoVgOVuyfQkRPN1KpHSp1yEHMIjlVb8tU w6pQ4wXqHJColmshdFCcQhh6EhruHcWWutFmy58squ/ceTEonTAARgPPrcnKPEjpNUop ntzY4wYwew3apnTURd/YpG3zKkUHEKjyZt8NYTo0agh7yq7slUPm4U66fE3mncvuO+vS /iTw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532ZPcGLj/qJ0G2Fiy+c+nm0i+S4fZX5otNP55uPp+8QWJ7rjnCs oxZsBPqaZP134U37q3mzxtE= X-Google-Smtp-Source: ABdhPJzocqlBVbv4foYRIhjJq1QRrNRcDL72rX67eqlzwoCw9+rmF4NxKAxVvHH9d9UPgWDyAIamMw== X-Received: by 2002:ac8:7dce:0:b0:2f9:173a:6166 with SMTP id c14-20020ac87dce000000b002f9173a6166mr29039251qte.127.1653626838154; Thu, 26 May 2022 21:47:18 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:620a:370c:b0:6a5:ab60:492c with SMTP id de12-20020a05620a370c00b006a5ab60492cls2602276qkb.3.gmail; Thu, 26 May 2022 21:47:17 -0700 (PDT) X-Received: by 2002:a05:620a:22a7:b0:6a5:823d:652d with SMTP id p7-20020a05620a22a700b006a5823d652dmr10208760qkh.127.1653626837443; Thu, 26 May 2022 21:47:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653626837; cv=none; d=google.com; s=arc-20160816; b=melmHFbS4lgscZxdMjPotNdrIRw0JciZVQaWnSHxZZERWf0kSLxMJNiFCNgw0lLvoP G4eXMpd6p5yRn9tusQ+0dKMyKaI+Bu9TVTFm12cTQ4Fgq1gzhyKNMieI/xWDAEmqPALm 35sJyeC+KRgMJhos09W2ePZNmcVu9EXY2DxVGEo7e2Nr1lpRk8qFt2CRq/SCkqF5J6cs yUqHCom6maD71f/F9w60cYmlJln0y5aFF2pQ6LTPEwu6Z0kQh3BX7Ew0F01v3g0a0b6Y IIJcfnGbBXz93xqhAC9N+PlGjeaI39fR1fWJ2gIs2axBk/L2lXKOEh54d6YJUidhkqim 6MpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=qgI3aD6CZ8NBer9wqe9R1gLrYw8Pi9SLqxKObe7LHoo=; b=seYI2GCqM+OsAEdV+M9z99OUckdh3eI6P+DMRsz2gdeKj8/aTqyRKvCuEBGEaONEYc fNjJ/N9p2gNKDNk/HK56sfHTo+CAjXski8T0gMynXnf7VkkaA2rd26JgVV++anmrFbs0 deqvMhk2rvr+5mzUmHtUe/Wb8iS5cMqTK9jfPrcXyICznYteFKpj9losnK01SBDyyKLP BMd+5lzrAwBy1SVF65ki0w+0M+rZ72iJEiWXMBCtJkoi2e/bluV7SQXDyvtFk6aFsx08 wmiN4msvTJXhVuG9qBh3VBeXhL8Z76yB70WjzloewCBO6xC/z4jO4rpcyZJRoMwj44fn T2QA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Received: from gw2.atmark-techno.com (gw2.atmark-techno.com. [35.74.137.57]) by gmr-mx.google.com with ESMTP id i10-20020a05620a248a00b0069fc740f4cesi208797qkn.1.2022.05.26.21.47.16 for ; Thu, 26 May 2022 21:47:17 -0700 (PDT) Received-SPF: pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) client-ip=35.74.137.57; Received: from gw2.atmark-techno.com (localhost [127.0.0.1]) by gw2.atmark-techno.com (Postfix) with ESMTP id 0EAA320D78 for ; Fri, 27 May 2022 13:47:15 +0900 (JST) Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by gw2.atmark-techno.com (Postfix) with ESMTPS id 3E37A20D6E for ; Fri, 27 May 2022 13:47:14 +0900 (JST) Received: by mail-pj1-f71.google.com with SMTP id u1-20020a17090a2b8100b001d9325a862fso2128147pjd.6 for ; Thu, 26 May 2022 21:47:14 -0700 (PDT) X-Received: by 2002:a63:fc08:0:b0:3f9:e159:b114 with SMTP id j8-20020a63fc08000000b003f9e159b114mr26279372pgi.526.1653626832996; Thu, 26 May 2022 21:47:12 -0700 (PDT) X-Received: by 2002:a63:fc08:0:b0:3f9:e159:b114 with SMTP id j8-20020a63fc08000000b003f9e159b114mr26279358pgi.526.1653626832791; Thu, 26 May 2022 21:47:12 -0700 (PDT) Received: from pc-0115 (76.125.194.35.bc.googleusercontent.com. [35.194.125.76]) by smtp.gmail.com with ESMTPSA id s22-20020a170902a51600b00161823de53csm2475586plq.282.2022.05.26.21.47.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 May 2022 21:47:12 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.95) (envelope-from ) id 1nuRsU-00FNw7-Ck; Fri, 27 May 2022 13:47:10 +0900 From: Dominique Martinet To: swupdate@googlegroups.com, sbabic@denx.de Cc: Dominique Martinet Subject: [swupdate] [PATCH 6/6] spawn_process: use CLOEXEC for child communication fd Date: Fri, 27 May 2022 13:47:00 +0900 Message-Id: <20220527044700.3666830-7-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220527044700.3666830-1-dominique.martinet@atmark-techno.com> References: <20220527044700.3666830-1-dominique.martinet@atmark-techno.com> MIME-Version: 1.0 X-Original-Sender: dominique.martinet@atmark-techno.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , This fd leaks to subprocesses when using e.g. downloader mode Signed-off-by: Dominique Martinet --- core/pctl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/pctl.c b/core/pctl.c index 1c6e556d8721..89ebb452de04 100644 --- a/core/pctl.c +++ b/core/pctl.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #if defined(__linux__) #include @@ -147,6 +148,7 @@ static int spawn_process(struct swupdate_task *task, if (process_id) { /* Parent close the [1] */ close(sockfd[1]); + fcntl(sockfd[0], F_SETFD, FD_CLOEXEC); task->pid = process_id; task->pipe = sockfd[0]; return 0; @@ -154,6 +156,7 @@ static int spawn_process(struct swupdate_task *task, /* Child closes [0] */ close(sockfd[0]); + fcntl(sockfd[1], F_SETFD, FD_CLOEXEC); sw_sockfd = sockfd[1];