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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC786C433F5 for ; Thu, 21 Apr 2022 19:31:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F0C46B007D; Thu, 21 Apr 2022 15:31:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 39E156B007E; Thu, 21 Apr 2022 15:31:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23FE56B0080; Thu, 21 Apr 2022 15:31:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id 12DA76B007D for ; Thu, 21 Apr 2022 15:31:59 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id DAEC01217B7 for ; Thu, 21 Apr 2022 19:31:58 +0000 (UTC) X-FDA: 79381881516.17.169841F Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) by imf23.hostedemail.com (Postfix) with ESMTP id 06AB4140026 for ; Thu, 21 Apr 2022 19:31:55 +0000 (UTC) Received: by mail-io1-f45.google.com with SMTP id i196so6427135ioa.1 for ; Thu, 21 Apr 2022 12:31:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=ChcaOOdn/M8suYxqXQ+PGCxHuw+mTiMXMZ+jM9GrefI=; b=UjIQ1FFdFQrrSszpwO6Bhhjj/JRqJyhC5nfRIA8HWCyoWI/OEn12Xgn7aDVeMn5K3a bNMVs2tMT/tHb2COd9Fjf3B1Y8ZSNjRq+YGqn97BzNYHWuuKmQRNwszD1dxk39JL0J7b eiAvhDnwmTe0cpc9OhOFhuQoJiGlF3mSDL85w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ChcaOOdn/M8suYxqXQ+PGCxHuw+mTiMXMZ+jM9GrefI=; b=NTV15q1YCEXIl735y0tZ2JTB/uaPpHmbKvmUZqsHTNJf2LxVaXTsSg0OQVKaYfPDvI XzqdRKpBE42ftHu2TDx3ZKmi9jRq4SEmTfPohT3Ik/VKEsk2HB1+lFFjQk+2vwuS2N6H a78KQRjtNRr4V5N/FF+xEvQdDE5zdlesoJAf2U8RUZ1hGYnzg447/6oHLGo154s2stVp AmLZp/drO2mArwh+VVKCZazfEJ7ehypbilysEylh/pI//LzrDF2377tkoQf6Ei8pEv3q IAh9zVhYpLrSdTs0D9ejaRu7tYe2/SNgIDijqwKB0s82eeo+k3Tyw5W4HRJKA9fKxo8E fLOA== X-Gm-Message-State: AOAM531qEn447Iy0l1R1ltfFNTmd9o8t2Ii/E/KJSGU5m0NFjhqT4dJp SnyKha0nFMmuJ4R/w/rMmJrMeA== X-Google-Smtp-Source: ABdhPJxBpKoQk/2G24NzJGB83sHvZtecYc3iCN32hGuCxXQOqjgfgf51gXtjUs4//o4vh/1ogzFY4Q== X-Received: by 2002:a05:6638:2586:b0:32a:9e25:d5d6 with SMTP id s6-20020a056638258600b0032a9e25d5d6mr639819jat.191.1650569517485; Thu, 21 Apr 2022 12:31:57 -0700 (PDT) Received: from [192.168.1.128] ([71.205.29.0]) by smtp.gmail.com with ESMTPSA id x9-20020a6b6a09000000b006549545c9d5sm8429268iog.42.2022.04.21.12.31.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Apr 2022 12:31:57 -0700 (PDT) Subject: Re: [PATCH v2 2/4] selftest/vm: verify remap destination address in mremap_test To: Sidhartha Kumar , shuah@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Shuah Khan References: <20220420215721.4868-1-sidhartha.kumar@oracle.com> <20220420215721.4868-2-sidhartha.kumar@oracle.com> From: Shuah Khan Message-ID: <76cd8347-a8d0-3b56-a202-17ba2a73503d@linuxfoundation.org> Date: Thu, 21 Apr 2022 13:31:56 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20220420215721.4868-2-sidhartha.kumar@oracle.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 06AB4140026 X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=google header.b=UjIQ1FFd; spf=pass (imf23.hostedemail.com: domain of skhan@linuxfoundation.org designates 209.85.166.45 as permitted sender) smtp.mailfrom=skhan@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org X-Stat-Signature: sjk6yb9y6mb6kcj3h68uqh4xesnqinqo X-HE-Tag: 1650569515-176636 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 4/20/22 3:57 PM, Sidhartha Kumar wrote: > Because mremap does not have a MAP_FIXED_NOREPLACE flag, it can destroy > existing mappings. This causes a segfault when regions such as text are > remapped and the permissions are changed. > > Verify the requested mremap destination address does not overlap any > existing mappings by using mmap's MAP_FIXED_NOREPLACE flag. Keep > incrementing the destination address until a valid mapping is found or > fail the current test once the max address is reached. > > Signed-off-by: Sidhartha Kumar > --- > v2: > -rename remap_region_valid() to is_remap_region_valid(). > -change return value of is_remap_region_valid() to bool. > -take out overflow check from is_remap_region_valid() to > inside caller. > -fail just the current test on overflow rather than existing > the program > -fix alignment of mmap calls > -change "can't" to "couldn't" in error message > -increment mremap destination address by dest_alignment > rather than src_alignment > Thank you. Reviewed-by: Shuah Khan Andrew, please let me know if you would like me to take this through kselftest tree.