From nobody Sun May 19 14:32:57 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1682157893; cv=none; d=zohomail.com; s=zohoarc; b=JDaqAJf0ZZ2sD57ilVaqxGh1pBcQp97UVsQg/mXV8p39VnjmQKhLIK95qm+9vT5c63RBSV0XjhDuMdCE6rW8+Vv9rdWP4CvMq+lwjkiBfYVUATrhUFjyMPxiLMLnsjh0gFS6Gu+kyZPpT1AIKbu1jC0VgsWbYjVFr3e/SfRqa2Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682157893; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rYpA24cVu4OFgk4DBcECq3kusuEBa2bpD2LXsBHmJCI=; b=OJD0sXtCVUuxRAua/iijHQj+wAv0PnrsJbJuzeMlDceg0TEgMl0NqqpUVPR6Say/Cf3HOSFeLU/0qHEWaz+PZKUljtM9PeYoBUmBvyoURWYaBOFTEKLHsXoRQ+WOejkhszso6G9Xc+usv4QqdgM9/LuXGkfHTrntLuh1R+7iIBI= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682157893005469.44938862523986; Sat, 22 Apr 2023 03:04:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqA5v-0003o1-05; Sat, 22 Apr 2023 06:03:51 -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 1pqA5n-0003lA-4B for qemu-devel@nongnu.org; Sat, 22 Apr 2023 06:03:44 -0400 Received: from todd.t-8ch.de ([159.69.126.157]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqA5j-0000f4-4X for qemu-devel@nongnu.org; Sat, 22 Apr 2023 06:03:41 -0400 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-8ch.de; s=mail; t=1682157813; bh=fXGTwsgoJEVjDUk4qyvsKAgrgaCs5TLuSvqVeEzmj9M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DzNavXaHU7B6pzyEav35tTgD8cilwryuBBLcjIsz8pxzaMBKi4ljxh3jRZKuo1dX/ f2nu971eIPXc2lCzuh9F5NOjJCxwRri4Io7veP54KQ3iN6bBnzfadxyxRFECsHme4+ Ccg8SKSluU0rfv2u31vMgrTXo5yZqTSMGlZELS5s= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , "Laurent Vivier" Subject: [PATCH v2 1/2] linux-user: Add new flag VERIFY_NONE Date: Sat, 22 Apr 2023 12:03:13 +0200 Message-Id: <20230422100314.1650-2-thomas@t-8ch.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230422100314.1650-1-thomas@t-8ch.de> References: <20230422100314.1650-1-thomas@t-8ch.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=159.69.126.157; envelope-from=thomas@t-8ch.de; helo=todd.t-8ch.de 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, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @t-8ch.de) X-ZM-MESSAGEID: 1682157894235100002 This can be used to validate that an address range is mapped but without being readable or writable. It will be used by an updated implementation of mincore(). Signed-off-by: Thomas Wei=C3=9Fschuh Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/qemu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index e2e93fbd1d5d..92f9f5af41c7 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -168,6 +168,7 @@ abi_long do_brk(abi_ulong new_brk); =20 /* user access */ =20 +#define VERIFY_NONE 0 #define VERIFY_READ PAGE_READ #define VERIFY_WRITE (PAGE_READ | PAGE_WRITE) =20 --=20 2.40.0 From nobody Sun May 19 14:32:57 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1682157853; cv=none; d=zohomail.com; s=zohoarc; b=PP/v4BVuG+UgyaJ/tPGzOPELbkrcy2hOOYpNxfR96qKDTMoUCBIFPl04Q95POjO96V79oSXFR0Oti+VGPO3cJKCE/hNo73oqBAIowj64Q68qN7Q9EiOdNQV0wnlyemKVHakmPivQ17TbiaFMIya+pOjrJNviMOTsLrZW0o7cV1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682157853; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xnDI8udoOtv9g/Tjht8PPaNsIlbBAeFF6+xdkuqJp5M=; b=kxZg155RgrXjxiUkzuKJ1kiyDi6VXILgUOTMsvePaOdvfej3QIfd6dSegNjfi94aqzMGn6bBAASlmW6dwM4Hh+Q9fAf8lD8XI1qcfd50aewRzT+EkGVHY/RJq/mnzx+6g2vnY9lPI0g8ynDxEQoMqpeUO1g1GqbhV0PO88DakAM= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682157853070781.5835186024821; Sat, 22 Apr 2023 03:04:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqA5p-0003lC-2r; Sat, 22 Apr 2023 06:03:46 -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 1pqA5l-0003hg-7q for qemu-devel@nongnu.org; Sat, 22 Apr 2023 06:03:41 -0400 Received: from todd.t-8ch.de ([2a01:4f8:c010:41de::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqA5i-0000fE-2l for qemu-devel@nongnu.org; Sat, 22 Apr 2023 06:03:40 -0400 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-8ch.de; s=mail; t=1682157814; bh=BAwx82WpZZmURcNDMQd8RcPycVG7QdU/ASsiJNOYjuo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KDLdT4G2hEc1gI0do1PRcYBS3Nm+bUno9RHeMOAj1wQDhN4s4xPq+FnrjbNzpL2SJ JnA1WfW1kY2Q0ECMcdSECdN/BS3/HDIQGXHV+ZhchqW1lxzAIOX8z7/b3KWTqYo3Cv NxHOS/RU4Bngs1xXR0m0UFmeGKlTGERjYio1ynU8= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , "Laurent Vivier" Subject: [PATCH v2 2/2] linux-user: Don't require PROT_READ for mincore Date: Sat, 22 Apr 2023 12:03:14 +0200 Message-Id: <20230422100314.1650-3-thomas@t-8ch.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230422100314.1650-1-thomas@t-8ch.de> References: <20230422100314.1650-1-thomas@t-8ch.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=2a01:4f8:c010:41de::1; envelope-from=thomas@t-8ch.de; helo=todd.t-8ch.de 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, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @t-8ch.de) X-ZM-MESSAGEID: 1682157854833100001 The kernel does not require PROT_READ for addresses passed to mincore. For example the fincore(1) tool from util-linux uses PROT_NONE and currently does not work under qemu-user. Example (with fincore(1) from util-linux 2.38): $ fincore /proc/self/exe RES PAGES SIZE FILE 24K 6 22.1K /proc/self/exe $ qemu-x86_64 /usr/bin/fincore /proc/self/exe fincore: failed to do mincore: /proc/self/exe: Cannot allocate memory With this patch: $ ./build/qemu-x86_64 /usr/bin/fincore /proc/self/exe RES PAGES SIZE FILE 24K 6 22.1K /proc/self/exe Signed-off-by: Thomas Wei=C3=9Fschuh Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 69f740ff98c8..5ec848b459f7 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11897,7 +11897,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, #ifdef TARGET_NR_mincore case TARGET_NR_mincore: { - void *a =3D lock_user(VERIFY_READ, arg1, arg2, 0); + void *a =3D lock_user(VERIFY_NONE, arg1, arg2, 0); if (!a) { return -TARGET_ENOMEM; } --=20 2.40.0