Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3699920pxv; Mon, 26 Jul 2021 09:42:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7OaX4WIzc3NZ2FFZpsoN+5Spa4e0gCzq4iSE9uL744I37VJ0H+nYxDVFA56UNeMjAzv6J X-Received: by 2002:aa7:d344:: with SMTP id m4mr22627523edr.184.1627317731693; Mon, 26 Jul 2021 09:42:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627317731; cv=none; d=google.com; s=arc-20160816; b=hW6+bXM5+9jtR7hWMVsrJMVEJLmIzri6aRmIxjIDg8AAjvsxDKcGkpiZMWcUTNiUj/ 4mUtKbNI7fpVWR3CUpCplHp0dn9oOjvF6vu+CjCD2VhXMLzugPolycLnLC07/SQnF+EE 2pHt7eJcwKbhgcUzQXxWN15rqC+acon6UQvKyZlD2KsmygZjoslGzc210JT6XAAWNjfX cX4rMz+zrqIJhAaMilRUCbpV3GyA949A2N1I/2YEWhW3mZh1wltxqt2UYltxaJEWQX4b GEcr3XTkrdLKPNjz3r3m2dQri9c1tK3Sh7Knrru9QAt6nUQe3FuN/KjAxiH5aWN/i/ss e8rw== 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=czYRAEg1nEybWHht6daPfm7EwUIGweVRqUpSDH0O4D0=; b=KERQZDWutuANtLJ52R6jyMZlzYncu2Ch5Brj4GP5PpnuPXZy4OTfgbH6l3XpOwQe7/ zgs/bxj6jazYK7Dp1czIO/QwONpdZ/7ath351uNUBqYSIKAxtWBDer4fiGT3xrIjsNB5 avbUUlPzDztZPpiMmZVZ/t7mDXWLtFVwE6+fqgJrlDFQdWO70ddarohx/vFbM0o1bs9Q OIWW6HEtWraj4p53dqJiI4HP39DLpCZGsemu2MBOy76uKgN1IUyFZCRf+ddslWo3uC7x bDm//K53QR6i2Y9HNrBKQr3oWQZY8wpm7dJS3c7H6/O626G6pzuJ8+73XKb9hBpx1Wni pfnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IUqWnrXv; 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 w3si452782edc.112.2021.07.26.09.41.48; Mon, 26 Jul 2021 09:42:11 -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=IUqWnrXv; 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 S239674AbhGZP5I (ORCPT + 99 others); Mon, 26 Jul 2021 11:57:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:53888 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237751AbhGZPgF (ORCPT ); Mon, 26 Jul 2021 11:36:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 18014604AC; Mon, 26 Jul 2021 16:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627316193; bh=oXQPLTtnLwa4Q5l926i50RFNtfg8BEi86KK7K8/ySIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IUqWnrXvlljbr0AWFTBvlY/zQ8/CST6ZSxjRGKUmVVzEh6R0L56cHW6WsXoZ0zV29 s3fSlBX0miNwhvNoqOltcjFmd9vjSjGAwbjy9LhZJmsppBAu6b2dXidxZCgJAr7Ofl +uQ5Sg/M+oxgeG4pY1z+0/W6huTnsMFK772FWB9k= 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.13 191/223] selftest: use mmap instead of posix_memalign to allocate memory Date: Mon, 26 Jul 2021 17:39:43 +0200 Message-Id: <20210726153852.445207631@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153846.245305071@linuxfoundation.org> References: <20210726153846.245305071@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 @@ -197,8 +197,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; } }