From nobody Sun Mar 22 15:36:06 2026 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1774054186; cv=none; d=zohomail.com; s=zohoarc; b=Gl3l4A6CY+lIwFCLRlsFmVSkkfaj1DF1cleGugff9kknmVUSjqhCWq68ISSjOzLpo54rkJwBcRd44/BLLAbBjZY1S7kp6JK55+3v+d+4zfrrkbG1HvAyT3wuGU++gaAdYYgt+pCDarCvPSfndmo0IGWnD2XRLqps5aUfzDOtuVI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774054186; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3Vn78SmAAKLbz3+kHLOEDEuAaN8ZeC+NU4A6mFcmLx8=; b=GS3laxY/9xL42RCi5tPcOIh2vXlSiDu9M8qYUT+HXOPObR534L8rjRHPBFDGLQRaX1ZwKtYrE7Xqxd79JvTB80wrBT621caXem4cxKmGkUhU8ccuh/o7dQwyEyAdZtYtNnN/nc1fZiSGx6dxR6qsbN/l2arGau06+dmfdtEgBkA= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1774054186833741.0977870059169; Fri, 20 Mar 2026 17:49:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w3kWe-0005R3-AE; Fri, 20 Mar 2026 20:49:12 -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 1w3kWd-0005Qr-1E for qemu-devel@nongnu.org; Fri, 20 Mar 2026 20:49:11 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1w3kWb-00025V-HF for qemu-devel@nongnu.org; Fri, 20 Mar 2026 20:49:10 -0400 Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-35b97ed057cso684991a91.1 for ; Fri, 20 Mar 2026 17:49:09 -0700 (PDT) Received: from lima-default (103.95.112.190.qld.leaptel.network. [103.95.112.190]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b083527f84sm34637685ad.18.2026.03.20.17.49.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2026 17:49:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1774054147; x=1774658947; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3Vn78SmAAKLbz3+kHLOEDEuAaN8ZeC+NU4A6mFcmLx8=; b=MFrxdr7PfbLJ9SKsElFlsyx408sS2LhE5YFhZ1IcfockPDKibiRKCQHymh0cni9WJ3 qdgPsHqTvDvxQsCjp6KVwgD4i7639EwjZFpiyNbK66jEtCSBbuRL3Go2SNx6Au+92e2P 5IWwKTMIZYNUwztU38jorDdAv58fJrkd6cDkauZ1tTvkBXK164p69VP3rph+QbGfzKmd tSgov0hhRJLw8swufbMogeeY+O6ifsT1sCxn2lMFN4W5MxvAlmmdO/gQXxpnsAFf8X2p d+vgfRQt8/3flr5J5DH8mf45gkaNtuXP8bpGHyJpkk3VFHqLYG33eaaYsobmlIo6AXzY SVxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774054147; x=1774658947; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=3Vn78SmAAKLbz3+kHLOEDEuAaN8ZeC+NU4A6mFcmLx8=; b=gwwoDwexd1zrmu2w7THm5DRn6hJn6j9IlDjZdYLyzPp3Pux9HtDWp3ncHurWgUtT+x 1OmeGNOYSAPn6H+BVRqVjb1biL7+Vi9Sjozx8TJku6CMpDmny4t8ZiwuFkqgYvkGwtqO VfCbNLV2TC6qbcUZHYKY3FreEemuvPv/0BJBV4OEbjQK8Mse/KDhJqI2K74gzUNXkfdz nsi1Vjo1Chr167hRxiLgctpZzSjPlMC7utVHzWOsU4Y3yu2BlXKzmchmWVOdR/3W2Ak+ xm3uYz8H9tY82DrP7NYZ3GCSQHSJVdM9YIY5L+vQD4sLb76NT7v4dae73PVVLs8EyMsE OZ+g== X-Gm-Message-State: AOJu0YzmjxAdOOcXqkphQDFvut1VSeDff3tWddGqDeZfT9oUQ7X+Hoyu he5DxMrLgNFG/6bxukSEo04puOwrq5/oelGrsnillPBNdXueBEzFD0woTur5fQ== X-Gm-Gg: ATEYQzworgzYgV+tsT8XH1/NLIv6cweY4AXKtFA47nRXhlQ1KseD1AGFfyvBYDXENHb IZFr1bhz2ReeqXTBf03z9i5hPJyIeLockmHAAL5jLamuRS1ppZ6zRtxjjrp5Dn1FIahz7OCUImU ZxXt3BF/GszXM5y/i9vXecwJyaLh3EXtPESLRCAHy8FwlHvzfHxZ5tGE8XYiNUOP3YGyA9kw3Lo iqIyRhOoQK0rLX07HOp8jLI8hYoaFY/v5SeYO3ykHu1KhWymISR7w5OUSBFKMV1n9lKNOBNYGmw HTiIfH5N2Q34VIjdmJVS7x0R+0WnIi4BUwCCTyuvcUMlZTRrKatafi/LX88WW2dkjmmw3cLu+XL T2kJ4xvq5yAMTrasPMJXJWxpMZHw/0AeriZdmXPAy+pJG2lGUK6rHQ43CdY2k7HwZZmQXg0Vchh f1lmlhXyg0sdxMzLHQxirKiXR57vNiAFkxMsf7e4da+as66KJqO9anPfeFOnpNkgDFi1bg X-Received: by 2002:a17:903:2984:b0:2b0:5ae9:ee4 with SMTP id d9443c01a7336-2b0826d8307mr43580205ad.5.1774054147270; Fri, 20 Mar 2026 17:49:07 -0700 (PDT) From: Nicholas Piggin To: qemu-devel@nongnu.org Cc: Nicholas Piggin , Warner Losh , Kyle Evans , Laurent Vivier , Pierrick Bouvier , Palmer Dabbelt , Alistair Francis , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , qemu-riscv@nongnu.org Subject: [PATCH 2/3] linux-user: Fix unlock_user API usage Date: Sat, 21 Mar 2026 10:48:35 +1000 Message-ID: <20260321004836.500390-3-npiggin@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260321004836.500390-1-npiggin@gmail.com> References: <20260321004836.500390-1-npiggin@gmail.com> MIME-Version: 1.0 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=2607:f8b0:4864:20::102b; envelope-from=npiggin@gmail.com; helo=mail-pj1-x102b.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1774054189687158500 Content-Type: text/plain; charset="utf-8" Fix errors in unlock_user() calls: - unlock_user() with len=3D1 instead of len=3Dwritten - unlock_user() with len=3D1 instead of len=3D0 - unlock_user() with len=3D0 instead of len=3D1 Signed-off-by: Nicholas Piggin Reviewed-by: Chao Liu --- linux-user/linuxload.c | 2 +- linux-user/syscall.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/linux-user/linuxload.c b/linux-user/linuxload.c index 85d700953e..79416a94c9 100644 --- a/linux-user/linuxload.c +++ b/linux-user/linuxload.c @@ -19,7 +19,7 @@ abi_long memcpy_to_target(abi_ulong dest, const void *src= , unsigned long len) return -TARGET_EFAULT; } memcpy(host_ptr, src, len); - unlock_user(host_ptr, dest, 1); + unlock_user(host_ptr, dest, len); return 0; } =20 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7832a1aba5..13b8bd9ed3 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2989,7 +2989,7 @@ get_timeout: if (put_user_u32(lv, optlen)) { return -TARGET_EFAULT; } - unlock_user(results, optval_addr, 0); + unlock_user(results, optval_addr, len); break; } #endif /* LINUX_VERSION_CODE >=3D KERNEL_VERSION(4, 2, 0) */ @@ -4006,7 +4006,7 @@ static inline abi_long host_to_target_semarray(int se= mid, abi_ulong target_addr, __put_user((*host_array)[i], &array[i]); } g_free(*host_array); - unlock_user(array, target_addr, 1); + unlock_user(array, target_addr, nsems * sizeof(unsigned short)); =20 return 0; } @@ -7888,7 +7888,7 @@ static inline abi_long target_to_host_sigevent(struct= sigevent *host_sevp, host_sevp->sigev_notify =3D tswap32(target_sevp->sigev_notify); host_sevp->sigev_notify_thread_id =3D tswap32(target_sevp->_sigev_un._= tid); =20 - unlock_user_struct(target_sevp, target_addr, 1); + unlock_user_struct(target_sevp, target_addr, 0); return 0; } =20 --=20 2.51.0