From mboxrd@z Thu Jan 1 00:00:00 1970 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=-10.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 3F67AC433E0 for ; Tue, 9 Mar 2021 21:13:57 +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 D95AE65250 for ; Tue, 9 Mar 2021 21:13:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D95AE65250 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=xes-inc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJjfv-0002YS-VO for qemu-devel@archiver.kernel.org; Tue, 09 Mar 2021 16:13:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJjX5-0005Gy-5G; Tue, 09 Mar 2021 16:04:47 -0500 Received: from mail.xes-mad.com ([162.248.234.2]:38872) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJjX1-0007pj-2g; Tue, 09 Mar 2021 16:04:46 -0500 Received: from [10.52.16.140] (vfazio1.xes-mad.com [10.52.16.140]) by mail.xes-mad.com (Postfix) with ESMTP id 0BD962C552; Tue, 9 Mar 2021 15:04:28 -0600 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xes-inc.com; s=mail; t=1615323868; bh=5VhUrBba04/jpKWRHi7qHq6WuraJNq4ous2+g7AILrw=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=VF3Wv9Tyu7Gb+AxWMTb83zVHCzhnpYDvZp05LMZKoFYUzlsJC6C4Me3rY++vU/jGw t46ki+dkyVLzOyh2cCdQxxEi7W8Gk5fhYToXfZDiB2X8W5zeXmkL3hrZtsfHdBaf/Q 0XsdvsZj7/lGP5MDlukh6QlM0hRPGWqkFeV3mD0s= Subject: Re: [PATCH] linux-user/elfload: munmap proper address in pgd_find_hole_fallback To: laurent@vivier.eu References: <20210131061849.12615-1-vfazio@xes-inc.com> <87lfbqc2ab.fsf@linaro.org> From: Vincent Fazio Message-ID: <4614f136-8604-a40b-8ea9-7964eba304a3@xes-inc.com> Date: Tue, 9 Mar 2021 15:04:27 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <87lfbqc2ab.fsf@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=162.248.234.2; envelope-from=vfazio@xes-inc.com; helo=mail.xes-mad.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, NICE_REPLY_A=-0.001, 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: , Cc: qemu-trivial@nongnu.org, =?UTF-8?Q?Alex_Benn=c3=a9e?= , qemu-devel@nongnu.org, Vincent Fazio Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Pinging per Laurent. On 2/14/21 5:32 AM, Alex Bennée wrote: > > Vincent Fazio writes: > >> From: Vincent Fazio >> >> Previously, if the build host's libc did not define MAP_FIXED_NOREPLACE >> or if the running kernel didn't support that flag, it was possible for >> pgd_find_hole_fallback to munmap an incorrect address which could lead to >> SIGSEGV if the range happened to overlap with the mapped address of the >> QEMU binary. >> >> mmap(0x1000, 22261224, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x7f889d331000 >> munmap(0x1000, 22261224) = 0 >> --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x84b817} --- >> ++ killed by SIGSEGV +++ >> >> Now, always munmap the address returned by mmap. >> >> Fixes: 2667e069e7b5 ("linux-user: don't use MAP_FIXED in pgd_find_hole_fallback") >> Signed-off-by: Vincent Fazio > > Reviewed-by: Alex Bennée >