Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5988317pxj; Wed, 23 Jun 2021 13:40:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw67HCRF+xPOLX87/2TaHmIqcVSDCs7YeDaAtwlZKSOwQd8n8XO9FAzwGvc+qM4sPCyPhKq X-Received: by 2002:a05:6e02:8b:: with SMTP id l11mr964780ilm.228.1624480848596; Wed, 23 Jun 2021 13:40:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624480848; cv=none; d=google.com; s=arc-20160816; b=Hg8J/huk0xpwc5eQIl1y8IBGplT4+VyVN4eVxTYyoG1S8tHm1A6oz6/sdaslVcea1R CDlelgJFU8D9j15P2zk+lA+9J+N9+5zAAw3ySUSGC12CXYDbhlTmF2HXNgfoszxXFNL7 BR+nKWjnZm2FhM3rO2GvUnwj/34ND7UJRFiBrF8ortSAku6Y7zlSI6GesFa4Ar+Ea4js VgydGeOkNfm0TzKT8ARJfam5gKmir/XEt2+c5fyT/kNW6hJZo3zs776/WWHr5C9Qmed9 +qE3CXXNPewwPG2KUaKGRhHuHnneZI0xTGgTQfQdGAHcCbe95i0k30BT7boea2uxZBfw usPQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=a/NHLnzJB2ygZFZV6tY0zJmtOu+fbM3j2iEZapLwC/A=; b=oJxtGDoYDY45jeyLejE7mzIjZpHZbp2CR33wYtbmtJid4vPSwEX65rtCGolgM9cs9X sA7qHh6GPQ+oCEDB87YLLkbl35iEJmu19oY3udPnnbi+V0XqcI4QxRyTkmQhkipHL9qL FxRH9q4tlzryYl0XRmXqNx5QGUXOToehnLQpYwrqdSaOaaI8ZF+fl1SGx3+RCwpcFy3T B7xLiY+8MFTlEBPtdchxR90rpHAkMGu2h7hTGTWbME79eR4DW7g9PzKN14AyqrOeAMW4 qIpEC4mruwf5lw4uobRNZgKt/Bkv2NKl+C406+cMTNcBWxrguojisQMjXX3BmxMHRXa9 dPRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="I/banPaT"; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r7si720286ilg.41.2021.06.23.13.40.36; Wed, 23 Jun 2021 13:40:48 -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=@chromium.org header.s=google header.b="I/banPaT"; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229948AbhFWUmG (ORCPT + 99 others); Wed, 23 Jun 2021 16:42:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229818AbhFWUmF (ORCPT ); Wed, 23 Jun 2021 16:42:05 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D4DDC061760 for ; Wed, 23 Jun 2021 13:39:47 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id k5so2187548pjj.1 for ; Wed, 23 Jun 2021 13:39:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a/NHLnzJB2ygZFZV6tY0zJmtOu+fbM3j2iEZapLwC/A=; b=I/banPaTpbTehL6OdlALe/IibBFT5OlgTdWS6XNKoIoXm+GiZtXArwzsPg+rtwRkgg NmrSVIMu+8EuZ9CYJ01zzWl4kbE+LLteCDRjIKB9SxVkzoI6SWm+GokpeXxJUhilXbxr V3BTbXTDX4uqb6Jl4nP19anmnYosCw2t8IZxM= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=a/NHLnzJB2ygZFZV6tY0zJmtOu+fbM3j2iEZapLwC/A=; b=mCbCrsHinjqNFRvqWFLIOCnJrNNapMVtlGCJgKx0LE0Hu9Rn/nDwwaLrNFoht8QZHJ DpERpcMxgj2pTcQdP9wLX3DunnkFvluaqUiW5sRfYmlCsaGdhK7c5TZnEkGLetcMrJsO ifhrCU6313rabjP6zMYnBslFnTDJM9cIxAwdZzM/90itPzX/SEX+n9bTYQnIaIpjryci 94cmdLeX98r99xqdeMGZ8Onj1+4gbovPriwr2UzVCqRcrHoYrITeKXkrXzAhm3Fs10IN IOGYam8SPZxQuosNZ10HSu/zopLGi5pf7DMasc/xUeLuhglNh7roYgrhXO6gHU8QLaEs x7pw== X-Gm-Message-State: AOAM532uGCDDGwHFl+656R96lxvYefF/jP+DHW0O2ksOeCRT5nqyjO7O LUD56qEE09MS3f4lhH/eqjhgJw== X-Received: by 2002:a17:90a:5a08:: with SMTP id b8mr11356642pjd.228.1624480786915; Wed, 23 Jun 2021 13:39:46 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id u23sm9942pgk.38.2021.06.23.13.39.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 13:39:45 -0700 (PDT) From: Kees Cook To: Greg Kroah-Hartman Cc: Kees Cook , Guillaume Tucker , David Laight , stable@vger.kernel.org, Arnd Bergmann , linux-kernel@vger.kernel.org, kernelci@groups.io, linux-kselftest@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH 1/9] selftests/lkdtm: Avoid needing explicit sub-shell Date: Wed, 23 Jun 2021 13:39:28 -0700 Message-Id: <20210623203936.3151093-2-keescook@chromium.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210623203936.3151093-1-keescook@chromium.org> References: <20210623203936.3151093-1-keescook@chromium.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1841; h=from:subject; bh=AmOgu4HWdRZorYqBFRSjQNwNv37L2JYo/PWnXeJW7vY=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBg05wFY5oavND7smh3PFgLH+LKjB2fUh5OHY6bWTIk eYMshS6JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCYNOcBQAKCRCJcvTf3G3AJvtJD/ 9G+j8CKarzbS3nY6L6aaVmdftLkiLrU13NYZGNHPstjHi6Lx9CpHpJ+QwK8wc78agXMWUB/r+L8qLk s5gPPethiYZV3QumjnWFZ+gj2T/Xoz+EbjLOWntVMv9mjstH5+5/e/VcX9vi3N56IBFqOT/OAyrw6V piyzsjxVP6elfNaUtfASxPcXo5H7zZVums4Lnz/S7qok5qi+zmFuE9cxdfPi1g5YHAdw8uxX76SDgD hoV+UheZw8Vf76IBrTdkW9Jp46PrE+jfJrWT6bx2II9gX/ukVqaMFNd4OMh/CyptWTqAdlnB165u2o dy3BZ1goom8Vqgcw5HC4Xyvj6RHMejdsHAwvZi1eykN7tOV2Ad3VciAb5zpVW0aw6N6KFim54cJhF+ 6ZEq4G2peIhgqpOiJQeN3nNjM19grUPTa4eG/YYfxZxPmhW9BgnimjjelWxx2V2bEUMsU5WvOOOhKl 3av97w61teJaEc5UTni4zXrsFfROtUVxxWtGT6W++WLxeHaIFjxiNKPOUNqIF8xNIDbfy5mnHt7dp6 qzq+WOtPvEmqbCZQ/qsVUVxIbAaVUSoNjmrIU5nCypQyLphJMqKBzn/qDVtewgDbXOT8Np07K7fFns ceDGvDFjboNdC3WG7S0yN+Pj+kveweqXC8AKB5TUR06NIKYA8nA74XD1efAg== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Suggested-by: Guillaume Tucker Suggested-by: David Laight Fixes: 46d1a0f03d66 ("selftests/lkdtm: Add tests for LKDTM targets") Cc: stable@vger.kernel.org Signed-off-by: Kees Cook --- tools/testing/selftests/lkdtm/run.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/lkdtm/run.sh b/tools/testing/selftests/lkdtm/run.sh index bb7a1775307b..e95e79bd3126 100755 --- 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 -- 2.30.2