* [PATCH] selftests/mm: Fixed incorrect buffer->mirror size in hmm2 double_map test
@ 2024-09-27 5:07 Donet Tom
2024-09-27 7:18 ` Muhammad Usama Anjum
0 siblings, 1 reply; 4+ messages in thread
From: Donet Tom @ 2024-09-27 5:07 UTC (permalink / raw)
To: Andrew Morton, Shuah Khan, Jérôme Glisse
Cc: linux-mm, linux-kselftest, linux-kernel, Ritesh Harjani,
Kees Cook, Mark Brown, Przemek Kitszel, usama.anjum
The hmm2 double_map test was failing due to an incorrect
buffer->mirror size. The buffer->mirror size was 6, while buffer->ptr
size was 6 * PAGE_SIZE. The test failed because the kernel's
copy_to_user function was attempting to copy a 6 * PAGE_SIZE buffer
to buffer->mirror. Since the size of buffer->mirror was incorrect,
copy_to_user failed.
This patch corrects the buffer->mirror size to 6 * PAGE_SIZE.
Test Result without this patch
==============================
# RUN hmm2.hmm2_device_private.double_map ...
# hmm-tests.c:1680:double_map:Expected ret (-14) == 0 (0)
# double_map: Test terminated by assertion
# FAIL hmm2.hmm2_device_private.double_map
not ok 53 hmm2.hmm2_device_private.double_map
Test Result with this patch
===========================
# RUN hmm2.hmm2_device_private.double_map ...
# OK hmm2.hmm2_device_private.double_map
ok 53 hmm2.hmm2_device_private.double_map
Signed-off-by: Donet Tom <donettom@linux.ibm.com>
---
tools/testing/selftests/mm/hmm-tests.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/mm/hmm-tests.c b/tools/testing/selftests/mm/hmm-tests.c
index d2cfc9b494a0..141bf63cbe05 100644
--- a/tools/testing/selftests/mm/hmm-tests.c
+++ b/tools/testing/selftests/mm/hmm-tests.c
@@ -1657,7 +1657,7 @@ TEST_F(hmm2, double_map)
buffer->fd = -1;
buffer->size = size;
- buffer->mirror = malloc(npages);
+ buffer->mirror = malloc(size);
ASSERT_NE(buffer->mirror, NULL);
/* Reserve a range of addresses. */
--
2.43.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] selftests/mm: Fixed incorrect buffer->mirror size in hmm2 double_map test
2024-09-27 5:07 [PATCH] selftests/mm: Fixed incorrect buffer->mirror size in hmm2 double_map test Donet Tom
@ 2024-09-27 7:18 ` Muhammad Usama Anjum
2024-09-27 10:51 ` Donet Tom
0 siblings, 1 reply; 4+ messages in thread
From: Muhammad Usama Anjum @ 2024-09-27 7:18 UTC (permalink / raw)
To: Donet Tom, Andrew Morton, Shuah Khan, Jérôme Glisse
Cc: Usama.Anjum, linux-mm, linux-kselftest, linux-kernel,
Ritesh Harjani, Kees Cook, Mark Brown, Przemek Kitszel
On 9/27/24 10:07 AM, Donet Tom wrote:
> The hmm2 double_map test was failing due to an incorrect
> buffer->mirror size. The buffer->mirror size was 6, while buffer->ptr
> size was 6 * PAGE_SIZE. The test failed because the kernel's
> copy_to_user function was attempting to copy a 6 * PAGE_SIZE buffer
> to buffer->mirror. Since the size of buffer->mirror was incorrect,
> copy_to_user failed.
>
> This patch corrects the buffer->mirror size to 6 * PAGE_SIZE.
>
> Test Result without this patch
> ==============================
> # RUN hmm2.hmm2_device_private.double_map ...
> # hmm-tests.c:1680:double_map:Expected ret (-14) == 0 (0)
> # double_map: Test terminated by assertion
> # FAIL hmm2.hmm2_device_private.double_map
> not ok 53 hmm2.hmm2_device_private.double_map
>
> Test Result with this patch
> ===========================
> # RUN hmm2.hmm2_device_private.double_map ...
> # OK hmm2.hmm2_device_private.double_map
> ok 53 hmm2.hmm2_device_private.double_map
>
> Signed-off-by: Donet Tom <donettom@linux.ibm.com>
Please add Fixes-by tag. Other than this, LGTM
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
> tools/testing/selftests/mm/hmm-tests.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/mm/hmm-tests.c b/tools/testing/selftests/mm/hmm-tests.c
> index d2cfc9b494a0..141bf63cbe05 100644
> --- a/tools/testing/selftests/mm/hmm-tests.c
> +++ b/tools/testing/selftests/mm/hmm-tests.c
> @@ -1657,7 +1657,7 @@ TEST_F(hmm2, double_map)
>
> buffer->fd = -1;
> buffer->size = size;
> - buffer->mirror = malloc(npages);
> + buffer->mirror = malloc(size);
> ASSERT_NE(buffer->mirror, NULL);
>
> /* Reserve a range of addresses. */
--
BR,
Muhammad Usama Anjum
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] selftests/mm: Fixed incorrect buffer->mirror size in hmm2 double_map test
2024-09-27 7:18 ` Muhammad Usama Anjum
@ 2024-09-27 10:51 ` Donet Tom
2024-09-27 18:07 ` Andrew Morton
0 siblings, 1 reply; 4+ messages in thread
From: Donet Tom @ 2024-09-27 10:51 UTC (permalink / raw)
To: Muhammad Usama Anjum, Andrew Morton, Shuah Khan, Jérôme Glisse
Cc: linux-mm, linux-kselftest, linux-kernel, Ritesh Harjani,
Kees Cook, Mark Brown, Przemek Kitszel
On 9/27/24 12:48, Muhammad Usama Anjum wrote:
> On 9/27/24 10:07 AM, Donet Tom wrote:
>> The hmm2 double_map test was failing due to an incorrect
>> buffer->mirror size. The buffer->mirror size was 6, while buffer->ptr
>> size was 6 * PAGE_SIZE. The test failed because the kernel's
>> copy_to_user function was attempting to copy a 6 * PAGE_SIZE buffer
>> to buffer->mirror. Since the size of buffer->mirror was incorrect,
>> copy_to_user failed.
>>
>> This patch corrects the buffer->mirror size to 6 * PAGE_SIZE.
>>
>> Test Result without this patch
>> ==============================
>> # RUN hmm2.hmm2_device_private.double_map ...
>> # hmm-tests.c:1680:double_map:Expected ret (-14) == 0 (0)
>> # double_map: Test terminated by assertion
>> # FAIL hmm2.hmm2_device_private.double_map
>> not ok 53 hmm2.hmm2_device_private.double_map
>>
>> Test Result with this patch
>> ===========================
>> # RUN hmm2.hmm2_device_private.double_map ...
>> # OK hmm2.hmm2_device_private.double_map
>> ok 53 hmm2.hmm2_device_private.double_map
>>
>> Signed-off-by: Donet Tom <donettom@linux.ibm.com>
> Please add Fixes-by tag. Other than this, LGTM
Fixes-by : Donet Tom <donettom@linux.ibm.com>
I have added the Fixes-by tag here. Please let me know if you would prefer that I send a V2 with this tag.
>
> Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Thank you
Donet
>
>> ---
>> tools/testing/selftests/mm/hmm-tests.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/testing/selftests/mm/hmm-tests.c b/tools/testing/selftests/mm/hmm-tests.c
>> index d2cfc9b494a0..141bf63cbe05 100644
>> --- a/tools/testing/selftests/mm/hmm-tests.c
>> +++ b/tools/testing/selftests/mm/hmm-tests.c
>> @@ -1657,7 +1657,7 @@ TEST_F(hmm2, double_map)
>>
>> buffer->fd = -1;
>> buffer->size = size;
>> - buffer->mirror = malloc(npages);
>> + buffer->mirror = malloc(size);
>> ASSERT_NE(buffer->mirror, NULL);
>>
>> /* Reserve a range of addresses. */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] selftests/mm: Fixed incorrect buffer->mirror size in hmm2 double_map test
2024-09-27 10:51 ` Donet Tom
@ 2024-09-27 18:07 ` Andrew Morton
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2024-09-27 18:07 UTC (permalink / raw)
To: Donet Tom
Cc: Muhammad Usama Anjum, Shuah Khan, Jérôme Glisse,
linux-mm, linux-kselftest, linux-kernel, Ritesh Harjani,
Kees Cook, Mark Brown, Przemek Kitszel, Ralph Campbell,
Jason Gunthorpe
On Fri, 27 Sep 2024 16:21:30 +0530 Donet Tom <donettom@linux.ibm.com> wrote:
> >> Test Result with this patch
> >> ===========================
> >> # RUN hmm2.hmm2_device_private.double_map ...
> >> # OK hmm2.hmm2_device_private.double_map
> >> ok 53 hmm2.hmm2_device_private.double_map
> >>
> >> Signed-off-by: Donet Tom <donettom@linux.ibm.com>
> > Please add Fixes-by tag. Other than this, LGTM
>
> Fixes-by : Donet Tom <donettom@linux.ibm.com>
>
> I have added the Fixes-by tag here. Please let me know if you would prefer that I send a V2 with this tag.
>
"Fixes:". I added
Fixes: fee9f6d1b8df ("mm/hmm/test: add selftests for HMM")
Cc: <stable@vger.kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-12-05 15:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-27 5:07 [PATCH] selftests/mm: Fixed incorrect buffer->mirror size in hmm2 double_map test Donet Tom
2024-09-27 7:18 ` Muhammad Usama Anjum
2024-09-27 10:51 ` Donet Tom
2024-09-27 18:07 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox