From patchwork Fri Apr 5 22:00:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 786250 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1101:b0:343:f27d:c44e with SMTP id z1csp386119wrw; Fri, 5 Apr 2024 15:01:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUKj5ppzGjT+VmHIk9l71VwHVQQg6TH5WZJd/LTBQpOSsjzDc1gT8ghXKViWjXwjwPKO9gw/GPFg6w8OOTFX+AY X-Google-Smtp-Source: AGHT+IHENA97mAxN5Bhq/JH9OvdBCNo6OniTleCv++u7h5YBQKbYkCW0kqM/hdilrUDoXBVSB3S7 X-Received: by 2002:a05:622a:120c:b0:432:f556:bdf6 with SMTP id y12-20020a05622a120c00b00432f556bdf6mr3424625qtx.45.1712354502028; Fri, 05 Apr 2024 15:01:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712354502; cv=none; d=google.com; s=arc-20160816; b=kuhDZtPNWJuynafOSddGb7Fq14h/x3vCe5SE1Zk3rWvLy7xK52tvWZ2VFQzQsUYc8B duu/N0stbqDPAeG8QCi5zl7WKFu4PCdyoODtv/vTktKhv3Jt1dsDUobRi7rSr5nVE96P kYy3I8CMbJBiqdczPI4gh4TN4NKzfnzYogu0tpn6n5ao/6SGq9DSCNwfNq9nqBQ+Q42Q 1BaSm1thQtuBKvA+M3KvqLKo4mbpurAPUnPIIEvRV/z1oBV4ld9S0gQSTOgIlhR6IS7R HLsk7D0IV4ls/nz/19UE8AQ9HGzQ2/RixVjdcpz6M7Ch+SAOerOgqV3/Vh0NwMjko/VM yi4Q== 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:message-id:date:subject:to:from:dkim-signature; bh=xtbJ/p7JEFHTppWK8T4w7KJEZi+x0bHxbuO/ApHynWI=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=Rp75GGZu4YWndGPrKn4Whu40BWA6RiiSlg+qvzJfgAqsrBOqjqWofkhtHQrn4Beffd AMBSYubPp5E0NhKFLah1aJGp3dRpLZNSB3rVVZKxJYkjK3RBNqC4iaNMRo46dJw1zhGr 2Uxcl7GYhMgEz2FJ+bcNAcjIkgQomVc98qv6uJShFFM07PruwQX4xkwzIZAmRBesiTz2 h3OH9K3M6FuZ5lrVQX7UbALBQRk3FrwlT/LcDcU+/WJObp1J6QGoJggr/S07KYj/gp+w ziVn/7V0fvLVl27nM+2bL5U6X8H68Dfy5ZhhkGZ5sO4fQD36CvTkx9YM6ilKa1nqL53p ktaw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RAKOM067; 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 g4-20020ac87f44000000b004313b62765fsi2623638qtk.117.2024.04.05.15.01.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Apr 2024 15:01:41 -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=RAKOM067; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rsrcC-0005tP-7S; Fri, 05 Apr 2024 18:00:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rsrc3-0005rL-9j for qemu-devel@nongnu.org; Fri, 05 Apr 2024 18:00:43 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsrc1-0002TN-Fq for qemu-devel@nongnu.org; Fri, 05 Apr 2024 18:00:43 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6ecf1bb7f38so1880814b3a.0 for ; Fri, 05 Apr 2024 15:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712354439; x=1712959239; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=xtbJ/p7JEFHTppWK8T4w7KJEZi+x0bHxbuO/ApHynWI=; b=RAKOM067L3kxKcc7Ohzh/tCl3s6ci/XN2B48a8w2MS0Kh1sLrPOUf4whBWFBerzCpI e5qX/dq8u4FBz0v1wObZp6epnQ076yvUSNkte1jiWoBlccPu5RUL/MTX7OLKF6r8pPPt F2xhMofBuJ+d5F/eJR/t8u6Vom3O48AQ4PoTxMIC5hQnCXmgBmjxNOP7NAZF+kbFeL1D rwTrpHH43kfkv4Di528Eth8yIDY410jD2TXjoA5MxGDQSOywUpwB86DjzhdhV0/NCzwE BPxak+Etmb4EUbVZp5mtuqPG8jt4fw7isAIxiR3rFvfcJRgyIi0C7Nnmr/7bziz3gN9j DZGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712354439; x=1712959239; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xtbJ/p7JEFHTppWK8T4w7KJEZi+x0bHxbuO/ApHynWI=; b=iyEtcbOKtXEHSFITay/kZ0fBb0lcFYBEPl8n/nhPQbZeIgGU6l0AAQRuQmftlWtNM3 RBzhd/at9celCVhjMg4HkYKKF40OktUBNE0DUd9qAcIysyev/GRMbvpus8i5NyQKODqx V8Fsx+PeOW4s9ZzjKfQWKuM+uQfND0/n/j4P1xIxY+68rBv1tqN3GD7OtIXRMwxPiXY4 6fVS+3Y6YYcFwpB2ccR3l6lrIY8NwtNEg5DGakPT/KV8LV2LEkq6WHYimPBHsINlhxBp sbCzdrsy5NXbwCQPNHxI4LZ31l0EJjxVJ+FLZngedCgLPwqCfNlVfyhRjw90KwPVjaIX HbFA== X-Gm-Message-State: AOJu0YyfoLzEgmjI12O+WEXDRyTb6P6ce9ZWQ5vyerlJuiXyO6gvtOKj Q80/y1OmaEqp0swtTQuKiEfUZ1cBhgP5lO8W8gztXkdCNByeyDRxyMPiIGVeFv3a7Xi+KHHsICA m X-Received: by 2002:a05:6a21:4987:b0:1a3:c604:8486 with SMTP id ax7-20020a056a21498700b001a3c6048486mr2435130pzc.34.1712354438811; Fri, 05 Apr 2024 15:00:38 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id z11-20020aa785cb000000b006ece85910edsm1988831pfn.152.2024.04.05.15.00.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 15:00:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-9.0] linux-user: Fix waitid return of siginfo_t and rusage Date: Fri, 5 Apr 2024 12:00:34 -1000 Message-Id: <20240405220034.5128-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.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 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-bounces+patch=linaro.org@nongnu.org The copy back to siginfo_t should be conditional only on arg3, not the specific values that might have been written. The copy back to rusage was missing entirely. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2262 Signed-off-by: Richard Henderson Signed-off-by: Alex Fan Tested-by: Alex Fan Reviewed-by: Philippe Mathieu-Daudé --- linux-user/syscall.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e12d969c2e..3df2b94d9a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9272,14 +9272,24 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_waitid case TARGET_NR_waitid: { + struct rusage ru; siginfo_t info; - info.si_pid = 0; - ret = get_errno(safe_waitid(arg1, arg2, &info, arg4, NULL)); - if (!is_error(ret) && arg3 && info.si_pid != 0) { - if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0))) + + ret = get_errno(safe_waitid(arg1, arg2, (arg3 ? &info : NULL), + arg4, (arg5 ? &ru : NULL))); + if (!is_error(ret)) { + if (arg3) { + p = lock_user(VERIFY_WRITE, arg3, + sizeof(target_siginfo_t), 0); + if (!p) { + return -TARGET_EFAULT; + } + host_to_target_siginfo(p, &info); + unlock_user(p, arg3, sizeof(target_siginfo_t)); + } + if (arg5 && host_to_target_rusage(arg5, &ru)) { return -TARGET_EFAULT; - host_to_target_siginfo(p, &info); - unlock_user(p, arg3, sizeof(target_siginfo_t)); + } } } return ret;