Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5807514pxj; Wed, 23 Jun 2021 09:19:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpIoElneQRu8tRKnYIGplFW3sQAH3s7KlbmxIZgbURh9Jpe5t5fEAL03W72YG65ADNz1sF X-Received: by 2002:a92:b50d:: with SMTP id f13mr138569ile.253.1624465185064; Wed, 23 Jun 2021 09:19:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624465185; cv=none; d=google.com; s=arc-20160816; b=sC44gq/5u1cEKg8x7u71UOh4JyRgsRmOlB7Ur33DK7suxD6vQYa1SMRDr5+nxQR6u3 hYPjqMlCOmhoU41A1ZpnRb21MrCcH/Vbzd8/U6ooRrfR57plhtyKY3k5DAudVdqvU71L DWeXQXFGmMdkn62uGkg1bYgdXNrBGSH6AFSfoSoU7Xd8m+A/xE4Q7N0S3NUFXe2fHzQh ZlsHiZHppvU5d1NT4PASfXAKTkmWKlxXQryGiW/udEAO1sWLSStgbSECN6JPrn8vG7fz xaVIKQ7nqOxNn4ILPHUG9YAnWyxZUKoWZc4FPB7BummJ1I/z3JaireXPDIUfjAqy/b7e 4Q9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=rhZzXtsZWfzXc61E37Y58HMAKueOCl1cxiUTemZwhBU=; b=hBsPBXSU76Dh65nQMnQ4DLwyxJ3eW0divha3dedvUiK1Do/hOTml2MAKJLXlcqd3VV YRMQYMn+aLeogI9rgEtLfJdai7+5U8LT31P9vczx+Ig2KAkoGhqU/JIIEk5/4e2HtUUV exFZAuhUAcfYRux42I493YyO+tf702Z0f/6l4ox1Z0xV4/xV8kV5ZC1I+dkKVi3jnK0l kpYQu0I8HH1v7VRzTpIil3FaX7X+g3okgOisrozdDjb1UBlfUnnd0XJkxt4z9h+vbKXZ QrvPNnWxLM4zhcFs7XMoB30tMYm//MlCswYsm6zwScEBHkysReC4kdfyT139m992OnXM thjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dH3chPBB; 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 x99si333116jah.122.2021.06.23.09.19.27; Wed, 23 Jun 2021 09:19:45 -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=dH3chPBB; 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 S229660AbhFWQVG (ORCPT + 99 others); Wed, 23 Jun 2021 12:21:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbhFWQVF (ORCPT ); Wed, 23 Jun 2021 12:21:05 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1489C061756 for ; Wed, 23 Jun 2021 09:18:46 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id z3-20020a17090a3983b029016bc232e40bso1680021pjb.4 for ; Wed, 23 Jun 2021 09:18:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=rhZzXtsZWfzXc61E37Y58HMAKueOCl1cxiUTemZwhBU=; b=dH3chPBBa5s/c/kTTWhH9cTfQGuIHgt6buqYxYnwEqzVCEmuavirXgMY0jnzWzrhpf FK8uGYEmwOjOuasjcAutd5ga7BMVZDFtJrfwPCEPGoiBq+FnZRea4SQmaQyFa+0CNfrF sIjbKxy0LAM5hoYzEP2pje/v101mH4cfysi68= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=rhZzXtsZWfzXc61E37Y58HMAKueOCl1cxiUTemZwhBU=; b=JIJ8WzecZqh8tkqcNYo3qFvJxNC2P5QXlIyxbhPWz/Qv9LPBM+e5SjEOTpc0H/HtY2 hG6GGZwYN8gqq7Gp4Ks7zMrDAfPkJsGwJmezoFdMMbyBAsfdGswedKUowKFMcUC8q+RU T2+ZaWySND3rrza4IjGT8bkdoz+M4nFhv5TPAz81dOWlwA+xj0/XGNHon1rItF9+4IXT fceSsa1WlVtCjM5ya8It0+On6IA+MixPu46zZdZJVfZQ1u0eB7YgkvlVqMCUqAmf7so2 sgxgbTVh5rSoliJ8DAF1CgxGNiDmAJV34HeyhXmWinyx1sCnO8wF8uXXzqF4eDO68hBa losw== X-Gm-Message-State: AOAM5318nGA7oIZYjf8evLaBsXT7Y7MV5IcDcv8Opm9fjP1I3zJ7v3N7 YXWANzX75bhdnV8xsc2NlK+h5w== X-Received: by 2002:a17:90a:c002:: with SMTP id p2mr10127839pjt.132.1624465126002; Wed, 23 Jun 2021 09:18:46 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id lp1sm133183pjb.44.2021.06.23.09.18.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 09:18:45 -0700 (PDT) Date: Wed, 23 Jun 2021 09:18:44 -0700 From: Kees Cook To: David Laight Cc: 'Guillaume Tucker' , Shuah Khan , "stable@vger.kernel.org" , "linux-kselftest@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2] selftests/lkdtm: Use /bin/sh not $SHELL Message-ID: <202106230917.FE2F587@keescook> References: <20210619025834.2505201-1-keescook@chromium.org> <42f26361db6f481e980ac349bf0079ef@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42f26361db6f481e980ac349bf0079ef@AcuMS.aculab.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 23, 2021 at 01:43:04PM +0000, David Laight wrote: > From: Guillaume Tucker > > Sent: 23 June 2021 13:40 > ... > > > diff --git a/tools/testing/selftests/lkdtm/run.sh b/tools/testing/selftests/lkdtm/run.sh > > > index bb7a1775307b..0f9f22ac004b 100755 > > > --- a/tools/testing/selftests/lkdtm/run.sh > > > +++ b/tools/testing/selftests/lkdtm/run.sh > > > @@ -78,8 +78,9 @@ 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 > > > +# to avoid terminating this script. Leave stderr alone, just in case > > > +# something _else_ happens. > > > +(/bin/sh -c '(echo '"$test"') | cat >'"$TRIGGER") || true > > I was having trouble parsing that command - and I'm good > at shell scripts. > I think the extra subshell the 'echo' is in doesn't help. > In fact, is either subshell needed? > Surely: > /bin/sh -c "echo '$test' | cat >$trigger" || true > will work just as well? Ah yeah, and I just tested it to double check, it can be even simpler: echo "$test" | /bin/sh -c "cat >$TRIGGER" || true I'll adjust and resend... -Kees -- Kees Cook