* [PATCH] samples: pidfd: Fix compile error seen if __NR_pidfd_send_signal is undefined
@ 2019-05-30 11:40 Guenter Roeck
2019-05-30 11:43 ` Christian Brauner
0 siblings, 1 reply; 6+ messages in thread
From: Guenter Roeck @ 2019-05-30 11:40 UTC (permalink / raw)
To: Jann Horn; +Cc: Christian Brauner, linux-kernel, Guenter Roeck
To make pidfd-metadata compile on all arches, irrespective of whether
or not syscall numbers are assigned, define the syscall number to -1
if it isn't to cause the kernel to return -ENOSYS.
Fixes: 43c6afee48d4 ("samples: show race-free pidfd metadata access")
Cc: Christian Brauner <christian@brauner.io>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
samples/pidfd/pidfd-metadata.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/samples/pidfd/pidfd-metadata.c b/samples/pidfd/pidfd-metadata.c
index 640f5f757c57..1e125ddde268 100644
--- a/samples/pidfd/pidfd-metadata.c
+++ b/samples/pidfd/pidfd-metadata.c
@@ -21,6 +21,10 @@
#define CLONE_PIDFD 0x00001000
#endif
+#ifndef __NR_pidfd_send_signal
+#define __NR_pidfd_send_signal -1
+#endif
+
static int do_child(void *args)
{
printf("%d\n", getpid());
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] samples: pidfd: Fix compile error seen if __NR_pidfd_send_signal is undefined
2019-05-30 11:40 [PATCH] samples: pidfd: Fix compile error seen if __NR_pidfd_send_signal is undefined Guenter Roeck
@ 2019-05-30 11:43 ` Christian Brauner
2019-05-30 11:50 ` Guenter Roeck
0 siblings, 1 reply; 6+ messages in thread
From: Christian Brauner @ 2019-05-30 11:43 UTC (permalink / raw)
To: Guenter Roeck, Jann Horn; +Cc: linux-kernel
On May 30, 2019 1:40:47 PM GMT+02:00, Guenter Roeck <linux@roeck-us.net> wrote:
>To make pidfd-metadata compile on all arches, irrespective of whether
>or not syscall numbers are assigned, define the syscall number to -1
>if it isn't to cause the kernel to return -ENOSYS.
>
>Fixes: 43c6afee48d4 ("samples: show race-free pidfd metadata access")
>Cc: Christian Brauner <christian@brauner.io>
>Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>---
> samples/pidfd/pidfd-metadata.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
>diff --git a/samples/pidfd/pidfd-metadata.c
>b/samples/pidfd/pidfd-metadata.c
>index 640f5f757c57..1e125ddde268 100644
>--- a/samples/pidfd/pidfd-metadata.c
>+++ b/samples/pidfd/pidfd-metadata.c
>@@ -21,6 +21,10 @@
> #define CLONE_PIDFD 0x00001000
> #endif
>
>+#ifndef __NR_pidfd_send_signal
>+#define __NR_pidfd_send_signal -1
>+#endif
>+
> static int do_child(void *args)
> {
> printf("%d\n", getpid());
Couldn't you just use the actual syscall number?
That should still fail if the kernel is to old
and still work on kernels that support it
but for whatever reason the unistd.h h
header doesn't have it defined.
Thanks!
Christian
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] samples: pidfd: Fix compile error seen if __NR_pidfd_send_signal is undefined
2019-05-30 11:43 ` Christian Brauner
@ 2019-05-30 11:50 ` Guenter Roeck
2019-05-30 11:55 ` Christian Brauner
0 siblings, 1 reply; 6+ messages in thread
From: Guenter Roeck @ 2019-05-30 11:50 UTC (permalink / raw)
To: Christian Brauner, Jann Horn; +Cc: linux-kernel
On 5/30/19 4:43 AM, Christian Brauner wrote:
> On May 30, 2019 1:40:47 PM GMT+02:00, Guenter Roeck <linux@roeck-us.net> wrote:
>> To make pidfd-metadata compile on all arches, irrespective of whether
>> or not syscall numbers are assigned, define the syscall number to -1
>> if it isn't to cause the kernel to return -ENOSYS.
>>
>> Fixes: 43c6afee48d4 ("samples: show race-free pidfd metadata access")
>> Cc: Christian Brauner <christian@brauner.io>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>> samples/pidfd/pidfd-metadata.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/samples/pidfd/pidfd-metadata.c
>> b/samples/pidfd/pidfd-metadata.c
>> index 640f5f757c57..1e125ddde268 100644
>> --- a/samples/pidfd/pidfd-metadata.c
>> +++ b/samples/pidfd/pidfd-metadata.c
>> @@ -21,6 +21,10 @@
>> #define CLONE_PIDFD 0x00001000
>> #endif
>>
>> +#ifndef __NR_pidfd_send_signal
>> +#define __NR_pidfd_send_signal -1
>> +#endif
>> +
>> static int do_child(void *args)
>> {
>> printf("%d\n", getpid());
>
> Couldn't you just use the actual syscall number?
> That should still fail if the kernel is to old
> and still work on kernels that support it
> but for whatever reason the unistd.h h
> header doesn't have it defined.
>
syscall numbers can differ from architecture to architecture, and the
provided solution is used in other test code. Please feel free to submit
a different patch, though - I am only interested in a fix, which doesn't
have to be mine.
Note that this fails in mips builds.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] samples: pidfd: Fix compile error seen if __NR_pidfd_send_signal is undefined
2019-05-30 11:50 ` Guenter Roeck
@ 2019-05-30 11:55 ` Christian Brauner
2019-05-30 12:29 ` Guenter Roeck
0 siblings, 1 reply; 6+ messages in thread
From: Christian Brauner @ 2019-05-30 11:55 UTC (permalink / raw)
To: Guenter Roeck, Jann Horn; +Cc: linux-kernel
On May 30, 2019 1:50:31 PM GMT+02:00, Guenter Roeck <linux@roeck-us.net> wrote:
>On 5/30/19 4:43 AM, Christian Brauner wrote:
>> On May 30, 2019 1:40:47 PM GMT+02:00, Guenter Roeck
><linux@roeck-us.net> wrote:
>>> To make pidfd-metadata compile on all arches, irrespective of
>whether
>>> or not syscall numbers are assigned, define the syscall number to -1
>>> if it isn't to cause the kernel to return -ENOSYS.
>>>
>>> Fixes: 43c6afee48d4 ("samples: show race-free pidfd metadata
>access")
>>> Cc: Christian Brauner <christian@brauner.io>
>>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>>> ---
>>> samples/pidfd/pidfd-metadata.c | 4 ++++
>>> 1 file changed, 4 insertions(+)
>>>
>>> diff --git a/samples/pidfd/pidfd-metadata.c
>>> b/samples/pidfd/pidfd-metadata.c
>>> index 640f5f757c57..1e125ddde268 100644
>>> --- a/samples/pidfd/pidfd-metadata.c
>>> +++ b/samples/pidfd/pidfd-metadata.c
>>> @@ -21,6 +21,10 @@
>>> #define CLONE_PIDFD 0x00001000
>>> #endif
>>>
>>> +#ifndef __NR_pidfd_send_signal
>>> +#define __NR_pidfd_send_signal -1
>>> +#endif
>>> +
>>> static int do_child(void *args)
>>> {
>>> printf("%d\n", getpid());
>>
>> Couldn't you just use the actual syscall number?
>> That should still fail if the kernel is to old
>> and still work on kernels that support it
>> but for whatever reason the unistd.h h
>> header doesn't have it defined.
>>
>
>syscall numbers can differ from architecture to architecture, and the
>provided solution is used in other test code. Please feel free to
>submit
>a different patch, though - I am only interested in a fix, which
>doesn't
>have to be mine.
>
>Note that this fails in mips builds.
>
>Thanks,
>Guenter
The syscall number is the same on all arches for this syscall.
It's been added after the syscall numbering
work by Arnd.
Christian
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] samples: pidfd: Fix compile error seen if __NR_pidfd_send_signal is undefined
2019-05-30 11:55 ` Christian Brauner
@ 2019-05-30 12:29 ` Guenter Roeck
2019-05-30 12:34 ` Christian Brauner
0 siblings, 1 reply; 6+ messages in thread
From: Guenter Roeck @ 2019-05-30 12:29 UTC (permalink / raw)
To: Christian Brauner, Jann Horn; +Cc: linux-kernel
On 5/30/19 4:55 AM, Christian Brauner wrote:
> On May 30, 2019 1:50:31 PM GMT+02:00, Guenter Roeck <linux@roeck-us.net> wrote:
>> On 5/30/19 4:43 AM, Christian Brauner wrote:
>>> On May 30, 2019 1:40:47 PM GMT+02:00, Guenter Roeck
>> <linux@roeck-us.net> wrote:
>>>> To make pidfd-metadata compile on all arches, irrespective of
>> whether
>>>> or not syscall numbers are assigned, define the syscall number to -1
>>>> if it isn't to cause the kernel to return -ENOSYS.
>>>>
>>>> Fixes: 43c6afee48d4 ("samples: show race-free pidfd metadata
>> access")
>>>> Cc: Christian Brauner <christian@brauner.io>
>>>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>>>> ---
>>>> samples/pidfd/pidfd-metadata.c | 4 ++++
>>>> 1 file changed, 4 insertions(+)
>>>>
>>>> diff --git a/samples/pidfd/pidfd-metadata.c
>>>> b/samples/pidfd/pidfd-metadata.c
>>>> index 640f5f757c57..1e125ddde268 100644
>>>> --- a/samples/pidfd/pidfd-metadata.c
>>>> +++ b/samples/pidfd/pidfd-metadata.c
>>>> @@ -21,6 +21,10 @@
>>>> #define CLONE_PIDFD 0x00001000
>>>> #endif
>>>>
>>>> +#ifndef __NR_pidfd_send_signal
>>>> +#define __NR_pidfd_send_signal -1
>>>> +#endif
>>>> +
>>>> static int do_child(void *args)
>>>> {
>>>> printf("%d\n", getpid());
>>>
>>> Couldn't you just use the actual syscall number?
>>> That should still fail if the kernel is to old
>>> and still work on kernels that support it
>>> but for whatever reason the unistd.h h
>>> header doesn't have it defined.
>>>
>>
>> syscall numbers can differ from architecture to architecture, and the
>> provided solution is used in other test code. Please feel free to
>> submit
>> a different patch, though - I am only interested in a fix, which
>> doesn't
>> have to be mine.
>>
>> Note that this fails in mips builds.
>>
>> Thanks,
>> Guenter
>
> The syscall number is the same on all arches for this syscall.
> It's been added after the syscall numbering
> work by Arnd.
>
As I suggested, please feel free to submit a different patch to fix the problem.
What you are saying may be correct, but I would not personally want to rely on it
or create a hard assumption that it will always be the case.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] samples: pidfd: Fix compile error seen if __NR_pidfd_send_signal is undefined
2019-05-30 12:29 ` Guenter Roeck
@ 2019-05-30 12:34 ` Christian Brauner
0 siblings, 0 replies; 6+ messages in thread
From: Christian Brauner @ 2019-05-30 12:34 UTC (permalink / raw)
To: Guenter Roeck, Jann Horn; +Cc: linux-kernel
On May 30, 2019 2:29:43 PM GMT+02:00, Guenter Roeck <linux@roeck-us.net> wrote:
>On 5/30/19 4:55 AM, Christian Brauner wrote:
>> On May 30, 2019 1:50:31 PM GMT+02:00, Guenter Roeck
><linux@roeck-us.net> wrote:
>>> On 5/30/19 4:43 AM, Christian Brauner wrote:
>>>> On May 30, 2019 1:40:47 PM GMT+02:00, Guenter Roeck
>>> <linux@roeck-us.net> wrote:
>>>>> To make pidfd-metadata compile on all arches, irrespective of
>>> whether
>>>>> or not syscall numbers are assigned, define the syscall number to
>-1
>>>>> if it isn't to cause the kernel to return -ENOSYS.
>>>>>
>>>>> Fixes: 43c6afee48d4 ("samples: show race-free pidfd metadata
>>> access")
>>>>> Cc: Christian Brauner <christian@brauner.io>
>>>>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>>>>> ---
>>>>> samples/pidfd/pidfd-metadata.c | 4 ++++
>>>>> 1 file changed, 4 insertions(+)
>>>>>
>>>>> diff --git a/samples/pidfd/pidfd-metadata.c
>>>>> b/samples/pidfd/pidfd-metadata.c
>>>>> index 640f5f757c57..1e125ddde268 100644
>>>>> --- a/samples/pidfd/pidfd-metadata.c
>>>>> +++ b/samples/pidfd/pidfd-metadata.c
>>>>> @@ -21,6 +21,10 @@
>>>>> #define CLONE_PIDFD 0x00001000
>>>>> #endif
>>>>>
>>>>> +#ifndef __NR_pidfd_send_signal
>>>>> +#define __NR_pidfd_send_signal -1
>>>>> +#endif
>>>>> +
>>>>> static int do_child(void *args)
>>>>> {
>>>>> printf("%d\n", getpid());
>>>>
>>>> Couldn't you just use the actual syscall number?
>>>> That should still fail if the kernel is to old
>>>> and still work on kernels that support it
>>>> but for whatever reason the unistd.h h
>>>> header doesn't have it defined.
>>>>
>>>
>>> syscall numbers can differ from architecture to architecture, and
>the
>>> provided solution is used in other test code. Please feel free to
>>> submit
>>> a different patch, though - I am only interested in a fix, which
>>> doesn't
>>> have to be mine.
>>>
>>> Note that this fails in mips builds.
>>>
>>> Thanks,
>>> Guenter
>>
>> The syscall number is the same on all arches for this syscall.
>> It's been added after the syscall numbering
>> work by Arnd.
>>
>
>As I suggested, please feel free to submit a different patch to fix the
>problem.
>What you are saying may be correct, but I would not personally want to
>rely on it
>or create a hard assumption that it will always be the case.
>
>Thanks,
>Guenter
I'll pick this patch up.
Acked-by: Christian Brauner <christian@brauner.io>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-05-30 12:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-30 11:40 [PATCH] samples: pidfd: Fix compile error seen if __NR_pidfd_send_signal is undefined Guenter Roeck
2019-05-30 11:43 ` Christian Brauner
2019-05-30 11:50 ` Guenter Roeck
2019-05-30 11:55 ` Christian Brauner
2019-05-30 12:29 ` Guenter Roeck
2019-05-30 12:34 ` Christian Brauner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®