From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796510859; b=v9ycLmn4171imKqm31NCHKmu7OBbsxIExoY5NTBPY+t2l8FcYUm96JNhshdJI2PX7ghg Vc+L458jwnD1K6Vc10D7AQQbmJ5s6yykB9jl8Xkx1JHbIWhfOkj5BXJvvKA+RG/nw7rWA QraVxnvsrO5xP7HpaZ2SCr1Q1iTWS+0FWb3Sbfe4OHYng+qSjFMzTpRgg3VOm9O5ikG5J l4CQoeXqayhYLTD4cQTU+N9c6SY85jDB9Nqv/bfBEZAlCA+7LcPGmOkuP/Ep1/oD5Sa80 7QLXGf/exndNgD5HEGcef+nXk/9fzgTDSPrqfJ+g4i/65Vp5np/h8tYZ8a+3+uJyL9Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796510859; h=Received:DKIM-Signature:Date:To:From:Subject:Message-Id; bh=bqq4WDB8B2jwKNQUlsL+QQeoMhdBtngUA1NtwM0kG9U=; b=yMgwS1F8G3d54lJO+CaQeBexYfEsI+WjWpB2uSxv+kQONwqdFSNry1Tj9xJI8OoOAVQV 6oxXNo+m6MvrxtILXG9JokNOE+VQXEIS81ErAuEuziRlJdyHjLYrhqE7pykrO4O1eWK9n AUxmDFbF+/+ak1wc6j2jlyzRJ8SrZ77T0WH8tBAIe9z2h5n5oDU8I4LK/LNMUKydeEWjp MS0Ep6zL3Te9lPqpOB6xkIYeACjoF3Q09UEsu3f5VdrQL7T5TyCqxUP8ekqbfP+L9tWK2 eWd9O7c4P2WXqh870jCQcyRZkz8EM3KQ0NW1Q2Wda3pwnDaVMknKcfpULz2TsCrma0w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=r6tOhBjU; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D85EF606A336 for ; Sat, 5 Dec 2026 22:47:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=r6tOhBjU Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B4311F00936; Sat, 5 Dec 2026 22:47:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796510859; bh=bqq4WDB8B2jwKNQUlsL+QQeoMhdBtngUA1NtwM0kG9U=; h=Date:To:From:Subject; b=r6tOhBjUWZBE/EBbfDKrO27uKtCSprGzFKKUGMNaq+mKlmVndgMNMHvzJaMxqZZgH TSrysS9erMZLBKIQIub/n3t7zi7MO/so7jzaMwJW9lr/2XAsq2vLCQEUGql6cxKGvd 2BoDFwKf8Lb6ndV/ncnbvkXtjJyBe9y6TpzxdVIA= Date: Sat, 05 Dec 2026 14:47:38 -0800 To: mm-commits@vger.kernel.org,azpijr@gmail.com,akpm@linux-foundation.org From: Andrew Morton Subject: + selftests-mm-test-mlock-and-munlock-range-normalisation-fix.patch added to mm-unstable branch Message-Id: <20261205224739.7B4311F00936@smtp.kernel.org> X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The patch titled Subject: selftests-mm-test-mlock-and-munlock-range-normalisation-fix has been added to the -mm mm-unstable branch. Its filename is selftests-mm-test-mlock-and-munlock-range-normalisation-fix.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-mm-test-mlock-and-munlock-range-normalisation-fix.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Andrew Morton Subject: selftests-mm-test-mlock-and-munlock-range-normalisation-fix Date: Wed, 25 Nov 2026 13:05:16 -0800 ULONG_MAX has the test binary's width. A 32-bit binary on a 64-bit kernel passes 0xffffffff, which does not overflow the kernel's arithmetic. Requiring EINVAL can therefore fail on a correct kernel. Require the calls to fail on a 32-bit binary, while retaining the EINVAL check on a 64-bit binary. The mlock tests continue to check that the failed calls did not change VmLck. Signed-off-by: Andrew Morton Cc: Jose A. Perez de Azpillaga tools/testing/selftests/mm/mlock2-tests.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) --- a/tools/testing/selftests/mm/mlock2-tests.c~selftests-mm-test-mlock-and-munlock-range-normalisation-fix +++ a/tools/testing/selftests/mm/mlock2-tests.c @@ -286,6 +286,13 @@ static void test_munlock_zero_length(voi munmap(map, 2 * page_size); } +/* A 32-bit request may not wrap in a 64-bit kernel. */ +static bool overflow_rejected(int ret) +{ + return ret == -1 && + (sizeof(unsigned long) == 4 || errno == EINVAL); +} + static void test_mlock_length_wrap(void) { unsigned long page_size = getpagesize(); @@ -301,7 +308,7 @@ static void test_mlock_length_wrap(void) vmlck_before = get_vmlck(); errno = 0; ret = mlock(map, ULONG_MAX); - ksft_test_result(ret == -1 && errno == EINVAL, + ksft_test_result(overflow_rejected(ret), "%s: mlock() with a wrapping length is rejected\n", __func__); @@ -313,7 +320,7 @@ static void test_mlock_length_wrap(void) vmlck_before = get_vmlck(); errno = 0; ret = mlock(map + 5, ULONG_MAX); - ksft_test_result(ret == -1 && errno == EINVAL, + ksft_test_result(overflow_rejected(ret), "%s: unaligned mlock() with a wrapping length is rejected\n", __func__); @@ -345,7 +352,7 @@ static void test_mlock_addr_overflow(voi vmlck_before = get_vmlck(); errno = 0; ret = mlock(map, len); - ksft_test_result(ret == -1 && errno == EINVAL, + ksft_test_result(overflow_rejected(ret), "%s: mlock() with an overflowing addr + len is rejected\n", __func__); @@ -369,18 +376,18 @@ static void test_munlock_range_overflow( ksft_exit_fail_msg("mmap error: %s\n", strerror(errno)); errno = 0; - ksft_test_result(munlock(map, ULONG_MAX) == -1 && errno == EINVAL, + ksft_test_result(overflow_rejected(munlock(map, ULONG_MAX)), "%s: munlock() with a wrapping length is rejected\n", __func__); errno = 0; - ksft_test_result(munlock(map + 5, ULONG_MAX) == -1 && errno == EINVAL, + ksft_test_result(overflow_rejected(munlock(map + 5, ULONG_MAX)), "%s: unaligned munlock() with a wrapping length is rejected\n", __func__); len = (size_t)(0UL - (unsigned long)map); errno = 0; - ksft_test_result(munlock(map, len) == -1 && errno == EINVAL, + ksft_test_result(overflow_rejected(munlock(map, len)), "%s: munlock() with an overflowing addr + len is rejected\n", __func__); _ Patches currently in -mm which might be from akpm@linux-foundation.org are kselftest-mm-rename-read_pmd_pagesize-to-pmd_psize-fix.patch selftests-mm-check-madv_cold-and-madv_pageout-on-partly-advised-thps-fix.patch selftests-mm-retain-move-pmd-coverage-and-verify-huge-pmds.patch lib-test_xarray-check-unused-spare-node-after-range-creation.patch selftests-mm-check-that-fsync-reports-hard-poisoned-dirty-page-cache.patch selftests-mm-memory-failure-truncate-poisoned-fuse-page-cache-before-teardown.patch selftests-mm-memory-failure-skip-poisoned-dirty-page-cache-on-nilfs2.patch selftest-mm-memory-failure-keep-page-cache-files-linked-until-cleanup.patch selftest-mm-memory-failure-keep-page-cache-files-linked-until-cleanup-fix.patch selftests-mm-memory-failure-skip-hard-dirty-page-cache-test-on-cephfs.patch selftests-mm-memory-failure-close-dirty-page-cache-files-before-unlinking-them.patch selftests-mm-memory-failure-extend-page-cache-test-files-with-pwrite.patch selftests-mm-memory-failure-write-the-whole-page-cache-test-file-for-omfs.patch selftests-mm-memory-failure-accept-eio-from-close-after-poisoning-dirty-data.patch selftests-mm-test-mlock-and-munlock-range-normalisation-fix.patch selftests-mm-free-the-test-context-when-uffd_test_ctx_init-fails-fix.patch alloc_tag-introduce-ioctls-to-toggle-allocation-tracepoints-fix-fix.patch alloc_tag-introduce-ioctls-to-toggle-allocation-tracepoints-fix.patch mm-vmscan-scope-freeze-writeback-skip-to-the-reclaim-target.patch mm-vmscan-scope-freeze-writeback-skip-to-the-reclaim-target-fix.patch mm-hmm-refuse-secretmem-vmas-in-hmm_range_fault-fix.patch hugetlbfs-dont-overflow-the-end-of-the-unmap-range-on-32-bit-fix.patch ipc-msg-clamp-negative-msg_info-usage-counts.patch squashfs-fix-leaked-page-locks-when-page-actor-allocation-fails-fix.patch ocfs2-skip-network-flush-when-no-domain-handlers-are-registered.patch selftests-ptrace-check-that-ptrace_set_syscall_info-rejects-invalid-error-values-fix.patch lib-atomic64-separate-hashed-locks-by-smp-cache-line.patch nvdimm-btt-separate-map-locks-by-smp-cache-line.patch percpu_ref-replace-the-global-switch-lock-with-hashed-locks-fix.patch afs-do-not-put-error-pointer-after-address-lookup-failure.patch drivers-media-v4l2-core-v4l2-vp9c-reduce-inlining.patch