Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3663367pxv; Mon, 26 Jul 2021 08:58:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/I2+Q1PpD0pgQSuCcla/E8K+0FTPfqXtXtv76qk21G9cYrJx0UC1mKmdwc0TY/+K0noRc X-Received: by 2002:a17:906:40e:: with SMTP id d14mr8571909eja.338.1627315126846; Mon, 26 Jul 2021 08:58:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627315126; cv=none; d=google.com; s=arc-20160816; b=i5qsjAgeM/+THsTdnUhFqWpjh/JSf2/ovJ9dnZEPnr5ScJzFIwwWh9tnIlkrmEY/kV AlVbln9Aa6++eE4gz1FC0W84630JF5ngRpmk5ihQP3Lyg6IH4plB+8i4QqrC+CROgDyy bmOVhVtn6lr4V5EDi/NjQhmlVcJPDXFmPiDViFz8iiuENsNSWefr0OIlROaf6OogWSu7 /2I/3NjLXUWtk+Luim0nGHIQ93+UgYnplniXfiCAmxmOteLCQ1RgPh/W7dpiVdQ9etQ0 0aQfO/xJsNKtfhsWvQXPy+LZhVhFovid3qFbZ7+qKzOjxFoi3Dx/PpreOLzU8NbvmBl4 OVzg== 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=acEY8Y09pj4z3dfgNUwvuM3ZzBrCtOsdppChF9jDLRU=; b=tflww1LkxJ1OoGsSta3K8vzoUe9AI5RMvxANqlxGCmzmgV/QB1KnjsNOrC/+dOlSx+ U+ezzfJgGzXeFp3DUrSZvqkSwoNryqfgSCJUAiZL2tFQMvWKE5mmAVotZTnOOmeCu4ox 9EGtJRYxvZ1MAUbwrEhBgvlD5LNj3fZuPVD51l0IPjUJwQWXGr9nVYmkTx6y3zTtGEL1 WSUE8zWbVN3g0/sK6XHCHmvgHrp41+fczA0ho3E6hfeLBM+jIYAZjY0W9/oLPFXLeNS1 l2hBLToCpLQpFEQGyExgw9Yq6MBb65unoIc6epp7j/Am7Gr7MF9RfDd9n6zmamhX7Luy Rjhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=okWDTSnr; 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 g20si257595ejm.455.2021.07.26.08.58.22; Mon, 26 Jul 2021 08:58:46 -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=okWDTSnr; 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 S237716AbhGZPQV (ORCPT + 99 others); Mon, 26 Jul 2021 11:16:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:49388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236357AbhGZPIQ (ORCPT ); Mon, 26 Jul 2021 11:08:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C1AA160F59; Mon, 26 Jul 2021 15:48:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627314511; bh=Xx4TdN3LRW98yyInq1cNQHG2ShyTMjifHR9k2mHWRtA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=okWDTSnrZk1KcVDHQaqhvujGptweTobrfrIZnd4mISZTegJaKnLZ8JpJo/VxET3Jw /imcLojMuDBHlPQWySjhCjmOAQ6K2/+a3yjLoQnN0y5SU6VScH309dZTwSNWUegGTj kuVos91Ccj5BJJpv7tcf+Xielrv9goWR4u42now4= 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 4.14 75/82] selftest: use mmap instead of posix_memalign to allocate memory Date: Mon, 26 Jul 2021 17:39:15 +0200 Message-Id: <20210726153830.613854294@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153828.144714469@linuxfoundation.org> References: <20210726153828.144714469@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 @@ -129,8 +129,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; } }