Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3681176pxv; Mon, 26 Jul 2021 09:16:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYuxudMditYNRWyAxqfMbIgbST4soCrM3WniYShr0aBsIODiDKemKJRTOwpPxXU35fJrB6 X-Received: by 2002:aa7:c1cc:: with SMTP id d12mr22641467edp.282.1627316181454; Mon, 26 Jul 2021 09:16:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627316181; cv=none; d=google.com; s=arc-20160816; b=E0wkOpssj50ZkqYE1d4OILrKLwfVFekS+0f2P7D0yrLrlPyy72hEstl1M2Kyf3LAiY nK4vxXfnZb2/5sC4cAAvb/dD9qap8xBj/PNaIWivVoMugWMgNHCCHPB12DJhWdlhXJZf XXcytDs90xS/TXObLgmiWoc7Bbw5MSk0w2Ltp+UgZ+RVoMvmT7bpcgJPm4l2tBGnmhxc sup0uDK9HmGBveDOAYKoJlNTWxCrbF+cAY28ci4gL5rwAdnabCyecQGwJXv6HU7TDAqK x4u0zV186cAiO582vSSnm37yo0j5YeGm+ev35oVkls9aeUjJDTBXXbqu/EjP05KRbaQo tLZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=c+Q5JuvURzx5ZNcXPzH0930FoISGArvF46D2MjM7xIo=; b=uV5YBZxaweAeZKh+tiEPqacTHLxF+/LeOTjstEya5yI6vVDNblL8CsS6ICoFoow3HZ 9vLnRRxocW/ZicQcUaLG5+XM3psrv4wGA4B1t7HV8b11gJsN7oH7C0kpn7Wn2uNKW38q yKuBi+eKrV6JDdc74R08aIDfNuOUmgLJSUGaz+bF11mpuJGDJYfpLrrxmrDyHw7aBSim VU/ysi2TtC0TumWHQlqZ2XuODQ2cNVpZXG+16Sa+t9pgzFXmzZQnyd7njY/pldgTlcPB C4bR6wHf2oaiMdDDD7kgZipsGJ4ihwuGzBy95eIvU124aUjhYtl5WAQ1It4dSqWcsJz4 dwMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="aX+P/iGQ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw18si283381edb.491.2021.07.26.09.15.58; Mon, 26 Jul 2021 09:16:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="aX+P/iGQ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234286AbhGZPdW (ORCPT + 99 others); Mon, 26 Jul 2021 11:33:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:59570 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236323AbhGZPSq (ORCPT ); Mon, 26 Jul 2021 11:18:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0CE9460F8F; Mon, 26 Jul 2021 15:59:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315153; bh=VnKLxJo20R+SaPZ2BgBSqyVGFQnYbkIdqtBRS2/obLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aX+P/iGQUMNX9B6xW+tnH1nEiYHdkdZ5HxTqeHuwxJASDu+YiUsSSCOrPSNCKy6IX DrExRseRETa+GLAk5uyOSz7Jw1pympy7k5B15O3tsqiv/8GhDjiQpBRr9eQJFnm05e iE+TYu2r/aqWcj2rpszEv/am9WtdgmNgPDOXFhzo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lokesh Gidra , Peter Collingbourne , Catalin Marinas , Vincenzo Frascino , Dave Martin , Will Deacon , Andrea Arcangeli , Alistair Delva , William McVicker , Evgenii Stepanov , Mitch Phillips , Andrey Konovalov , Andrew Morton , Linus Torvalds Subject: [PATCH 5.4 094/108] selftest: use mmap instead of posix_memalign to allocate memory Date: Mon, 26 Jul 2021 17:39:35 +0200 Message-Id: <20210726153834.696464801@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153831.696295003@linuxfoundation.org> References: <20210726153831.696295003@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Collingbourne commit 0db282ba2c12c1515d490d14a1ff696643ab0f1b upstream. This test passes pointers obtained from anon_allocate_area to the userfaultfd and mremap APIs. This causes a problem if the system allocator returns tagged pointers because with the tagged address ABI the kernel rejects tagged addresses passed to these APIs, which would end up causing the test to fail. To make this test compatible with such system allocators, stop using the system allocator to allocate memory in anon_allocate_area, and instead just use mmap. Link: https://lkml.kernel.org/r/20210714195437.118982-3-pcc@google.com Link: https://linux-review.googlesource.com/id/Icac91064fcd923f77a83e8e133f8631c5b8fc241 Fixes: c47174fc362a ("userfaultfd: selftest") Co-developed-by: Lokesh Gidra Signed-off-by: Lokesh Gidra Signed-off-by: Peter Collingbourne Reviewed-by: Catalin Marinas Cc: Vincenzo Frascino Cc: Dave Martin Cc: Will Deacon Cc: Andrea Arcangeli Cc: Alistair Delva Cc: William McVicker Cc: Evgenii Stepanov Cc: Mitch Phillips Cc: Andrey Konovalov Cc: [5.4] Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/vm/userfaultfd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c @@ -139,8 +139,10 @@ static int anon_release_pages(char *rel_ static void anon_allocate_area(void **alloc_area) { - if (posix_memalign(alloc_area, page_size, nr_pages * page_size)) { - fprintf(stderr, "out of memory\n"); + *alloc_area = mmap(NULL, nr_pages * page_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + if (*alloc_area == MAP_FAILED) + fprintf(stderr, "mmap of anonymous memory failed"); *alloc_area = NULL; } }