From nobody Fri Nov 14 18:05:12 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589526155; cv=none; d=zohomail.com; s=zohoarc; b=NmNGa6RpS5gsAXVtRMOIo40isGJdVtuQOWR8Uke0ZrpO4rwjdZMzHhT1lVhQU37jPJmbKAR/7+R2zQYEAeDLAnjeUarv07FzerOvnujW4QCDhL/IqiU3KMfisKwInyKRGRcIg2GLymrzbD/fa9Oo9TmquyB/VcDBRL1pipMMfKI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589526155; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=aC8pWJBY6ijAmmCp4CjAAiCuwem6djCmzySsAduGvbE=; b=NVFMKMNJx1nlK6w4IDu0z/8sfS2IfQ+125FaFu9tWxfF5ul0u10D+4oL3Jcquqiy2xBbBBhVQ4i9Q3ZheySJHLHNxZCwC3zquf4Rit0nBDCo38scZIGYxbLoGUVJqSQQZgVMeQtxZlcjTqByrok161nrA/SyNRfSKbaTc/jJfYI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589526155763100.81565750139293; Fri, 15 May 2020 00:02:35 -0700 (PDT) Received: from localhost ([::1]:59184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZUMb-0001lQ-Cl for importer@patchew.org; Fri, 15 May 2020 03:02:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZUKg-00082G-44 for qemu-devel@nongnu.org; Fri, 15 May 2020 03:00:34 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:37059 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZUKc-0003IP-KM for qemu-devel@nongnu.org; Fri, 15 May 2020 03:00:33 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-401--Yh1VvTFPum-tLa4pnvYtQ-1; Fri, 15 May 2020 03:00:27 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5F13FBFC6 for ; Fri, 15 May 2020 07:00:26 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3BF342E16C; Fri, 15 May 2020 07:00:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BAF9111358BC; Fri, 15 May 2020 09:00:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589526028; h=from:from:reply-to:subject:subject: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=aC8pWJBY6ijAmmCp4CjAAiCuwem6djCmzySsAduGvbE=; b=QWSqR+Dtvd2nWYTSusGI7SU8YVs5oU6ozgIyO1Cb5TH48qqV/qtcIGhQkYTtqiYuWpkssk A5tR76LMcKtZ+cLSF+Req0qbEzaNJRNF/pVPzBI4IpKxNiYhkQEmc1XaCOc/o2/TKFH4zG ZUdJxY5uPozwD/MDEozU2fHv8WGY1qA= X-MC-Unique: -Yh1VvTFPum-tLa4pnvYtQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH] trace/simple: Fix unauthorized enable Date: Fri, 15 May 2020 09:00:21 +0200 Message-Id: <20200515070021.20811-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:39:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" st_set_trace_file() accidentally enables tracing. It's called unconditionally during startup, which is why QEMU built with the simple trace backend always writes a trace file "trace-$PID". This has been broken for quite a while. I didn't track down the exact commit. Fix st_set_trace_file() to restore the state. Signed-off-by: Markus Armbruster --- trace/simple.h | 2 +- trace/simple.c | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/trace/simple.h b/trace/simple.h index 5771a0634f..26ccbc8b8a 100644 --- a/trace/simple.h +++ b/trace/simple.h @@ -12,7 +12,7 @@ #define TRACE_SIMPLE_H =20 void st_print_trace_file_status(void); -void st_set_trace_file_enabled(bool enable); +bool st_set_trace_file_enabled(bool enable); void st_set_trace_file(const char *file); bool st_init(void); void st_flush_trace_buffer(void); diff --git a/trace/simple.c b/trace/simple.c index fc7106ec49..906391538f 100644 --- a/trace/simple.c +++ b/trace/simple.c @@ -302,10 +302,10 @@ static int st_write_event_mapping(void) return 0; } =20 -void st_set_trace_file_enabled(bool enable) +bool st_set_trace_file_enabled(bool enable) { if (enable =3D=3D !!trace_fp) { - return; /* no change */ + return enable; /* no change */ } =20 /* Halt trace writeout */ @@ -323,14 +323,14 @@ void st_set_trace_file_enabled(bool enable) =20 trace_fp =3D fopen(trace_file_name, "wb"); if (!trace_fp) { - return; + return !enable; } =20 if (fwrite(&header, sizeof header, 1, trace_fp) !=3D 1 || st_write_event_mapping() < 0) { fclose(trace_fp); trace_fp =3D NULL; - return; + return !enable; } =20 /* Resume trace writeout */ @@ -340,6 +340,7 @@ void st_set_trace_file_enabled(bool enable) fclose(trace_fp); trace_fp =3D NULL; } + return !enable; } =20 /** @@ -350,7 +351,7 @@ void st_set_trace_file_enabled(bool enable) */ void st_set_trace_file(const char *file) { - st_set_trace_file_enabled(false); + bool saved_enable =3D st_set_trace_file_enabled(false); =20 g_free(trace_file_name); =20 @@ -361,7 +362,7 @@ void st_set_trace_file(const char *file) trace_file_name =3D g_strdup_printf("%s", file); } =20 - st_set_trace_file_enabled(true); + st_set_trace_file_enabled(saved_enable); } =20 void st_print_trace_file_status(void) --=20 2.21.1