All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] msgop.2: Add restriction on ENOSYS error
@ 2020-09-09  3:57 Yang Xu
  2020-09-09  8:57 ` Michael Kerrisk (man-pages)
  2020-09-09 12:19 ` Michael Kerrisk (man-pages)
  0 siblings, 2 replies; 5+ messages in thread
From: Yang Xu @ 2020-09-09  3:57 UTC (permalink / raw)
  To: mtk.manpages; +Cc: linux-man, Yang Xu

When calling msgrcv with MSG_COPY flag on 3.8 or new kernel, it will
report EINVAL error even we have disabled CONFIG_CHECKPOINT_RESTORE.
It also needs to specify IPC_NOWAIT flag.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 man2/msgop.2 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/man2/msgop.2 b/man2/msgop.2
index 373e53aa7..e559097a7 100644
--- a/man2/msgop.2
+++ b/man2/msgop.2
@@ -467,7 +467,9 @@ and the queue contains less than
 messages.
 .TP
 .BR ENOSYS " (since Linux 3.8)"
-.I MSG_COPY
+.B IPC_NOWAIT
+and
+.B MSG_COPY
 was specified in
 .IR msgflg ,
 and this kernel was configured without
-- 
2.23.0




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] msgop.2: Add restriction on ENOSYS error
  2020-09-09  3:57 [PATCH] msgop.2: Add restriction on ENOSYS error Yang Xu
@ 2020-09-09  8:57 ` Michael Kerrisk (man-pages)
  2020-09-09 11:14   ` Yang Xu
  2020-09-09 12:19 ` Michael Kerrisk (man-pages)
  1 sibling, 1 reply; 5+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-09-09  8:57 UTC (permalink / raw)
  To: Yang Xu; +Cc: linux-man

Hello Yang Xu,

On Wed, 9 Sep 2020 at 05:57, Yang Xu <xuyang2018.jy@cn.fujitsu.com> wrote:
>
> When calling msgrcv with MSG_COPY flag on 3.8 or new kernel, it will
> report EINVAL error even we have disabled CONFIG_CHECKPOINT_RESTORE.
> It also needs to specify IPC_NOWAIT flag.
>
> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> ---
>  man2/msgop.2 | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/man2/msgop.2 b/man2/msgop.2
> index 373e53aa7..e559097a7 100644
> --- a/man2/msgop.2
> +++ b/man2/msgop.2
> @@ -467,7 +467,9 @@ and the queue contains less than
>  messages.
>  .TP
>  .BR ENOSYS " (since Linux 3.8)"
> -.I MSG_COPY
> +.B IPC_NOWAIT
> +and
> +.B MSG_COPY
>  was specified in
>  .IR msgflg ,
>  and this kernel was configured without
> --
> 2.23.0

My apologies, I have a little bit of trouble to understand your commit
message, but the patch does seem to be wrong, at least as I understand
the code:

[[
#ifdef CONFIG_CHECKPOINT_RESTORE
...
#else
static inline struct msg_msg *prepare_copy(void __user *buf, size_t bufsz)
{
        return ERR_PTR(-ENOSYS);
}

...
static long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long
msgtyp, int msgflg,
               long (*msg_handler)(void __user *, struct msg_msg *, size_t))
{
...
        if (msgflg & MSG_COPY) {
                if ((msgflg & MSG_EXCEPT) || !(msgflg & IPC_NOWAIT))
                        return -EINVAL;
                copy = prepare_copy(buf, min_t(size_t, bufsz, ns->msg_ctlmax));
...
}
]]

My reading of that code is:
if MSG_COPY && MSG_EXCEPT ==> EINVAL
if MSG_COPY && ! IPC_NOWAIT ==> EINVAL
if neither of the above: if MSG_COPY && ! CONFIG_CHECKPOINT_RESTORE ==> ENOSYS

And all of that seems already to be captured in the manual page:

       EINVAL (since Linux 3.14)
              msgflg specified MSG_COPY, but not IPC_NOWAIT.

       EINVAL (since Linux 3.14)
              msgflg specified both MSG_COPY and MSG_EXCEPT.

       ENOSYS (since Linux 3.8)
              MSG_COPY was specified in msgflg, and this kernel was  con‐
              figured without CONFIG_CHECKPOINT_RESTORE.

Have I missed something?

Thanks,

Michael

-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] msgop.2: Add restriction on ENOSYS error
  2020-09-09  8:57 ` Michael Kerrisk (man-pages)
