Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2717346pxv; Sun, 11 Jul 2021 23:40:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvlnLOZ1365Xnp95MQrlfHZmKrO1QnYlS/P/Lu/nhTLm/458ZYdtuA41I7ppxeWxsPA7Jl X-Received: by 2002:a05:6402:2706:: with SMTP id y6mr1869549edd.192.1626072036653; Sun, 11 Jul 2021 23:40:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626072036; cv=none; d=google.com; s=arc-20160816; b=HWGUp1nDKqhh4/8Z7Fr5PIzDYzPcIKkK14m637ah8TBI7BK5NIUDH6NWumqY9IKhpt icHcPyjxaZGjmA7B3Gc5deRf/d9KFjF6GV4ZMZuvmtPHv1uHvcgVOGtTukWf79fzCrdi zzLT0T/wdulqwmVZYHfn+W4vCou4OqV68af7GsI6oE07rwkeI+QJvmAYPt5EJkp0hLXo B/BNTfjsBDzGu+YaatTZVWWvRi+S5+PnGlLADcaOaO1ex89UnjAJUFekJMcMaCOTcHTM NknTtDg0o+grEl7S/GhjSV3Z/Nb0nM6/AaW44QKChTU5Y4frU7DB22zv70LYgr2J/cJk 29BA== 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=sqyaBE98FYB8axNLEXIjvQfrZv0DOenHRR+evuteJ6s=; b=LNihyOsiUgHnAgOip8Qtlsm/Q28MN2icl9qu5OdgGGH46y864D/eW1cmb3hOlO4z5S tyl+zYqbvb8m1Xr6lED/qYkPF8CnF2R6uuVfQBkuySJykLhpw4Mmi7NRovKpwr1QUp/q zmoqr8MjF/+0ls8yMJjwYcabV/NIkQs7/NK7n46t10gKs+EfPLepSWhrOk0ami/0QqRj 0GXZ2TqSqfZEMQSzzuG3QECYcP2eAM97XA31WxajmQfWHYnlZFvlhWeguvIXI7trxznW gTTPeflvOT70YRnI40aqjhIkLyztQgKiQzZmxUxHqkgFPHE/RmiKj1Caaoq47KK7ugL0 jgCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SSnWhQ+e; 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 cw13si15709089ejc.195.2021.07.11.23.40.13; Sun, 11 Jul 2021 23:40:36 -0700 (PDT) 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=SSnWhQ+e; 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 S237380AbhGLGjZ (ORCPT + 99 others); Mon, 12 Jul 2021 02:39:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:54744 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236143AbhGLGbv (ORCPT ); Mon, 12 Jul 2021 02:31:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 86A32610A7; Mon, 12 Jul 2021 06:29:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071343; bh=RCjUG2JQ5Fn9D2AgnyWAr3vvbV9vOEIeYuaB+5de45g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SSnWhQ+exMXOyizZoBPG10LEIHNAYHp8ZXetvn8KQskHAAvos8w7/wWRgyZEB9rFJ EAI+q31/zgAzXULNcuj/hlNYTj4A0T00qpwuk2QmcWnz8p4iJ/fH/I9/6ZaPF2d1cj 0terCi/fO8j/YsyVRgAKX9Cz+Xt8Cm2lgn8azZ6M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guillaume Tucker , David Laight , Kees Cook Subject: [PATCH 5.10 030/593] selftests/lkdtm: Avoid needing explicit sub-shell Date: Mon, 12 Jul 2021 08:03:10 +0200 Message-Id: <20210712060846.491571648@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@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: Kees Cook commit 04831e892b41618914b2123ae3b4fa77252e8656 upstream. Some environments do not set $SHELL when running tests. There's no need to use $SHELL here anyway, since "cat" can be used to receive any delivered signals from the kernel. Additionally avoid using bash-isms in the command, and record stderr for posterity. Fixes: 46d1a0f03d66 ("selftests/lkdtm: Add tests for LKDTM targets") Cc: stable@vger.kernel.org Suggested-by: Guillaume Tucker Suggested-by: David Laight Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/20210623203936.3151093-2-keescook@chromium.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/lkdtm/run.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/tools/testing/selftests/lkdtm/run.sh +++ b/tools/testing/selftests/lkdtm/run.sh @@ -76,10 +76,14 @@ fi # Save existing dmesg so we can detect new content below dmesg > "$DMESG" -# Most shells yell about signals and we're expecting the "cat" process -# to usually be killed by the kernel. So we have to run it in a sub-shell -# and silence errors. -($SHELL -c 'cat <(echo '"$test"') >'"$TRIGGER" 2>/dev/null) || true +# Since the kernel is likely killing the process writing to the trigger +# file, it must not be the script's shell itself. i.e. we cannot do: +# echo "$test" >"$TRIGGER" +# Instead, use "cat" to take the signal. Since the shell will yell about +# the signal that killed the subprocess, we must ignore the failure and +# continue. However we don't silence stderr since there might be other +# useful details reported there in the case of other unexpected conditions. +echo "$test" | cat >"$TRIGGER" || true # Record and dump the results dmesg | comm --nocheck-order -13 "$DMESG" - > "$LOG" || true