Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp740162pxk; Thu, 17 Sep 2020 15:09:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKWA/4WCfQawd/u+O/qSArMecGvQtOm5iMLgLPinMWsKH7LRrqKTz2yQsBd04GqxR6dP61 X-Received: by 2002:a17:906:2b83:: with SMTP id m3mr15044882ejg.456.1600380543247; Thu, 17 Sep 2020 15:09:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600380543; cv=none; d=google.com; s=arc-20160816; b=GUF7a6rEH7TXtk7/tkxB+6wrZsqmZofTQKMNWL+tUzQZIiKqrZuX5u3/Xj6d3DHnrh Ac23MinbBtvnYlJZQmO6nL4UYWKvr7rDxC2+Y/0VVDp8CWIhpUusIJ1vrEbJwUHSgGM/ 2CPQWhYp2c38mj1Qn0NmABgfttaJV/PoFTDP//74LFQraXcPhfhH7A/TS0rqOJ17Ugg3 LrhX5jNVQXZI82Ykv4K7dI4wh6M2lbN3tJ6zh52Uhint4WTGcvq7KUhwVMtly5D+GXcq HkPTc3uRMeSE7HQOj3h9dy8CIOfD3ouks8L+uSDOzWxlAYpTzK8dUEubVm8MDkTwztAH V13g== 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=ZbCBEdq8KnsqpsS4hwIyptSV65b1idGsJpvWf9x1kWE=; b=0qxZR+yqBohLEN7iHHl+Y8WrL5zzLIyUbksE+SD6HxuDOXDz7gaTHWdAjcByti2O7b KL8Wo/W+Lru1HuW71LkTjsSwjVNRAZts0UDBRX8MKGoOzZGr9YrHzBlc2OlduQ+d2YJk YLozJRAEjgmSYi0/lVQBtvNWeyCHWIhal9kCn282REjhqDW43xVHjI2lSujScE6UcM0U UmR0U1pmEuaPck0R6YLxawoazGSfKpwBv1fqKv4lOy5M56w0EapxKYF4MlHX2D+8SVWv q1S2Wa5oP1fRz+YxCTYvThz01+2tcRcjV7NkSLdO202+qHl91Ve+0JZLsOFBoPXp2xRo Ihzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KjoJhWyx; 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 u11si832370edb.155.2020.09.17.15.08.40; Thu, 17 Sep 2020 15:09:03 -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=KjoJhWyx; 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 S1726112AbgIQWHi (ORCPT + 99 others); Thu, 17 Sep 2020 18:07:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725874AbgIQWHh (ORCPT ); Thu, 17 Sep 2020 18:07:37 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 928ABC06174A for ; Thu, 17 Sep 2020 15:07:37 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id a9so2022850pjg.1 for ; Thu, 17 Sep 2020 15:07:37 -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=ZbCBEdq8KnsqpsS4hwIyptSV65b1idGsJpvWf9x1kWE=; b=KjoJhWyxpjl6/1j5XZi1G6b1H4FHP4Jk7mq8yX/aKnzkjlTFoO0R6TTKvIJC75vWip cgKUWONQ39ZjHRbpEZ0RlgW28n+mUx9G4bMtuddc5U2pnvJjDC0t/kI/+vj5h5CDncA+ n6k72TZQrlo8nUg75GwDZ97PDuacdmPKR6M9U= 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=ZbCBEdq8KnsqpsS4hwIyptSV65b1idGsJpvWf9x1kWE=; b=jnmZRxNEvCJ5a+4t0U1cQt4wJ9ZKHb/vnbsriZ4rWMJ4N9Ofc0Xr0btVHqS/NIghq3 QcemnVcJfIeOlZrzOA3BYFIApH3PtGm+IT8Pjye7NSRkgUY00RPd2pV9nUfYxBt9YNrr +Ng9ntaARl/WCLIsaWUWIASVe9zhAzpOlRH2Fho0RuyFYdj1HjDemcMJ+G3GzPLuA09A KItvw8vDbM18d93Gw+egHBJkXP9zwF8pNViwXoA9MLcUdsX7duuFn2YFmQXv+tpVrOAb ySJ/4+OuZPL46aUlUixfB+wPFqjjEBgCya+puHpf16cF3qUXUOLKvC33SfsnKgMsnVGr iOTw== X-Gm-Message-State: AOAM530LdEJIvUBYtWK2ZFjr5I7Ie8QKPv/6DNGzBwx3g8MuDIi81/Ps ZoAeHIz52g7ofDmZFL2KrNRcIw== X-Received: by 2002:a17:902:c20a:b029:d1:e598:400d with SMTP id 10-20020a170902c20ab02900d1e598400dmr12681703pll.71.1600380457211; Thu, 17 Sep 2020 15:07:37 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id a13sm592214pgq.41.2020.09.17.15.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 15:07:36 -0700 (PDT) Date: Thu, 17 Sep 2020 15:07:35 -0700 From: Kees Cook To: Michael Ellerman Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, jcmvbkbc@gmail.com Subject: Re: [PATCH] selftests/harness: Flush stdout before forking Message-ID: <202009171506.7147F47FE@keescook> References: <20200917041519.3284582-1-mpe@ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200917041519.3284582-1-mpe@ellerman.id.au> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 17, 2020 at 02:15:19PM +1000, Michael Ellerman wrote: > The test harness forks() a child to run each test. Both the parent and > the child print to stdout using libc functions. That can lead to > duplicated (or more) output if the libc buffers are not flushed before > forking. > > It's generally not seen when running programs directly, because stdout > will usually be line buffered when it's pointing to a terminal. > > This was noticed when running the seccomp_bpf test, eg: > > $ ./seccomp_bpf | tee test.log > $ grep -c "TAP version 13" test.log > 2 Oh thank you for tracking this down! I thought seccomp wasn't killing a child or something, and hadn't found it yet. :) Acked-by: Kees Cook -- Kees Cook