@ 2020-09-09 11:14   ` Yang Xu
  2020-09-09 12:15     ` Michael Kerrisk (man-pages)
  0 siblings, 1 reply; 5+ messages in thread
From: Yang Xu @ 2020-09-09 11:14 UTC (permalink / raw)
  To: mtk.manpages; +Cc: linux-man

Hi Michael

> Hello Yang Xu,
> 
> On Wed, 9 Sep 2020 at 05:57, Yang Xu <xuyang2018.jy@cn.fujitsu.com> wrote:
>>
>> When calling msgrcv with MSG_COPY flag on 3.8 or new kernel, it will
>> report EINVAL error even we have disabled CONFIG_CHECKPOINT_RESTORE.
>> It also needs to specify IPC_NOWAIT flag.
>>
>> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
>> ---
>>   man2/msgop.2 | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/man2/msgop.2 b/man2/msgop.2
>> index 373e53aa7..e559097a7 100644
>> --- a/man2/msgop.2
>> +++ b/man2/msgop.2
>> @@ -467,7 +467,9 @@ and the queue contains less than
>>   messages.
>>   .TP
>>   .BR ENOSYS " (since Linux 3.8)"
>> -.I MSG_COPY
>> +.B IPC_NOWAIT
>> +and
>> +.B MSG_COPY
>>   was specified in
>>   .IR msgflg ,
>>   and this kernel was configured without
>> --
>> 2.23.0
> 
> My apologies, I have a little bit of trouble to understand your commit
> message, but the patch does seem to be wrong, at least as I understand
> the code:
> 
> [[
> #ifdef CONFIG_CHECKPOINT_RESTORE
> ...
> #else
> static inline struct msg_msg *prepare_copy(void __user *buf, size_t bufsz)
> {
>          return ERR_PTR(-ENOSYS);
> }
> 
> ...
> static long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long
> msgtyp, int msgflg,
>                 long (*msg_handler)(void __user *, struct msg_msg *, size_t))
> {
> ...
>          if (msgflg & MSG_COPY) {
>                  if ((msgflg & MSG_EXCEPT) || !(msgflg & IPC_NOWAIT))
>                          return -EINVAL;
>                  copy = prepare_copy(buf, min_t(size_t, bufsz, ns->msg_ctlmax));

The #ifdef CONFIG_CHECKPOINT_RESTORE only affected prepare_copy function 
and the EINVAL judgment is not included in #ifdef.
So, if current kernel config disables CONFIG_CHECKPOINT_RESTORE, Using 
MSG_COPY without IPC_NOWAIT will still hit EINVAL error firstly and 
doesn't run into  prepare_copy function to hit ENOSYS error.


Best Regards
Yang Xu
> ...
> }
> ]]
> 
> My reading of that code is:
> if MSG_COPY && MSG_EXCEPT ==> EINVAL
> if MSG_COPY && ! IPC_NOWAIT ==> EINVAL
> if neither of the above: if MSG_COPY && ! CONFIG_CHECKPOINT_RESTORE ==> ENOSYS
> 
> And all of that seems already to be captured in the manual page:
> 
>         EINVAL (since Linux 3.14)
>                msgflg specified MSG_COPY, but not IPC_NOWAIT.
> 
>         EINVAL (since Linux 3.14)
>                msgflg specified both MSG_COPY and MSG_EXCEPT.
> 
>         ENOSYS (since Linux 3.8)
>                MSG_COPY was specified in msgflg, and this kernel was  con‐
>                figured without CONFIG_CHECKPOINT_RESTORE.
> 
> Have I missed something?
> 
> Thanks,
> 
> Michael
> 



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] msgop.2: Add restriction on ENOSYS error
  2020-09-09 11:14   ` Yang Xu
@ 2020-09-09 12:15     ` Michael Kerrisk (man-pages)
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-09-09 12:15 UTC (permalink / raw)
  To: Yang Xu; +Cc: mtk.manpages, linux-man

