Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1147077rwb; Wed, 16 Nov 2022 12:49:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf64LJlv/PftdGZdSrq+AVxNuhKA34jJlNRQRKEY1vBFzsV/NJFPB6LwD4AM9VFuq3pNuMEN X-Received: by 2002:a17:907:98e1:b0:7ae:f441:6ade with SMTP id ke1-20020a17090798e100b007aef4416ademr12944506ejc.436.1668631779557; Wed, 16 Nov 2022 12:49:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668631779; cv=none; d=google.com; s=arc-20160816; b=FXawIu2T/dgJ9MxXgZdcsiaH1rVjmOesk69QMBP4K9inyZIazgCN4vzq/eCrPXAW1E gZw3LBpGklsjs/B9bnVpYgYiT7R2a4trkEj2PiX57PtKRxWmjGIhAmda8Q42hFw6sqT8 LCDPbtpjzS1Q1GbMY3oGMIppeHBdFSx4Rq7dpvxmknUbJfZx7dYmKI9tCPZ2ks/UDa0O 21bfHVn5RMoPDiI1OYh+vdYYtG6JwMkE47xBkyXVTILqpuPVanLzqxLxl+gTvEMJzkMe B4nwBGk++l8PaH2ZSBlRxK676tYr6j7r5YcS4/ROaV1fP+x403coC60fEo+Zr2R++/2T hnZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature:dkim-filter; bh=c7CHuhEkcILYlod524PGOT/hdlG/esbc7n/dEx43MCg=; b=qw3cXm7a6ILqKMruUHSEJuRuud7AlB2JG1O5zPQ5PGkpP7YTu8U7ZtRpUbI3sh8R53 xktDSkLDi4GH26q4hf/S4Ix9nqozJJdywOL3HTOwzYFzEcODEWpveQIO3NBYKTtWbqfq WDwaEtCJUQxJr6GRx50KbOoAlMFRD1MTW4YC3r1v0tjw0Cdm5aeMO64+qserXUM4Ow4I 28IF+hIUHrpNVkqnPrNviZHO9kOVm52klfZ8feKbECqwndAhkPcHM5HDg7uYVd1qnkKF NcAomg2grhRxjNC5EqC161e2aHcVztlnrks7PmZmLPLHObkb1d1+VVwTJAu6NO/F1kAk yymQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Rl7XjlFm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x21-20020a1709064bd500b00780e89ce0b0si11528117ejv.600.2022.11.16.12.49.18; Wed, 16 Nov 2022 12:49:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Rl7XjlFm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234031AbiKPUii (ORCPT + 90 others); Wed, 16 Nov 2022 15:38:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233641AbiKPUia (ORCPT ); Wed, 16 Nov 2022 15:38:30 -0500 Received: from conssluserg-04.nifty.com (conssluserg-04.nifty.com [210.131.2.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06252EA3; Wed, 16 Nov 2022 12:38:26 -0800 (PST) Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) (authenticated) by conssluserg-04.nifty.com with ESMTP id 2AGKc80C003458; Thu, 17 Nov 2022 05:38:08 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-04.nifty.com 2AGKc80C003458 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1668631088; bh=c7CHuhEkcILYlod524PGOT/hdlG/esbc7n/dEx43MCg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Rl7XjlFmmOZyOTwUmKDz97vVfo1RSfJB+BDQppKrZuXnHlIGgqKvNkB4y4JtL8w9t lRI/YyS9+fMTNzRoTwnLW+dPpKaw2JQn87aNhY7+/widowFmUhLrL8bnHNaGH1Eq5P w8QucvurLElJWmxeWRlNFBlLRzywJbsgKKlFTftLHh3tHTCY6gCxoeLeyBXz+d136P KyUorvVg31SvGrn+mPdF5wlyprs2jrGMMRKDDm7MhLlpwwevS16fEWEIr2CnKLfuYk dke04EqQiLN89F8EHP3bTcGevS/AjAdLmhF00CAfTWauIoQUnlPp5XdmEfazjInV+T OteBsD2RxFWkw== X-Nifty-SrcIP: [209.85.161.42] Received: by mail-oo1-f42.google.com with SMTP id r10-20020a4aa2ca000000b0049dd7ad4128so2675295ool.13; Wed, 16 Nov 2022 12:38:08 -0800 (PST) X-Gm-Message-State: ANoB5pl7xkAE0uufHBYuSZwvIUnIS+IB1zydqNpbkDJDut11+tUkK6aG MaITemnwpQ8MmcRC+QZJU51h1vXUDKh5pukEecU= X-Received: by 2002:a4a:dc13:0:b0:49f:87d0:ef5c with SMTP id p19-20020a4adc13000000b0049f87d0ef5cmr4521997oov.96.1668631087318; Wed, 16 Nov 2022 12:38:07 -0800 (PST) MIME-Version: 1.0 References: <20221027162839.410720-1-masahiroy@kernel.org> <202211161056.1B9611A@keescook> In-Reply-To: <202211161056.1B9611A@keescook> From: Masahiro Yamada Date: Thu, 17 Nov 2022 05:37:31 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] kbuild: fix SIGPIPE error message for AR=gcc-ar and AR=llvm-ar To: Kees Cook Cc: linux-kbuild@vger.kernel.org, Jiri Slaby , Nathan Chancellor , Nick Desaulniers , Michal Marek , Nicolas Schier , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 17, 2022 at 4:01 AM Kees Cook wrote: > > On Fri, Oct 28, 2022 at 01:28:39AM +0900, Masahiro Yamada wrote: > > Jiri Slaby reported that building the kernel with AR=gcc-ar shows: > > /usr/bin/ar terminated with signal 13 [Broken pipe] > > > > Nathan Chancellor reported the latest AR=llvm-ar shows > > error: write on a pipe with no reader > > > > The latter occurs since LLVM commit 51b557adc131 ("Add an error message > > to the default SIGPIPE handler"). > > > > The resulting vmlinux is correct, but it is better to silence it. > > > > 'head -n1' exits after reading the first line, so the pipe is closed. > > > > Use 'sed -n 1p' to eat the stream till the end. > > I think this is wrong because it needlessly consumes CPU time. SIGPIPE > is _needed_ to stop a process after we found what we needed, but it's up > to the caller (the shell here) to determine what to do about it. > > Similarly, that LLVM commit is wrong -- tools should _not_ catch their > own SIGPIPEs. They should be caught by their callers. > > For example, see: > > $ seq 10000 | head -n1 > 1 > > ^^^ no warnings from the shell (caller of "seq") > And you can see it _is_ being killed by SIGPIPE: > > $ strace seq 1000 | head -n1 > ... > write(1, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14"..., 8192) = 8192 > 1 > write(1, "\n1861\n1862\n1863\n1864\n1865\n1866\n1"..., 4096) = -1 EPIPE (Broken pipe) > --- SIGPIPE {si_signo=SIGPIPE, si_code=SI_USER, si_pid=3503448, si_uid=1000} --- > +++ killed by SIGPIPE +++ > > If we use "sed -n 1p" seq will continue to run, consuming needless time > and CPU resources. > > So, I strongly think this is the wrong solution. SIGPIPE should be > ignored for ar, and LLVM should _not_ catch its own SIGPIPE. > > -Kees I thought of this - it is just wasting CPU time, but I did not come up with a better idea on the kbuild side. I do not want to use 2>/dev/null because it may hide non-SIGPIPE (i.e. real) errors. I think you guys will be keen on fixing llvm. I hope gcc as well? -- Best Regards Masahiro Yamada