From patchwork Tue Jul 18 01:33:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 789817 X-Patchwork-Delegate: f.fainelli@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="uGFbgcGp"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JKi0YfW5"; dkim-atps=neutral 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 3xBN4D0MDsz9s82 for ; Tue, 18 Jul 2017 11:34:19 +1000 (AEST) 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=XXnqgS5nBXFyQZORVlxuEoCQrWfQ21kAlIY5h/P8eYY=; b=uGFbgcGpC2QoqA NPKE0ovDl2JLh3HoH79mZ/ZsslvGJ/+7abd3p9+vMUlD6F5Pybgv0JrbSi4Ui6kvAyWdyU2p6nSOS RCckzh/o79b8zi1Y+OZ5jgKWlKkComXKOokSq85hUuhC7T2TUxjVLP31SfgSXOI0vM2pEj9ImN5Xu IMzQHFapCBnf6M6GKnYHkmrva0hBBCIrxjleH3AjQvv+1C3EF9OMjFCorCGCgyZUW5p8JSQMgaoSi qvDPOcNyXlhkyB7Gy9GKlFyL53u/9ubozNl0Hz93CDyUq0EItrNfnscXT1ur13belUItbgRX24Vm2 JIzECr3IJlwpObMoo9dA==; 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 1dXHOl-0001Ad-4p; Tue, 18 Jul 2017 01:34:03 +0000 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dXHOh-00019c-JH for lede-dev@lists.infradead.org; Tue, 18 Jul 2017 01:34:01 +0000 Received: by mail-oi0-x241.google.com with SMTP id n2so779371oig.3 for ; Mon, 17 Jul 2017 18:33:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ssj4UlqE+62PAIuxaTmci0Fcpj0wXDAMy3CKG8hQiGo=; b=JKi0YfW5jIXThGhs3T689mi2M6UunUNMjioKMWD73LD9UfsVsx8XelAnAZqEnOTSns uKziB6wGaVgjNsBRIVB/JcL3MO02HibyNNnEn2VkwhUOnpYZbgCba1YU8qEeUMa+nKTW dYAKND0JVhx1gYYEy5UPtyWdrp89zRgALAoEfD6RkpeE6V/ShaP33f79NBjCFhb9NBhj CcecfNApoU2GVEojljGRLmJ4xnzceZ+x21tSVO6ewA7FJ0/NLAEfTj+bYYRIn04hALxz 5cNnfiRLqUuqO/gHSD823JIH2RSD8ko9PdPytvpMN2M+T0Wqr+jOP/paaCd+VVGkyPuS vPQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ssj4UlqE+62PAIuxaTmci0Fcpj0wXDAMy3CKG8hQiGo=; b=rInpt2pjDDo9fQAf4A7S/iHymsRVU4okQHiz570R08Uj9n5UH3quqYczKx/uvhIZIv b9B87qQYCWR3N2+HJuMKBwE6+QAI4PkMEHzYI6hhC0z6BX8cQnCLS7VpcQBknL3L54UE MdDWlJ7PYs10Cg3XEuIBIWsDLT9lZ60t5sr8ImukOuK/QgiFWdjg1xM9IIE1Mtbr2YiG q2J9lgav8R/jyQGs//qC16xCYF+Js4HMkza5nnjiiEXPwH2qSXb3sGeKgCoBNF9WUljv Ahb++43Sxv9xQH37pWZIN11Wt4/O8O4UyaOqvDAZTvmuPy0ClWs0tzoAZny5hlr8ZjW6 aYrg== X-Gm-Message-State: AIVw113ZgU2423tS9KB40F9njX1fbiciPZj4KSprQklKkbFah6IRwDg4 7cKqtT5+1FXVxOt9KtE= X-Received: by 10.202.177.137 with SMTP id a131mr185049oif.172.1500341618264; Mon, 17 Jul 2017 18:33:38 -0700 (PDT) Received: from cox.net ([2001:470:d:73f:c1a0:bc99:c3f4:47eb]) by smtp.gmail.com with ESMTPSA id d5sm1503461oic.14.2017.07.17.18.33.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 18:33:37 -0700 (PDT) From: Florian Fainelli To: lede-dev@lists.infradead.org Date: Mon, 17 Jul 2017 18:33:33 -0700 Message-Id: <20170718013334.15393-1-f.fainelli@gmail.com> X-Mailer: git-send-email 2.11.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170717_183359_743888_BE54A34D X-CRM114-Status: UNSURE ( 9.59 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:4003:c06:0:0:0:241 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (f.fainelli[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain Subject: [LEDE-DEV] [PATCH procd v2 1/2] init: Check chroot return value in sysupgrade_exec_upgraded() 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: Florian Fainelli , mschiffer@universe-factory.net, john@phrozen.org MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org chroot() can fail and its return value should be checked against, in that case do an exit() since this is a fatal condition that we cannot recover from. Fixes: 63789e51ed91 ("init: add support for sysupgrades triggered from preinit") Signed-off-by: Florian Fainelli --- sysupgrade.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sysupgrade.c b/sysupgrade.c index 30f1836135c9..bd909ad33a77 100644 --- a/sysupgrade.c +++ b/sysupgrade.c @@ -26,8 +26,10 @@ void sysupgrade_exec_upgraded(const char *prefix, char *path, char *command) { char *wdt_fd = watchdog_fd(); char *argv[] = { "/sbin/upgraded", NULL, NULL, NULL}; + int ret; - if (chroot(prefix)) { + ret = chroot(prefix); + if (ret < 0) { fprintf(stderr, "Failed to chroot for upgraded exec.\n"); return; } @@ -45,5 +47,9 @@ void sysupgrade_exec_upgraded(const char *prefix, char *path, char *command) fprintf(stderr, "Failed to exec upgraded.\n"); unsetenv("WDTFD"); watchdog_set_cloexec(true); - chroot("."); + ret = chroot("."); + if (ret < 0) { + fprintf(stderr, "Failed to chroot upon exit.\n"); + exit(EXIT_FAILURE); + } }