From patchwork Fri Feb 8 17:35:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 1038830 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) 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; dmarc=none (p=none dis=none) header.from=remlab.net Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43x2R06sTVz9s4V for ; Sat, 9 Feb 2019 04:36:12 +1100 (AEDT) Received: from localhost ([127.0.0.1]:60568 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gsA4Q-00070g-Ux for incoming@patchwork.ozlabs.org; Fri, 08 Feb 2019 12:36:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gsA3i-0006z9-EA for qemu-devel@nongnu.org; Fri, 08 Feb 2019 12:35:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gsA3h-00018N-MZ for qemu-devel@nongnu.org; Fri, 08 Feb 2019 12:35:26 -0500 Received: from poy.remlab.net ([2001:41d0:2:5a1a::]:44628 helo=ns207790.ip-94-23-215.eu) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gsA3h-00013E-GL for qemu-devel@nongnu.org; Fri, 08 Feb 2019 12:35:25 -0500 Received: from basile.remlab.net (ip6-localhost [IPv6:::1]) by ns207790.ip-94-23-215.eu (Postfix) with ESMTP id 5C50A5FCAB for ; Fri, 8 Feb 2019 18:35:20 +0100 (CET) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: qemu-devel@nongnu.org Date: Fri, 8 Feb 2019 19:35:20 +0200 Message-Id: <20190208173520.15007-1-remi@remlab.net> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:41d0:2:5a1a:: Subject: [Qemu-devel] [PATCH] linux-user: check valid address in access_ok() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This works around the LTP crash, but there are problably better ways to go about it. Signed-off-by: RĂ©mi Denis-Courmont Cc: --- linux-user/qemu.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index ef400cb78a..1d222a0cce 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -457,7 +457,8 @@ extern unsigned long guest_stack_size; static inline int access_ok(int type, abi_ulong addr, abi_ulong size) { - return page_check_range((target_ulong)addr, size, + return guest_addr_valid(addr) && guest_addr_valid(addr + size) && + page_check_range((target_ulong)addr, size, (type == VERIFY_READ) ? PAGE_READ : (PAGE_READ | PAGE_WRITE)) == 0; }