From patchwork Thu Apr 18 17:49:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 789807 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp694806wrm; Thu, 18 Apr 2024 10:51:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW1UeRxEl5TK4ku2O3uyTXMcyy0giZsoVNlVGU4c45kTd2b8I6zkwlVb1P32iFjckBaIEieeSJ6+aXGW5Iv8eKL X-Google-Smtp-Source: AGHT+IF1gxJx7gIZ/p01W1a/hmiGFvsX+TbReJ6XGaerzG2PIEz7ARU4oiUHsYWMKd1AuMOGUr/W X-Received: by 2002:ac8:5882:0:b0:437:b8d8:511d with SMTP id t2-20020ac85882000000b00437b8d8511dmr1154837qta.22.1713462667083; Thu, 18 Apr 2024 10:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713462667; cv=none; d=google.com; s=arc-20160816; b=pKCkUcIBuFgUQFFAkR+muf3arsBgRvefOMftVis0uDHyOfua3t0vDdDNnDWHM5Iicn QiVVDDVnlYc1nfvot+3khvVHcQt1/QMQaJhS0xZ6RH0vAR7iwdgnOPe2bjSJTL15D+no 8dB5CVlTkr5wdALw8DGVceMYoxSPLMdkh40kdBVnP9oeTC6vw2Feh7hodQYt1X7CmiSg Sgh6dxBl1cF2ClHg6/8w2WLHl+eVZJHyIq715EsJyAhN2FqELcW+t7Xq5V0H7iBJ4nkF NSs19m73A8jz+mxv7B1PfHw6NugwqeIdb2EAxkyPPoPnwvShoYSMeiUOvy4avr/FToyc aPag== 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; bh=wCp/DyMYE84q7vvjJpkJ9mFs+Zk6bbunncMMMGOVico=; fh=s1gKKDhkFfgLQwKUGKCVkWVHhmnGAhWn+inBTI2XnyU=; b=kay9XCBMKfnmDh5btXDiAzADdFaaf8/9l/qSjUuAiIvDcVfPJm9b8kIto5WmWQ19O3 wN2xz7jb3hGufr9OEe6l0pxuaiqORCv9H5U2GyYUNyZ//WetyFY9mrf4ERSI/KhKycUC ytUzjkuotwnMOybUwPp4q5e51deiSL0eEBwMMA9n4UQTH3D/KnvRRV4j+wjOdetfZza1 knfX6tDGd2syJSSOvc05a49rHfcsegPYE4H/C8E+ogBgTD6obm/QEFyY7OBcUXYuGtVr f+I/UE51TChn0nugoMkHVXJ0Y8wiOKURMob2JqtaaiGkBZ+Ytb2ABqnDClJBEgzu9SCL ZekA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v23-20020a05622a189700b0043665ab30c5si2049384qtc.130.2024.04.18.10.51.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Apr 2024 10:51:07 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxVtg-0008AL-T3; Thu, 18 Apr 2024 13:50:09 -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 1rxVte-00089K-OL; Thu, 18 Apr 2024 13:50:07 -0400 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxVtc-0007NA-Qv; Thu, 18 Apr 2024 13:50:06 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 04BAD5FD62; Thu, 18 Apr 2024 20:49:59 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 4FB95B9338; Thu, 18 Apr 2024 20:49:56 +0300 (MSK) Received: (nullmailer pid 947809 invoked by uid 1000); Thu, 18 Apr 2024 17:49:55 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Alex Fan , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Michael Tokarev Subject: [Stable-8.2.3 089/116] linux-user: Fix waitid return of siginfo_t and rusage Date: Thu, 18 Apr 2024 20:49:19 +0300 Message-Id: <20240418174955.947730-2-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, 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 From: Richard Henderson 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 Tested-by: Alex Fan Reviewed-by: Philippe Mathieu-Daudé (cherry picked from commit f0907ff4cae743f1a4ef3d0a55a047029eed06ff) Signed-off-by: Michael Tokarev diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e384e14248..834a254895 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9154,14 +9154,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;