lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a0985987-384a-d44f-c365-b0b2b935d417@redhat.com>
Date:   Tue, 10 Jan 2023 13:29:16 +0100
From:   David Hildenbrand <david@...hat.com>
To:     Mirsad Todorovac <mirsad.todorovac@....unizg.hr>,
        linux-mm@...ck.org
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Shuah Khan <shuah@...nel.org>, linux-kselftest@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: PROBLEM: selftest/vm/cow.c failed to compile (‘MADV_PAGEOUT’ undeclared)

On 10.01.23 13:25, Mirsad Todorovac wrote:
> On 1/10/23 11:05, David Hildenbrand wrote:
>> On 09.01.23 22:41, Mirsad Goran Todorovac wrote:
>>> On 1/9/2023 5:42 PM, David Hildenbrand wrote:
>>>
>>> Hi, thank you for your reply.
>>>
>>>>> I hope this is enough information for you to debug the issue.
>>>>>
>>>>> I am standing by for any additional diagnostics needed.
>>>>
>>>> Won't userfaultfd.c fail in a similar way?
>>>>
>>>> Anyhow, khugepaged.c jas
>>>>
>>>> #ifndef MADV_PAGEOUT
>>>> #define MADV_PAGEOUT 21
>>>> #endif
>>>>
>>>> So most probably we should do the same.
>>>
>>> Actually, David, it turned out that userfaultfd.c compiled
>>> out-of-the-box, and side-by-side comparison showed that it also included
>>> "/home/marvin/linux/kernel/linux_torvalds/usr/include/asm-generic/mman-common.h"
>>>
>>> The only remaining difference was including <linux/mman.h>, which fixed
>>> the issue w/o #ifdef ... #endif
>>>
>>> Hope this helps.
>>>
>>> Please find the following diff.
>>>
>>> Regards,
>>> Mirsad
>>>
>>> ------------------------------------------------------------------------------
>>> diff --git a/tools/testing/selftests/vm/cow.c
>>> b/tools/testing/selftests/vm/cow.c
>>> index 26f6ea3079e2..dd8cf12c6776 100644
>>> --- a/tools/testing/selftests/vm/cow.c
>>> +++ b/tools/testing/selftests/vm/cow.c
>>> @@ -16,6 +16,7 @@
>>>     #include <fcntl.h>
>>>     #include <dirent.h>
>>>     #include <assert.h>
>>> +#include <linux/mman.h>
>>>     #include <sys/mman.h>
>>>     #include <sys/ioctl.h>
>>>     #include <sys/wait.h>
>>>
>>
>> I already sent a different fix [1]. I suspect when including
>> linux/mman.h, it would still be problematic with older kernel
>> headers that lack MADV_PAGEOUT (< v5.4).
> 
> I see your point.
> 
>> But yeah, I saw that userfaultfd.c was fixed that way:
>>
>> commit b773827e361952b3f53ac6fa4c4e39ccd632102e
>> Author: Chengming Zhou <zhouchengming@...edance.com>
>> Date:   Fri Mar 4 20:29:04 2022 -0800
>>
>>       kselftest/vm: fix tests build with old libc
>>       The error message when I build vm tests on debian10 (GLIBC 2.28):
>>           userfaultfd.c: In function `userfaultfd_pagemap_test':
>>           userfaultfd.c:1393:37: error: `MADV_PAGEOUT' undeclared (first use
>>           in this function); did you mean `MADV_RANDOM'?
>>             if (madvise(area_dst, test_pgsize, MADV_PAGEOUT))
>>                                                ^~~~~~~~~~~~
>>                                                MADV_RANDOM
>>       This patch includes these newer definitions from UAPI linux/mman.h, is
>>       useful to fix tests build on systems without these definitions in
>> glibc
>>       sys/mman.h.
>>
>>
>> [1] https://lkml.kernel.org/r/20230109171255.488749-1-david@redhat.com
> 
> You're the boss :)

Heh, no I'm not :) I'm just raising that this turned out to be 
problematic unfortunately.

> 
> However, IMHO, having MADV_PAGEOUT defined in three or four places could
> make like miserable. OK, it is unlikely to change value, but something
> tells me that the right way to do it is to guarantee that the macro
> definition is unique.
> 
> I don't know what would be the right thing to do in pre-5.4 kernels
> w/o MADV_PAGEOUT defined.
> 
> Probably then the "(madvise(area_dst, test_pgsize, MADV_PAGEOUT)" gives
> EINVAL or is undefined?

Yes. The expectation is that it fails with ENOSYS or EINVAL if the 
kernel doesn't support it. The kernel might be different to the 
installed kernel headers.

In an ideal world, we'd be using the in-tree headers -- they are 
guaranteed to define what we need. So far, I failed to make it work (I 
thought it would work as expected before I had to do above mentioned 
fix). Maybe that can be made working?

-- 
Thanks,

David / dhildenb

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