From patchwork Thu Oct 21 07:47:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 46472 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 167D03857C71 for ; Thu, 21 Oct 2021 07:47:54 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id CE0253858D39 for ; Thu, 21 Oct 2021 07:47:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CE0253858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BD2DA2198C; Thu, 21 Oct 2021 07:47:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1634802456; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oaxjOZOcze9x8eKuuSWs825KwDfyD0cNUbd7qdLgi/g=; b=srHlYCLbqGTYucZjWFWaMWz19Sldb1ue+iYKpM7mYtH5HbRmueaJRxgrMaW1ytlY7/mddD xX2jeqFuEPr8QaE41xvJjO+MO0EfisY4BBxaB2OyQ3Eno646AzCktQ3bPSAY7/4MQQ45G6 n8BnpudlRL2sfu5ZmRD4WlY33HdNEAM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1634802456; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oaxjOZOcze9x8eKuuSWs825KwDfyD0cNUbd7qdLgi/g=; b=/fhLlzvt7mN0GW4B+bGgoOzVzjMxUDrcIfhoiUVZxGuAyzi/Vvs4hVN+DDPrJeZC+2ne0k Mu3k1j2idmXRcoCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A9AC513BBF; Thu, 21 Oct 2021 07:47:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id QCFPKBgbcWGsGgAAMHmgww (envelope-from ); Thu, 21 Oct 2021 07:47:36 +0000 Message-ID: <88d036b7-5304-3673-318f-2ebc159c8b16@suse.cz> Date: Thu, 21 Oct 2021 09:47:36 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] Handle jobserver file descriptors in btest. To: gcc-patches@gcc.gnu.org Content-Language: en-US X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ian Lance Taylor Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi. The patch is about sensitive handling of file descriptors opened by make's jobserver. Ready for master? Thanks, Martin PR testsuite/102742 libbacktrace/ChangeLog: * btest.c (check_open_files): Ignore file descriptors provided by jobserver. --- libbacktrace/btest.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libbacktrace/btest.c b/libbacktrace/btest.c index 9f9c03babf3..a1ea93728be 100644 --- a/libbacktrace/btest.c +++ b/libbacktrace/btest.c @@ -464,9 +464,25 @@ static void check_open_files (void) { int i; + int rfd = -1; + int wfd = -1; + +#define JS_NEEDLE "--jobserver-auth=" + + /* Ignore file descriptors provided by jobserver. */ + const char *makeflags = getenv ("MAKEFLAGS"); + if (makeflags != NULL) + { + const char *n = strstr (makeflags, JS_NEEDLE); + if (n != NULL) + sscanf (n + strlen (JS_NEEDLE), "%d,%d", &rfd, &wfd); + } for (i = 3; i < 10; i++) { + if (i == rfd || i == wfd) + continue; + if (close (i) == 0) { fprintf (stderr,