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: 1448155 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=quarkslab.com header.i=@quarkslab.com header.a=rsa-sha256 header.s=mail header.b=Yis7fVK+; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DsbZj0SYmz9sW5 for ; Sat, 6 Mar 2021 05:18:21 +1100 (AEDT) Received: from localhost ([::1]:51312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIF1m-0001Sy-VD for incoming@patchwork.ozlabs.org; Fri, 05 Mar 2021 13:18:18 -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+incoming=patchwork.ozlabs.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) {