From nobody Mon May 20 14:56:39 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=1689683629; cv=none; d=zohomail.com; s=zohoarc; b=VczG/irKMuIgpcMY4XgswbAKpuVFqbIi+w7ePSJsuprgajBcTm1pRJexTx6oHR1TVF+4Xa3mZwvG4IZ9T7IVeyQFpLsqdnaI1n8sllg3q2GQ1PXEFUxordKeqfmSJSrT2I3tJ9/rp2/XvQ+zABSqFPMmOUz2JTRuCqrEuwPlj5c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689683629; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=X3h8htJE1tcjlrg5sp4AKojdGMdbT25L5P1jLszkeAc=; b=E6l8ZKqheds8JIiLQwiAAduXTzDFXmHylBbU8JoZevj1y/z+0PWylM5UvIvzSFUSkOu0atu+z0GkO/TSyYslA4lgwl4tyZAuLwjf+i8sj07p5vK7mOvqfBslyk8xzwgApQRWMlqQj6aX8Y4qWwYxYe7NElk9yRcuHoWk7wLKn94= 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 1689683629041526.685564674982; Tue, 18 Jul 2023 05:33:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qLjtJ-0008LK-Pu; Tue, 18 Jul 2023 08:33:21 -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 1qLjtH-0008L0-GC for qemu-devel@nongnu.org; Tue, 18 Jul 2023 08:33:19 -0400 Received: from bonnix2.bonnix.it ([37.247.49.194]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qLjtF-0001oD-60 for qemu-devel@nongnu.org; Tue, 18 Jul 2023 08:33:19 -0400 Received: from [10.0.0.152] (unknown [82.84.102.14]) by bonnix2.bonnix.it (Postfix) with ESMTPSA id 340C6ADC03 for ; Tue, 18 Jul 2023 14:33:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 bonnix2.bonnix.it 340C6ADC03 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bonslack.org; s=20220805; t=1689683591; bh=X3h8htJE1tcjlrg5sp4AKojdGMdbT25L5P1jLszkeAc=; h=Date:To:From:Subject; b=j6V5D2nY4keO8AusWshFwQNFSQp2bdaTQh9l3Ga72DTjAvHs1DIbctIQ9m/1V0sfb JtumXIWUkXZz1+bsRtVsg3QK8vrqN8XYUXVCkcvMd464LXGfmC4AFT5Tv/bponxDno ACj1ql9KRF9P4Zl1BGOxXAPxFcUoQX3Aa9aB/EGY= Message-ID: <4e1b1c75-8f00-83cc-86c3-0401c8bd0b2a@bonslack.org> Date: Tue, 18 Jul 2023 14:33:10 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Content-Language: it, en-US To: qemu-devel@nongnu.org From: Luca Bonissi Subject: Wrong signed data type on pageflags_* functions - limit to 2GB memory allocation 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=37.247.49.194; envelope-from=qemu@bonslack.org; helo=bonnix2.bonnix.it 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 @bonslack.org) X-ZM-MESSAGEID: 1689683632259100001 Content-Type: text/plain; charset="utf-8"; format="flowed" On 32bit qemu-user targets, memory allocation failed after about 2GB due=20 to incorrect signed (instead of the correct unsigned) "last" parameter=20 in pageflags_find and pageflags_next functions (file accel/tcg/user-exec.c). The parameter, on 32bit targets, will be signed-extent to the 64bit=20 final uint64_t parameters, leading to incorrect comparison on the RBTree=20 (only the first call to mmap on the upper 2GB memory will be successful). Following the patch to fix the bug: Reviewed-by: Richard Henderson --- qemu-20230327.orig/accel/tcg/user-exec.c 2023-03-27=20 15:41:42.000000000 +0200 +++ qemu-20230327/accel/tcg/user-exec.c 2023-07-15 14:09:07.160453759 +0200 @@ -144,7 +144,7 @@ typedef struct PageFlagsNode { static IntervalTreeRoot pageflags_root; -static PageFlagsNode *pageflags_find(target_ulong start, target_long last) +static PageFlagsNode *pageflags_find(target_ulong start, target_ulong last) { IntervalTreeNode *n; @@ -153,7 +153,7 @@ static PageFlagsNode *pageflags_find(tar } static PageFlagsNode *pageflags_next(PageFlagsNode *p, target_ulong start, - target_long last) + target_ulong last) { IntervalTreeNode *n;