On 9/9/20 1:14 PM, Yang Xu wrote:
> Hi Michael
> 
>> Hello Yang Xu,
>>
>> On Wed, 9 Sep 2020 at 05:57, Yang Xu <xuyang2018.jy@cn.fujitsu.com> wrote:
>>>
>>> When calling msgrcv with MSG_COPY flag on 3.8 or new kernel, it will
>>> report EINVAL error even we have disabled CONFIG_CHECKPOINT_RESTORE.
>>> It also needs to specify IPC_NOWAIT flag.
>>>
>>> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
>>> ---
>>>   man2/msgop.2 | 4 +++-
>>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/man2/msgop.2 b/man2/msgop.2
>>> index 373e53aa7..e559097a7 100644
>>> --- a/man2/msgop.2
>>> +++ b/man2/msgop.2
>>> @@ -467,7 +467,9 @@ and the queue contains less than
>>>   messages.
>>>   .TP
>>>   .BR ENOSYS " (since Linux 3.8)"
>>> -.I MSG_COPY
>>> +.B IPC_NOWAIT
>>> +and
>>> +.B MSG_COPY
>>>   was specified in
>>>   .IR msgflg ,
>>>   and this kernel was configured without
>>> --
>>> 2.23.0
>>
>> My apologies, I have a little bit of trouble to understand your commit
>> message, but the patch does seem to be wrong, at least as I understand
>> the code:
>>
>> [[
>> #ifdef CONFIG_CHECKPOINT_RESTORE
>> ...
>> #else
>> static inline struct msg_msg *prepare_copy(void __user *buf, size_t bufsz)
>> {
>>          return ERR_PTR(-ENOSYS);
>> }
>>
>> ...
>> static long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long
>> msgtyp, int msgflg,
>>                 long (*msg_handler)(void __user *, struct msg_msg *, size_t))
>> {
>> ...
>>          if (msgflg & MSG_COPY) {
>>                  if ((msgflg & MSG_EXCEPT) || !(msgflg & IPC_NOWAIT))
>>                          return -EINVAL;
>>                  copy = prepare_copy(buf, min_t(size_t, bufsz, ns->msg_ctlmax));
> 
> The #ifdef CONFIG_CHECKPOINT_RESTORE only affected prepare_copy function 
> and the EINVAL judgment is not included in #ifdef.
> So, if current kernel config disables CONFIG_CHECKPOINT_RESTORE, Using 
> MSG_COPY without IPC_NOWAIT will still hit EINVAL error firstly and 
> doesn't run into  prepare_copy function to hit ENOSYS error.

Ahh -- now I see what you mean.

Thanks,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] msgop.2: Add restriction on ENOSYS error
  2020-09-09  3:57 [PATCH] msgop.2: Add restriction on ENOSYS error Yang Xu
  2020-09-09  8:57 ` Michael Kerrisk (man-pages)
@ 2020-09-09 12:19 ` Michael Kerrisk (man-pages)
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-09-09 12:19 UTC (permalink / raw)
  To: Yang Xu; +Cc: mtk.manpages, linux-man

Hello Yang Xu,

On 9/9/20 5:57 AM, Yang Xu wrote:
> When calling msgrcv with MSG_COPY flag on 3.8 or new kernel, it will
> report EINVAL error even we have disabled CONFIG_CHECKPOINT_RESTORE.
> It also needs to specify IPC_NOWAIT flag.
> 
> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> ---
>  man2/msgop.2 | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/man2/msgop.2 b/man2/msgop.2
> index 373e53aa7..e559097a7 100644
> --- a/man2/msgop.2
> +++ b/man2/msgop.2
> @@ -467,7 +467,9 @@ and the queue contains less than
>  messages.
>  .TP
>  .BR ENOSYS " (since Linux 3.8)"
> -.I MSG_COPY
> +.B IPC_NOWAIT
> +and
> +.B MSG_COPY
>  was specified in
>  .IR msgflg ,
>  and this kernel was configured without

Thanks for the patch, and your clarifications to my confusion. I applied the
patch, and then did some light editing, so that the change looks as below.

Cheers,

Michael


diff --git a/man2/msgop.2 b/man2/msgop.2
index 373e53aa7..6a8dfcdf8 100644
--- a/man2/msgop.2
+++ b/man2/msgop.2
@@ -467,8 +467,11 @@ and the queue contains less than
 messages.
 .TP
 .BR ENOSYS " (since Linux 3.8)"
-.I MSG_COPY
-was specified in
+Both
+.B MSG_COPY
+and
+.B IPC_NOWAIT
+were specified in
 .IR msgflg ,
 and this kernel was configured without
 .BR CONFIG_CHECKPOINT_RESTORE .


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-09 15:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-09  3:57 [PATCH] msgop.2: Add restriction on ENOSYS error Yang Xu
2020-09-09  8:57 ` Michael Kerrisk (man-pages)
2020-09-09 11:14   ` Yang Xu
2020-09-09 12:15     ` Michael Kerrisk (man-pages)
2020-09-09 12:19 ` Michael Kerrisk (man-pages)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.