From patchwork Fri Mar 5 17:31:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Surbayrole X-Patchwork-Id: 12119135 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB60CC433E0 for ; Fri, 5 Mar 2021 18:18:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 59751650A3 for ; Fri, 5 Mar 2021 18:18:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 59751650A3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=quarkslab.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIF2J-0003Au-Fm for qemu-devel@archiver.kernel.org; Fri, 05 Mar 2021 13:18:51 -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 X-Spam: Yes 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 = 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) {