From patchwork Mon Aug 29 02:10:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 600859 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1685129mae; Sun, 28 Aug 2022 19:18:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR5kGIz6AZ3gvva8T3cJ0GLGHaX2TAUxKfm0wkSMX1fMbtZ9e5vpqxmxO644MTh1OK8AAzgM X-Received: by 2002:a05:620a:2157:b0:6ba:cc6b:8e99 with SMTP id m23-20020a05620a215700b006bacc6b8e99mr6860989qkm.185.1661739539555; Sun, 28 Aug 2022 19:18:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661739539; cv=none; d=google.com; s=arc-20160816; b=iHWpSUKQj0O3pAKMveQUPiuuhSlzD/XDdptPMoxeCGaNXjVyFwixR3oJKbzaAhWTIw tSRyIjz6tPSGbE+wzvFFjdm0UmkiLncxcA5LHXq8a3qy5pPDzuM1WW0DYYmd5nqX9TKG kIqkmIo+l8Rc1NNnLmb2bIyddE33rhYfmG96FOAJjCzJriQQrDFsRLFVfRj9fDUMyKK7 NOmjXYGq7dhNZcXA1RB4halYy/LykZut/URaqBssbVr6eM49QMq2mVDcNiTWgJVKJTVS x6c2eQnhUqo2Ib2JUkv2J0tRXRu5/MZxmsGEkxIdKWdCaxfvYPWa+7YPKntspUzRjlyn SVmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MG15NAkIAITNs1OE3bxclYfrNMvmI1vfTm8EKN0Sndo=; b=XyA3Oa/s0J/SmH3Rt9lGQApiBk4RGIlw/1fRdsO3qTGZlI0IXMHvKUw+QxUAaCnsg9 yd9MX9LYjZqpf8rOTDTwG/CVn+dtU8ihYA0du7/+ut3qc9hapkf8HdEqekhT3x2ZImz5 kfXdC93z/lHaw9+EPHlZkYJmbvhfAtrcXMIVDL+LhwV8BgfbgKe5v4W2AdvF9m8mHJAe KkaIlZy8aUu9GEIXYEMd0O+zlYDJWLNg5mF/pbSHZPUjTDG/SB5EAhB0WoNK2RNt0c6c kd7q32RhKUWrnYOZFD5QkwRXCWbGisRW3RRqPI4S4AGmYJWNusEw++EbFPknAiLDLGOP NAJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RFDTln+p; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e21-20020ac84915000000b003430651483bsi3087670qtq.289.2022.08.28.19.18.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 Aug 2022 19:18:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RFDTln+p; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:33564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSUMd-0005HH-5d for patch@linaro.org; Sun, 28 Aug 2022 22:18:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSUEF-0003as-QK for qemu-devel@nongnu.org; Sun, 28 Aug 2022 22:10:19 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:42982) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oSUEE-0001cH-3D for qemu-devel@nongnu.org; Sun, 28 Aug 2022 22:10:19 -0400 Received: by mail-pl1-x62a.google.com with SMTP id v5so392088plo.9 for ; Sun, 28 Aug 2022 19:10:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=MG15NAkIAITNs1OE3bxclYfrNMvmI1vfTm8EKN0Sndo=; b=RFDTln+pSjDUmG9UXyVj9H6FTR0ihRkPbzZpLHxIqKUSURhGJ140a1LbMaUE2DQ8+J 3pVkbBQHuGi/YU3NnyC8PfpSUnCcAfEbv2H9cFwRlxqGxRtQl1TTEs+HZxrFA7Qg3HdF EMK0ukMsL3fBgXULEh5DyM8HpVSvJtT5KeuZA0RWuj2h06L1kiXVP1G9//8lKHvlZzB1 bNLAm5oQnrTvQfV6Aq0IHR22lYeVXxUJj2du/xCKxjwprx7NLo6x6WX4Ghi2H2PV5xJg SglPiCWC6xme1oVTRUShLH4hZR7XNwh/pY1q+UeTloafvkAADhmQB/kkBgcFAPaZ+tVK E+zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=MG15NAkIAITNs1OE3bxclYfrNMvmI1vfTm8EKN0Sndo=; b=Q331+3CR/9fKr+5emaVHcuZe2wCZDoSdSh30RzwRpiFARWkkmgEwGmc88WPm4WYjBh zaZFjZlnsh3+N/OgEMByMdp3vgSoYYJ1ymlblbiNY+qQxsrMJsE97WVdDhk7sp2ZAQt1 ONHqayBcOQE8hbs7hv+WvI0Vv0PsftaQCjb073GSl9V/BlSvZk3qO03fJ4KdxlPg3ORT rwPqXlnoAYgaJCr7K/qLSMY5GHWMHCAKZCQoWMr0mH3/jbQxO/KvfhHQmnBZrecqFWn9 zRK0KmpslFSKsiT5JNN3piH+DjyCozSS1BDkDKSoJ+CNAHv24VNCuldjMP/1Caz2BXvp aUZw== X-Gm-Message-State: ACgBeo1mV6+b3PlmX7oJmomXgXysUCDeQ/M+cpVl78fl5Dh3gloLme0o Z27f3HD7qw0Ng27YsokJzwpqTZ6DLHmnEg== X-Received: by 2002:a17:903:2d0:b0:172:b63b:3a1e with SMTP id s16-20020a17090302d000b00172b63b3a1emr14610369plk.76.1661739016406; Sun, 28 Aug 2022 19:10:16 -0700 (PDT) Received: from stoup.. ([2602:47:d49d:ec01:2fa6:2ab5:a96e:2a35]) by smtp.gmail.com with ESMTPSA id ik30-20020a170902ab1e00b0016bdc98730bsm6035139plb.151.2022.08.28.19.10.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Aug 2022 19:10:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu Subject: [PATCH 7/8] linux-user: Lock log around strace Date: Sun, 28 Aug 2022 19:10:05 -0700 Message-Id: <20220829021006.67305-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829021006.67305-1-richard.henderson@linaro.org> References: <20220829021006.67305-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Do not allow syscall arguments to be interleaved between threads. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier --- linux-user/strace.c | 65 ++++++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 19 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 8eadbed39e..c47d91bb3d 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -3773,26 +3773,37 @@ print_syscall(CPUArchState *cpu_env, int num, abi_long arg4, abi_long arg5, abi_long arg6) { int i; - const char *format="%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")"; + FILE *f; + const char *format = "%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," + TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," + TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")"; - qemu_log("%d ", getpid()); + f = qemu_log_trylock(); + if (!f) { + return; + } + fprintf(f, "%d ", getpid()); - for(i=0;i