Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2833046pxv; Mon, 12 Jul 2021 03:04:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybUZF2DBzksRZRM+ppyKm4HOnGbrLkTsBqaI3N7Ic+ke6umsKz7vidpetSQce+jwJ6a3Eb X-Received: by 2002:a6b:f704:: with SMTP id k4mr39310713iog.191.1626084278583; Mon, 12 Jul 2021 03:04:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626084278; cv=none; d=google.com; s=arc-20160816; b=ODRUQfzzIBRpoJfvfv4IWiF7dKdMmBb86PGR4RrW3qT3qoPN/dzBOXVAF394OwFXdi 1xb2U8vO8VJ+Vjedg9hh9mY8leCey4T5jPRF7QYDftloRsF8MABO5TLgcAf9W/kRYXkF Nm75gnMwjHNHyR/+5ooOtzPdQBzIeoE6vhkFi1CHO5GkUvmWu2+zW68zUFhmJGUbd9yA IuAJ9Deog8vyH957dtIlppQjKKt8JzKPxD6PyjGMT1b8ApjYzRL9ZtplH7ySK7ndeirG 2Izu6FUxCYSNEglR3z+j32h94nOqV4kayRH+gzVAQL4BhwpqaQu/Y/SUASA6VysERzra CDiw== 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=mDIO6toYhsxb+zyWN6QFe45ywuc9tDgvVpFD1+07mTVVztbnDndN75WlrPtyyJzU7t EjYl21DuAq2ijzXH367qYsOshvLWDZ+cnUB3c8D7BYs0kpexTTvnYhNYfP9STC+A2OgS 1LQ5Ejqem1YbW4qR/flH4wRivgJ+h04ipdIzp18983xzfmMLl0h5TPSVDZmbKj0Vmh81 F9H0BW2UtU7VXuBV8QMbtMEh6FmMBzuDh6WjjS2uccHIopicbl9CEYSUDY7GzlReGi4X 3Z4LTmwwIiIZuwz4i+LgbniASIlpfXCGfiVF3DoraV/LHodYbc5rROevU4BJou6iTFWy stCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oFn3lwk1; 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 b12si15962703ioj.88.2021.07.12.03.04.26; Mon, 12 Jul 2021 03:04:38 -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=oFn3lwk1; 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 S1345368AbhGLHZV (ORCPT + 99 others); Mon, 12 Jul 2021 03:25:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:33308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239955AbhGLG6j (ORCPT ); Mon, 12 Jul 2021 02:58:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 426C261380; Mon, 12 Jul 2021 06:55:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626072951; bh=RCjUG2JQ5Fn9D2AgnyWAr3vvbV9vOEIeYuaB+5de45g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oFn3lwk1OxXYuvmi2+XFq3PpBSqzotW0Gaqm5p0g8dAv2jn3wYW9gveQkCmZTUl8x Qt5v26WB3pNcmhk2LDcByUwO1ITwT4pt5SrXWQ/zRNLPpMs8rShsnsokgb0npFTM8G HE1RPrIBrRyD5BVTjVDvKqgF9af6JjYGJdZMbMTM= 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.12 033/700] selftests/lkdtm: Avoid needing explicit sub-shell Date: Mon, 12 Jul 2021 08:01:56 +0200 Message-Id: <20210712060929.311193615@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@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