From nobody Mon Feb 9 08:44:34 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=quarkslab.com ARC-Seal: i=1; a=rsa-sha256; t=1614968337; cv=none; d=zohomail.com; s=zohoarc; b=Kq+l9Z+s6HK0WEgEN91YkvjS9HaGer7SwQNKo4qHGcRfp+ye/rlTO3uWrBQ3qoeUSuqeint+NFbj1L5r//W1742lsFqME64FOPzBlM9t4QAuJZh1CkA79BWigrjFKyArtNoQ6wlvBAbOZMUlZv10aH5Pl+dAtfKuOcTi/BhV0Cc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614968337; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=XK+JgNR6PdCQQHR5ls3J+fQVuIt75rpDteHPgWQOYKI=; b=PY4y00ZQPqOgBp4Rw8L9CagkadBCnUHKk6RxgXTwKWpUKa6aIySNout/ssIOzo76YJwDud4x3xiX63nXlp6wVRSGll1A36sTrmE8ZII+y0YBaCSg1KF+SdH5dLOu3gc6t6VPWnXvoBPE1nnuR69wKCe3cn4ZFbO+9l6KdyCY7So= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161496833758447.322781828131156; Fri, 5 Mar 2021 10:18:57 -0800 (PST) Received: from localhost ([::1]:55250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIF2N-0003Au-F5 for importer@patchew.org; Fri, 05 Mar 2021 13:18:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIEJ7-0007vn-II for qemu-devel@nongnu.org; Fri, 05 Mar 2021 12:32:09 -0500 Received: from mx5.quarkslab.com ([163.172.30.93]:51940) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIEJ3-0004PK-9k for qemu-devel@nongnu.org; Fri, 05 Mar 2021 12:32:08 -0500 Received: from localhost.localdomain (143.68.31.93.rev.sfr.net [93.31.68.143]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx5.quarkslab.com (Postfix) with ESMTPSA id 4DsZYB1rgCz7sfM; Fri, 5 Mar 2021 18:31:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=quarkslab.com; s=mail; t=1614965518; bh=ej8mXFyq1S3fLjunoOjVkx+WEWcZkAKvpzvj9k1PIz8=; h=From:To:Cc:Subject:Date:Reply-To; b=Yis7fVK+tqthSEyN6dRJaUDzEYf6WrO+7/RLuPqgo7kzJpHZGR1YxjM9PbjYcLMqo WnBnuz/GtRI4GWssWQDvgrAhmzj+hJbEz502utETT6YpHhp8BTTV1RvAWrPEHm9RLg 5IKc8ZOAT7wuuQPJuDYfNWjuLBZsz00dBt/LeIxc= From: Nicolas Surbayrole To: qemu-devel@nongnu.org Subject: [PATCH] linux-user: Fix executable page of /proc/self/maps Date: Fri, 5 Mar 2021 18:31:44 +0100 Message-Id: <20210305173144.874378-1-nsurbayrole@quarkslab.com> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes 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=163.172.30.93; envelope-from=nsurbayrole@quarkslab.com; helo=mx5.quarkslab.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, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: laurent@vivier.eu Cc: Nicolas Surbayrole Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @quarkslab.com) Content-Type: text/plain; charset="utf-8" The guest binary and libraries are not always mapped with the executable bit in the host process. The guest may read a /proc/self/maps with no executable address range. The patch bases the perm fields against the guest permission inside Qemu. Signed-off-by: Nicolas Surbayrole --- linux-user/syscall.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 389ec09764..77c40a274f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7888,9 +7888,9 @@ static int open_self_maps(void *cpu_env, int fd) count =3D dprintf(fd, TARGET_ABI_FMT_ptr "-" TARGET_ABI_FMT_ptr " %c%c%c%c %08" PRIx64 " %s %"PRId64, h2g(min), h2g(max - 1) + 1, - e->is_read ? 'r' : '-', - e->is_write ? 'w' : '-', - e->is_exec ? 'x' : '-', + (flags & PROT_READ) ? 'r' : '-', + (flags & PROT_WRITE) ? 'w' : '-', + (flags & PROT_EXEC) ? 'x' : '-', e->is_priv ? 'p' : '-', (uint64_t) e->offset, e->dev, e->inode); if (path) { --=20 2.30.1 When trying to used Qemu on amd64 host to run aarch64 binary, I've reached=20 an issue with /proc/self/maps. $ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes=20 $ docker run --rm -it arm64v8/ubuntu cat /proc/self/maps 5500000000-5500008000 r--p 00000000 fe:06 141788774 /u= sr/bin/cat 5500008000-5500017000 ---p 00000000 00:00 0 5500017000-5500018000 r--p 00007000 fe:06 141788774 /u= sr/bin/cat 5500018000-5500019000 rw-p 00008000 fe:06 141788774 /u= sr/bin/cat 5500019000-550003a000 rw-p 00000000 00:00 0 5501019000-550101a000 ---p 00000000 00:00 0 550101a000-550181a000 rw-p 00000000 00:00 0 [s= tack] 550181a000-550183b000 r--p 00000000 fe:06 134329967 /u= sr/lib/aarch64-linux-gnu/ld-2.31.so 550183b000-550184b000 ---p 00000000 00:00 0 550184b000-550184c000 r--p 00021000 fe:06 134329967 /u= sr/lib/aarch64-linux-gnu/ld-2.31.so 550184c000-550184e000 rw-p 00022000 fe:06 134329967 /u= sr/lib/aarch64-linux-gnu/ld-2.31.so 5501850000-55019a9000 r--p 00000000 fe:06 134344388 /u= sr/lib/aarch64-linux-gnu/libc-2.31.so 55019a9000-55019b8000 ---p 00159000 fe:06 134344388 /u= sr/lib/aarch64-linux-gnu/libc-2.31.so 55019b8000-55019bb000 r--p 00158000 fe:06 134344388 /u= sr/lib/aarch64-linux-gnu/libc-2.31.so 55019bb000-55019be000 rw-p 0015b000 fe:06 134344388 /u= sr/lib/aarch64-linux-gnu/libc-2.31.so 55019be000-55019c3000 rw-p 00000000 00:00 0 No executable page is available. The same result is observed with the=20 last master commit. I think the perm fields should be based on=20 the guest permission inside Qemu, but I'd be happy to hear the rational aga= inst this.