public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH][BZ 16852] Do not clobber recvmmsg argument.
@ 2014-04-28 15:29 Ondřej Bílka
  2014-04-28 15:41 ` Andreas Schwab
  0 siblings, 1 reply; 17+ messages in thread
From: Ondřej Bílka @ 2014-04-28 15:29 UTC (permalink / raw)
  To: libc-alpha

Hi, here Rich asked about intended behaviour of recvmmsg timeout
argument. A kernel overwrites it by remaining time but we declare it
with const argument. So who is correct?

If we want to make timeout constant following patch should work.

Comments?

	* sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Do not clobber
	timeout argument.

diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c
index 57ddf31..56690ff 100644
--- a/sysdeps/unix/sysv/linux/recvmmsg.c
+++ b/sysdeps/unix/sysv/linux/recvmmsg.c
@@ -37,6 +37,10 @@ int
 recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
 	  const struct timespec *tmo)
 {
+  struct timespec dummy;
+  memcpy (&dummy, tmo, sizeof (struct timespec));
+  tmo = &dummy;
+
   if (SINGLE_THREAD_P)
     return INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, tmo);
 
@@ -61,6 +65,10 @@ int
 recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
 	  const struct timespec *tmo)
 {
+  struct timespec dummy;
+  memcpy (&dummy, tmo, sizeof (struct timespec));
+  tmo = &dummy;
+
   if (__glibc_likely (have_recvmmsg >= 0))
     {
       int ret = __internal_recvmmsg (fd, vmessages, vlen, flags, tmo);

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

* Re: [PATCH][BZ 16852] Do not clobber recvmmsg argument.
  2014-04-28 15:29 [PATCH][BZ 16852] Do not clobber recvmmsg argument Ondřej Bílka
@ 2014-04-28 15:41 ` Andreas Schwab
  2014-04-28 16:04   ` [PATCH v2][BZ " Ondřej Bílka
  0 siblings, 1 reply; 17+ messages in thread
From: Andreas Schwab @ 2014-04-28 15:41 UTC (permalink / raw)
  To: Ondřej Bílka; +Cc: libc-alpha

Ondřej Bílka <neleai@seznam.cz> writes:

> +  struct timespec dummy;
> +  memcpy (&dummy, tmo, sizeof (struct timespec));

What's wrong with an assignment?

>    if (SINGLE_THREAD_P)
>      return INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, tmo);

You still pass a const where a non-const is expected.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* [PATCH v2][BZ 16852] Do not clobber recvmmsg argument.
  2014-04-28 15:41 ` Andreas Schwab
@ 2014-04-28 16:04   ` Ondřej Bílka
  2014-04-28 17:01     ` David Miller
  2014-04-28 18:07     ` Rich Felker
  0 siblings, 2 replies; 17+ messages in thread
From: Ondřej Bílka @ 2014-04-28 16:04 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha

On Mon, Apr 28, 2014 at 05:40:56PM +0200, Andreas Schwab wrote:
> Ondřej Bílka <neleai@seznam.cz> writes:
> 
> > +  struct timespec dummy;
> > +  memcpy (&dummy, tmo, sizeof (struct timespec));
> 
> What's wrong with an assignment?
>
My first idea was memcpy, thanks. 
> >    if (SINGLE_THREAD_P)
> >      return INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, tmo);
> 
> You still pass a const where a non-const is expected.
>
fixed. 
> Andreas.
> 

Here is v2.

	* sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Do not clobber
	timeout argument.


diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c
index 57ddf31..04a065f 100644
--- a/sysdeps/unix/sysv/linux/recvmmsg.c
+++ b/sysdeps/unix/sysv/linux/recvmmsg.c
@@ -35,14 +35,16 @@
 #ifdef __NR_recvmmsg
 int
 recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
-	  const struct timespec *tmo)
+	  const struct timespec *_tmo)
 {
+  struct timespec tmo = *_tmo;
+
   if (SINGLE_THREAD_P)
-    return INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, tmo);
+    return INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, &tmo);
 
   int oldtype = LIBC_CANCEL_ASYNC ();
 
-  int result = INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, tmo);
+  int result = INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, &tmo);
 
   LIBC_CANCEL_RESET (oldtype);
 
@@ -52,18 +54,20 @@ recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
 # ifndef __ASSUME_RECVMMSG_SOCKETCALL
 extern int __internal_recvmmsg (int fd, struct mmsghdr *vmessages,
 				unsigned int vlen, int flags,
-				const struct timespec *tmo)
+				struct timespec *tmo)
      attribute_hidden;
 
 static int have_recvmmsg;
 
 int
 recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
-	  const struct timespec *tmo)
+	  const struct timespec *_tmo)
 {
+  struct timespec tmo = *_tmo;
+
   if (__glibc_likely (have_recvmmsg >= 0))
     {
-      int ret = __internal_recvmmsg (fd, vmessages, vlen, flags, tmo);
+      int ret = __internal_recvmmsg (fd, vmessages, vlen, flags, &tmo);
       /* The kernel returns -EINVAL for unknown socket operations.
 	 We need to convert that error to an ENOSYS error.  */
       if (__builtin_expect (ret < 0, 0)

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

* Re: [PATCH v2][BZ 16852] Do not clobber recvmmsg argument.
  2014-04-28 16:04   ` [PATCH v2][BZ " Ondřej Bílka
@ 2014-04-28 17:01     ` David Miller
  2014-04-30  8:29       ` Michael Kerrisk (man-pages)
  2014-05-04 15:35       ` Ondřej Bílka
  2014-04-28 18:07     ` Rich Felker
  1 sibling, 2 replies; 17+ messages in thread
From: David Miller @ 2014-04-28 17:01 UTC (permalink / raw)
  To: neleai; +Cc: schwab, libc-alpha

From: Ondřej Bílka <neleai@seznam.cz>
Date: Mon, 28 Apr 2014 18:04:20 +0200

> 	* sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Do not clobber
> 	timeout argument.

It is extremely unfortunate if we've defined this argument as const,
now you are making it so that the user has no mechanism to get the
updated timeval other than to define their own syscall stubs.

This is doubly unfortunately since there is absolutely no reason for
us to have defined the interface different from what the kernel
actually provides.

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

* Re: [PATCH v2][BZ 16852] Do not clobber recvmmsg argument.
  2014-04-28 16:04   ` [PATCH v2][BZ " Ondřej Bílka
  2014-04-28 17:01     ` David Miller
@ 2014-04-28 18:07     ` Rich Felker
  1 sibling, 0 replies; 17+ messages in thread
From: Rich Felker @ 2014-04-28 18:07 UTC (permalink / raw)
  To: Ondřej Bílka; +Cc: Andreas Schwab, libc-alpha

On Mon, Apr 28, 2014 at 06:04:20PM +0200, Ondřej Bílka wrote:
> diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c
> index 57ddf31..04a065f 100644
> --- a/sysdeps/unix/sysv/linux/recvmmsg.c
> +++ b/sysdeps/unix/sysv/linux/recvmmsg.c
> @@ -35,14 +35,16 @@
>  #ifdef __NR_recvmmsg
>  int
>  recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
> -	  const struct timespec *tmo)
> +	  const struct timespec *_tmo)
>  {
> +  struct timespec tmo = *_tmo;
> +

This is invalid because a null tmo argument is allowed (and is in fact
the normal usage case). You have to check for it.

Rich

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

* Re: [PATCH v2][BZ 16852] Do not clobber recvmmsg argument.
  2014-04-28 17:01     ` David Miller
@ 2014-04-30  8:29       ` Michael Kerrisk (man-pages)
  2014-04-30  9:07         ` Ondřej Bílka
  2014-05-04 15:35       ` Ondřej Bílka
  1 sibling, 1 reply; 17+ messages in thread
From: Michael Kerrisk (man-pages) @ 2014-04-30  8:29 UTC (permalink / raw)
  To: David Miller, neleai
  Cc: mtk.manpages, schwab, libc-alpha, Michael Kerrisk (gmail)

On 04/28/2014 07:01 PM, David Miller wrote:
> From: Ondøej Bílka <neleai@seznam.cz>
> Date: Mon, 28 Apr 2014 18:04:20 +0200
> 
>> 	* sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Do not clobber
>> 	timeout argument.
> 
> It is extremely unfortunate if we've defined this argument as const,
> now you are making it so that the user has no mechanism to get the
> updated timeval other than to define their own syscall stubs.
> 
> This is doubly unfortunately since there is absolutely no reason for
> us to have defined the interface different from what the kernel
> actually provides.

Agreed. Surely, the right fix here is simply to remove the "const" 
qualifier from the glibc API?

Cheers,

Michael

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

* Re: [PATCH v2][BZ 16852] Do not clobber recvmmsg argument.
  2014-04-30  8:29       ` Michael Kerrisk (man-pages)
@ 2014-04-30  9:07         ` Ondřej Bílka
  2014-04-30 11:17           ` Michael Kerrisk (man-pages)
  0 siblings, 1 reply; 17+ messages in thread
From: Ondřej Bílka @ 2014-04-30  9:07 UTC (permalink / raw)
  To: mtk.manpages; +Cc: David Miller, schwab, libc-alpha

On Wed, Apr 30, 2014 at 10:28:53AM +0200, Michael Kerrisk (man-pages) wrote:
> On 04/28/2014 07:01 PM, David Miller wrote:
> > From: Ondřej Bílka <neleai@seznam.cz>
> > Date: Mon, 28 Apr 2014 18:04:20 +0200
> > 
> >> 	* sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Do not clobber
> >> 	timeout argument.
> > 
> > It is extremely unfortunate if we've defined this argument as const,
> > now you are making it so that the user has no mechanism to get the
> > updated timeval other than to define their own syscall stubs.
> > 
> > This is doubly unfortunately since there is absolutely no reason for
> > us to have defined the interface different from what the kernel
> > actually provides.
> 
> Agreed. Surely, the right fix here is simply to remove the "const" 
> qualifier from the glibc API?
> 
Now I am also for removing const. Initially I looked to documentation
and this was undocumented feature so I was not sure about it. Could we
also document this in manpages?

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

* Re: [PATCH v2][BZ 16852] Do not clobber recvmmsg argument.
  2014-04-30  9:07         ` Ondřej Bílka
@ 2014-04-30 11:17           ` Michael Kerrisk (man-pages)
  2014-04-30 13:36             ` Michael Kerrisk (man-pages)
  0 siblings, 1 reply; 17+ messages in thread
From: Michael Kerrisk (man-pages) @ 2014-04-30 11:17 UTC (permalink / raw)
  To: Ondřej Bílka; +Cc: mtk.manpages, David Miller, schwab, libc-alpha

Hello Ondřej,

On 04/30/2014 11:07 AM, Ondřej Bílka wrote:
> On Wed, Apr 30, 2014 at 10:28:53AM +0200, Michael Kerrisk (man-pages) wrote:
>> On 04/28/2014 07:01 PM, David Miller wrote:
>>> From: Ondřej Bílka <neleai@seznam.cz>
>>> Date: Mon, 28 Apr 2014 18:04:20 +0200
>>>
>>>> 	* sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Do not clobber
>>>> 	timeout argument.
>>>
>>> It is extremely unfortunate if we've defined this argument as const,
>>> now you are making it so that the user has no mechanism to get the
>>> updated timeval other than to define their own syscall stubs.
>>>
>>> This is doubly unfortunately since there is absolutely no reason for
>>> us to have defined the interface different from what the kernel
>>> actually provides.
>>
>> Agreed. Surely, the right fix here is simply to remove the "const" 
>> qualifier from the glibc API?
>>
> Now I am also for removing const. Initially I looked to documentation
> and this was undocumented feature so I was not sure about it. 

Yes, my mistake. 

> Could we
> also document this in manpages?

Yes, sure, I'll do that. Do you think we also need to document the
glibc 'const' issue under a BUGS section?

Cheers,

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] 17+ messages in thread

* Re: [PATCH v2][BZ 16852] Do not clobber recvmmsg argument.
  2014-04-30 11:17           ` Michael Kerrisk (man-pages)
@ 2014-04-30 13:36             ` Michael Kerrisk (man-pages)
  2014-04-30 16:05               ` Rich Felker
  0 siblings, 1 reply; 17+ messages in thread
From: Michael Kerrisk (man-pages) @ 2014-04-30 13:36 UTC (permalink / raw)
  To: Ondřej Bílka
  Cc: Michael Kerrisk, David Miller, Andreas Schwab, libc-alpha

On Wed, Apr 30, 2014 at 1:17 PM, Michael Kerrisk (man-pages)
<mtk.manpages@gmail.com> wrote:
> Hello Ondřej,
>
> On 04/30/2014 11:07 AM, Ondřej Bílka wrote:
>> On Wed, Apr 30, 2014 at 10:28:53AM +0200, Michael Kerrisk (man-pages) wrote:
>>> On 04/28/2014 07:01 PM, David Miller wrote:
>>>> From: Ondřej Bílka <neleai@seznam.cz>
>>>> Date: Mon, 28 Apr 2014 18:04:20 +0200
>>>>
>>>>>    * sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Do not clobber
>>>>>    timeout argument.
>>>>
>>>> It is extremely unfortunate if we've defined this argument as const,
>>>> now you are making it so that the user has no mechanism to get the
>>>> updated timeval other than to define their own syscall stubs.
>>>>
>>>> This is doubly unfortunately since there is absolutely no reason for
>>>> us to have defined the interface different from what the kernel
>>>> actually provides.
>>>
>>> Agreed. Surely, the right fix here is simply to remove the "const"
>>> qualifier from the glibc API?
>>>
>> Now I am also for removing const. Initially I looked to documentation
>> and this was undocumented feature so I was not sure about it.
>
> Yes, my mistake.

Sigh! Now I remember why that timeout behavior didn't get documented:

http://thread.gmane.org/gmane.linux.man/3477/focus=3500

The timeout argument is completely broken, AFAICT. I never did get a
reply from Arnaldo (but, as you can see in the thread, others agreed
tha there's a problem), and then I got distracted :-{.

Cheers,

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] 17+ messages in thread

* Re: [PATCH v2][BZ 16852] Do not clobber recvmmsg argument.
  2014-04-30 13:36             ` Michael Kerrisk (man-pages)
@ 2014-04-30 16:05               ` Rich Felker
  2014-05-04 19:31                 ` Michael Kerrisk (man-pages)
  0 siblings, 1 reply; 17+ messages in thread
From: Rich Felker @ 2014-04-30 16:05 UTC (permalink / raw)
  To: Michael Kerrisk (man-pages)
  Cc: Ondřej Bílka, David Miller, Andreas Schwab, libc-alpha

On Wed, Apr 30, 2014 at 03:35:40PM +0200, Michael Kerrisk (man-pages) wrote:
> On Wed, Apr 30, 2014 at 1:17 PM, Michael Kerrisk (man-pages)
> <mtk.manpages@gmail.com> wrote:
> > Hello Ondřej,
> >
> > On 04/30/2014 11:07 AM, Ondřej Bílka wrote:
> >> On Wed, Apr 30, 2014 at 10:28:53AM +0200, Michael Kerrisk (man-pages) wrote:
> >>> On 04/28/2014 07:01 PM, David Miller wrote:
> >>>> From: Ondřej Bílka <neleai@seznam.cz>
> >>>> Date: Mon, 28 Apr 2014 18:04:20 +0200
> >>>>
> >>>>>    * sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Do not clobber
> >>>>>    timeout argument.
> >>>>
> >>>> It is extremely unfortunate if we've defined this argument as const,
> >>>> now you are making it so that the user has no mechanism to get the
> >>>> updated timeval other than to define their own syscall stubs.
> >>>>
> >>>> This is doubly unfortunately since there is absolutely no reason for
> >>>> us to have defined the interface different from what the kernel
> >>>> actually provides.
> >>>
> >>> Agreed. Surely, the right fix here is simply to remove the "const"
> >>> qualifier from the glibc API?
> >>>
> >> Now I am also for removing const. Initially I looked to documentation
> >> and this was undocumented feature so I was not sure about it.
> >
> > Yes, my mistake.
> 
> Sigh! Now I remember why that timeout behavior didn't get documented:
> 
> http://thread.gmane.org/gmane.linux.man/3477/focus=3500
> 
> The timeout argument is completely broken, AFAICT. I never did get a
> reply from Arnaldo (but, as you can see in the thread, others agreed
> tha there's a problem), and then I got distracted :-{.

Indeed, this looks like a big problem and I don't see any viable
solution. I think the documented behavior, for now, should be that the
behavior is unspecified unless the timeout is a null pointer.

Rich

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

* Re: [PATCH v2][BZ 16852] Do not clobber recvmmsg argument.
  2014-04-28 17:01     ` David Miller
  2014-04-30  8:29       ` Michael Kerrisk (man-pages)
@ 2014-05-04 15:35       ` Ondřej Bílka
  2014-05-23 12:50         ` [PING][PATCH v2][BZ 16852] Fix recvmmsg prototype Ondřej Bílka
                           ` (2 more replies)
  1 sibling, 3 replies; 17+ messages in thread
From: Ondřej Bílka @ 2014-05-04 15:35 UTC (permalink / raw)
  To: David Miller; +Cc: schwab, libc-alpha

On Mon, Apr 28, 2014 at 01:01:22PM -0400, David Miller wrote:
> From: Ondřej Bílka <neleai@seznam.cz>
> Date: Mon, 28 Apr 2014 18:04:20 +0200
> 
> > 	* sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Do not clobber
> > 	timeout argument.
> 
> It is extremely unfortunate if we've defined this argument as const,
> now you are making it so that the user has no mechanism to get the
> updated timeval other than to define their own syscall stubs.
> 
> This is doubly unfortunately since there is absolutely no reason for
> us to have defined the interface different from what the kernel
> actually provides.

Ok, here is second alternative that drops constness.


	* socket/recvmmsg.c (recvmmsg): Drop const argument.
	* socket/sys/socket.h: Likewise
	* sysdeps/unix/sysv/linux/recvmmsg.c: Likewise.

---
 socket/recvmmsg.c                  | 2 +-
 socket/sys/socket.h                | 2 +-
 sysdeps/unix/sysv/linux/recvmmsg.c | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/socket/recvmmsg.c b/socket/recvmmsg.c
index ed0c369..3daa501 100644
--- a/socket/recvmmsg.c
+++ b/socket/recvmmsg.c
@@ -23,7 +23,7 @@
    Returns the number of bytes read or -1 for errors.  */
 int
 recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
-	  const struct timespec *tmo)
+	  struct timespec *tmo)
 {
   __set_errno (ENOSYS);
   return -1;
diff --git a/socket/sys/socket.h b/socket/sys/socket.h
index 95ee26a..091b08c 100644
--- a/socket/sys/socket.h
+++ b/socket/sys/socket.h
@@ -209,7 +209,7 @@ extern ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags);
    __THROW.  */
 extern int recvmmsg (int __fd, struct mmsghdr *__vmessages,
 		     unsigned int __vlen, int __flags,
-		     const struct timespec *__tmo);
+		     struct timespec *__tmo);
 #endif
 
 
diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c
index 57ddf31..6c9ca44 100644
--- a/sysdeps/unix/sysv/linux/recvmmsg.c
+++ b/sysdeps/unix/sysv/linux/recvmmsg.c
@@ -35,7 +35,7 @@
 #ifdef __NR_recvmmsg
 int
 recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
-	  const struct timespec *tmo)
+	  struct timespec *tmo)
 {
   if (SINGLE_THREAD_P)
     return INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, tmo);
@@ -52,14 +52,14 @@ recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
 # ifndef __ASSUME_RECVMMSG_SOCKETCALL
 extern int __internal_recvmmsg (int fd, struct mmsghdr *vmessages,
 				unsigned int vlen, int flags,
-				const struct timespec *tmo)
+				struct timespec *tmo)
      attribute_hidden;
 
 static int have_recvmmsg;
 
 int
 recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
-	  const struct timespec *tmo)
+	  struct timespec *tmo)
 {
   if (__glibc_likely (have_recvmmsg >= 0))
     {
-- 
1.8.4.rc3

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

* Re: [PATCH v2][BZ 16852] Do not clobber recvmmsg argument.
  2014-04-30 16:05               ` Rich Felker
@ 2014-05-04 19:31                 ` Michael Kerrisk (man-pages)
  0 siblings, 0 replies; 17+ messages in thread
From: Michael Kerrisk (man-pages) @ 2014-05-04 19:31 UTC (permalink / raw)
  To: Rich Felker
  Cc: Ondřej Bílka, David Miller, Andreas Schwab, libc-alpha

On Wed, Apr 30, 2014 at 6:04 PM, Rich Felker <dalias@libc.org> wrote:
> On Wed, Apr 30, 2014 at 03:35:40PM +0200, Michael Kerrisk (man-pages) wrote:
>> On Wed, Apr 30, 2014 at 1:17 PM, Michael Kerrisk (man-pages)
>> <mtk.manpages@gmail.com> wrote:
>> > Hello Ondřej,
>> >
>> > On 04/30/2014 11:07 AM, Ondřej Bílka wrote:
>> >> On Wed, Apr 30, 2014 at 10:28:53AM +0200, Michael Kerrisk (man-pages) wrote:
>> >>> On 04/28/2014 07:01 PM, David Miller wrote:
>> >>>> From: Ondřej Bílka <neleai@seznam.cz>
>> >>>> Date: Mon, 28 Apr 2014 18:04:20 +0200
>> >>>>
>> >>>>>    * sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Do not clobber
>> >>>>>    timeout argument.
>> >>>>
>> >>>> It is extremely unfortunate if we've defined this argument as const,
>> >>>> now you are making it so that the user has no mechanism to get the
>> >>>> updated timeval other than to define their own syscall stubs.
>> >>>>
>> >>>> This is doubly unfortunately since there is absolutely no reason for
>> >>>> us to have defined the interface different from what the kernel
>> >>>> actually provides.
>> >>>
>> >>> Agreed. Surely, the right fix here is simply to remove the "const"
>> >>> qualifier from the glibc API?
>> >>>
>> >> Now I am also for removing const. Initially I looked to documentation
>> >> and this was undocumented feature so I was not sure about it.
>> >
>> > Yes, my mistake.
>>
>> Sigh! Now I remember why that timeout behavior didn't get documented:
>>
>> http://thread.gmane.org/gmane.linux.man/3477/focus=3500
>>
>> The timeout argument is completely broken, AFAICT. I never did get a
>> reply from Arnaldo (but, as you can see in the thread, others agreed
>> tha there's a problem), and then I got distracted :-{.
>
> Indeed, this looks like a big problem and I don't see any viable
> solution. I think the documented behavior, for now, should be that the
> behavior is unspecified unless the timeout is a null pointer.

I got the formulation of the program slightly wrong, but the
fundamental problem is the same:

http://thread.gmane.org/gmane.linux.man/5677/focus=5702

Cheers,

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] 17+ messages in thread

* [PING][PATCH v2][BZ 16852] Fix recvmmsg prototype
  2014-05-04 15:35       ` Ondřej Bílka
@ 2014-05-23 12:50         ` Ondřej Bílka
  2014-06-04 15:57           ` Ondřej Bílka
  2014-08-02 14:16         ` [PATCH v2][BZ 16852] Do not clobber recvmmsg argument Mike Frysinger
  2015-02-18 17:45         ` Andreas Schwab
  2 siblings, 1 reply; 17+ messages in thread
From: Ondřej Bílka @ 2014-05-23 12:50 UTC (permalink / raw)
  To: David Miller; +Cc: schwab, libc-alpha

ping
On Sun, May 04, 2014 at 05:34:24PM +0200, Ondřej Bílka wrote:
> On Mon, Apr 28, 2014 at 01:01:22PM -0400, David Miller wrote:
> > From: Ondřej Bílka <neleai@seznam.cz>
> > Date: Mon, 28 Apr 2014 18:04:20 +0200
> > 
> > > 	* sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Do not clobber
> > > 	timeout argument.
> > 
> > It is extremely unfortunate if we've defined this argument as const,
> > now you are making it so that the user has no mechanism to get the
> > updated timeval other than to define their own syscall stubs.
> > 
> > This is doubly unfortunately since there is absolutely no reason for
> > us to have defined the interface different from what the kernel
> > actually provides.
> 
> Ok, here is second alternative that drops constness.
> 
> 
> 	* socket/recvmmsg.c (recvmmsg): Drop const argument.
> 	* socket/sys/socket.h: Likewise
> 	* sysdeps/unix/sysv/linux/recvmmsg.c: Likewise.
> 
> ---
>  socket/recvmmsg.c                  | 2 +-
>  socket/sys/socket.h                | 2 +-
>  sysdeps/unix/sysv/linux/recvmmsg.c | 6 +++---
>  3 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/socket/recvmmsg.c b/socket/recvmmsg.c
> index ed0c369..3daa501 100644
> --- a/socket/recvmmsg.c
> +++ b/socket/recvmmsg.c
> @@ -23,7 +23,7 @@
>     Returns the number of bytes read or -1 for errors.  */
>  int
>  recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
> -	  const struct timespec *tmo)
> +	  struct timespec *tmo)
>  {
>    __set_errno (ENOSYS);
>    return -1;
> diff --git a/socket/sys/socket.h b/socket/sys/socket.h
> index 95ee26a..091b08c 100644
> --- a/socket/sys/socket.h
> +++ b/socket/sys/socket.h
> @@ -209,7 +209,7 @@ extern ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags);
>     __THROW.  */
>  extern int recvmmsg (int __fd, struct mmsghdr *__vmessages,
>  		     unsigned int __vlen, int __flags,
> -		     const struct timespec *__tmo);
> +		     struct timespec *__tmo);
>  #endif
>  
>  
> diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c
> index 57ddf31..6c9ca44 100644
> --- a/sysdeps/unix/sysv/linux/recvmmsg.c
> +++ b/sysdeps/unix/sysv/linux/recvmmsg.c
> @@ -35,7 +35,7 @@
>  #ifdef __NR_recvmmsg
>  int
>  recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
> -	  const struct timespec *tmo)
> +	  struct timespec *tmo)
>  {
>    if (SINGLE_THREAD_P)
>      return INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, tmo);
> @@ -52,14 +52,14 @@ recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
>  # ifndef __ASSUME_RECVMMSG_SOCKETCALL
>  extern int __internal_recvmmsg (int fd, struct mmsghdr *vmessages,
>  				unsigned int vlen, int flags,
> -				const struct timespec *tmo)
> +				struct timespec *tmo)
>       attribute_hidden;
>  
>  static int have_recvmmsg;
>  
>  int
>  recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
> -	  const struct timespec *tmo)
> +	  struct timespec *tmo)
>  {
>    if (__glibc_likely (have_recvmmsg >= 0))
>      {
> -- 
> 1.8.4.rc3

-- 

parallel processors running perpendicular today

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

* Re: [PING][PATCH v2][BZ 16852] Fix recvmmsg prototype
  2014-05-23 12:50         ` [PING][PATCH v2][BZ 16852] Fix recvmmsg prototype Ondřej Bílka
@ 2014-06-04 15:57           ` Ondřej Bílka
  0 siblings, 0 replies; 17+ messages in thread
From: Ondřej Bílka @ 2014-06-04 15:57 UTC (permalink / raw)
  To: David Miller; +Cc: schwab, libc-alpha

ping
On Fri, May 23, 2014 at 02:02:02PM +0200, Ondřej Bílka wrote:
> ping
> On Sun, May 04, 2014 at 05:34:24PM +0200, Ondřej Bílka wrote:
> > On Mon, Apr 28, 2014 at 01:01:22PM -0400, David Miller wrote:
> > > From: Ondřej Bílka <neleai@seznam.cz>
> > > Date: Mon, 28 Apr 2014 18:04:20 +0200
> > > 
> > > > 	* sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Do not clobber
> > > > 	timeout argument.
> > > 
> > > It is extremely unfortunate if we've defined this argument as const,
> > > now you are making it so that the user has no mechanism to get the
> > > updated timeval other than to define their own syscall stubs.
> > > 
> > > This is doubly unfortunately since there is absolutely no reason for
> > > us to have defined the interface different from what the kernel
> > > actually provides.
> > 
> > Ok, here is second alternative that drops constness.
> > 
> > 
> > 	* socket/recvmmsg.c (recvmmsg): Drop const argument.
> > 	* socket/sys/socket.h: Likewise
> > 	* sysdeps/unix/sysv/linux/recvmmsg.c: Likewise.
> > 
> > ---
> >  socket/recvmmsg.c                  | 2 +-
> >  socket/sys/socket.h                | 2 +-
> >  sysdeps/unix/sysv/linux/recvmmsg.c | 6 +++---
> >  3 files changed, 5 insertions(+), 5 deletions(-)
> > 
> > diff --git a/socket/recvmmsg.c b/socket/recvmmsg.c
> > index ed0c369..3daa501 100644
> > --- a/socket/recvmmsg.c
> > +++ b/socket/recvmmsg.c
> > @@ -23,7 +23,7 @@
> >     Returns the number of bytes read or -1 for errors.  */
> >  int
> >  recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
> > -	  const struct timespec *tmo)
> > +	  struct timespec *tmo)
> >  {
> >    __set_errno (ENOSYS);
> >    return -1;
> > diff --git a/socket/sys/socket.h b/socket/sys/socket.h
> > index 95ee26a..091b08c 100644
> > --- a/socket/sys/socket.h
> > +++ b/socket/sys/socket.h
> > @@ -209,7 +209,7 @@ extern ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags);
> >     __THROW.  */
> >  extern int recvmmsg (int __fd, struct mmsghdr *__vmessages,
> >  		     unsigned int __vlen, int __flags,
> > -		     const struct timespec *__tmo);
> > +		     struct timespec *__tmo);
> >  #endif
> >  
> >  
> > diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c
> > index 57ddf31..6c9ca44 100644
> > --- a/sysdeps/unix/sysv/linux/recvmmsg.c
> > +++ b/sysdeps/unix/sysv/linux/recvmmsg.c
> > @@ -35,7 +35,7 @@
> >  #ifdef __NR_recvmmsg
> >  int
> >  recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
> > -	  const struct timespec *tmo)
> > +	  struct timespec *tmo)
> >  {
> >    if (SINGLE_THREAD_P)
> >      return INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, tmo);
> > @@ -52,14 +52,14 @@ recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
> >  # ifndef __ASSUME_RECVMMSG_SOCKETCALL
> >  extern int __internal_recvmmsg (int fd, struct mmsghdr *vmessages,
> >  				unsigned int vlen, int flags,
> > -				const struct timespec *tmo)
> > +				struct timespec *tmo)
> >       attribute_hidden;
> >  
> >  static int have_recvmmsg;
> >  
> >  int
> >  recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
> > -	  const struct timespec *tmo)
> > +	  struct timespec *tmo)
> >  {
> >    if (__glibc_likely (have_recvmmsg >= 0))
> >      {
> > -- 
> > 1.8.4.rc3
> 
> -- 
> 
> parallel processors running perpendicular today

-- 

PCMCIA slave driver

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

* Re: [PATCH v2][BZ 16852] Do not clobber recvmmsg argument.
  2014-05-04 15:35       ` Ondřej Bílka
  2014-05-23 12:50         ` [PING][PATCH v2][BZ 16852] Fix recvmmsg prototype Ondřej Bílka
@ 2014-08-02 14:16         ` Mike Frysinger
  2014-09-20 11:55           ` Ondřej Bílka
  2015-02-18 17:45         ` Andreas Schwab
  2 siblings, 1 reply; 17+ messages in thread
From: Mike Frysinger @ 2014-08-02 14:16 UTC (permalink / raw)
  To: libc-alpha; +Cc: Ondřej Bílka, David Miller, schwab

[-- Attachment #1: Type: text/plain, Size: 828 bytes --]

On Sun 04 May 2014 17:34:24 Ondřej Bílka wrote:
> On Mon, Apr 28, 2014 at 01:01:22PM -0400, David Miller wrote:
> > From: Ondřej Bílka <neleai@seznam.cz>
> > Date: Mon, 28 Apr 2014 18:04:20 +0200
> > 
> > > 	* sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Do not clobber
> > > 	timeout argument.
> > 
> > It is extremely unfortunate if we've defined this argument as const,
> > now you are making it so that the user has no mechanism to get the
> > updated timeval other than to define their own syscall stubs.
> > 
> > This is doubly unfortunately since there is absolutely no reason for
> > us to have defined the interface different from what the kernel
> > actually provides.
> 
> Ok, here is second alternative that drops constness.

i think everyone agreed this was the best way to go for now
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH v2][BZ 16852] Do not clobber recvmmsg argument.
  2014-08-02 14:16         ` [PATCH v2][BZ 16852] Do not clobber recvmmsg argument Mike Frysinger
@ 2014-09-20 11:55           ` Ondřej Bílka
  0 siblings, 0 replies; 17+ messages in thread
From: Ondřej Bílka @ 2014-09-20 11:55 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: libc-alpha, David Miller, schwab

On Sat, Aug 02, 2014 at 10:16:40AM -0400, Mike Frysinger wrote:
> On Sun 04 May 2014 17:34:24 Ondřej Bílka wrote:
> > On Mon, Apr 28, 2014 at 01:01:22PM -0400, David Miller wrote:
> > > From: Ondřej Bílka <neleai@seznam.cz>
> > > Date: Mon, 28 Apr 2014 18:04:20 +0200
> > > 
> > > > 	* sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Do not clobber
> > > > 	timeout argument.
> > > 
> > > It is extremely unfortunate if we've defined this argument as const,
> > > now you are making it so that the user has no mechanism to get the
> > > updated timeval other than to define their own syscall stubs.
> > > 
> > > This is doubly unfortunately since there is absolutely no reason for
> > > us to have defined the interface different from what the kernel
> > > actually provides.
> > 
> > Ok, here is second alternative that drops constness.
> 
> i think everyone agreed this was the best way to go for now
> -mike

As I decided to relax on holiday this waited a while. I pushed this now.

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

* Re: [PATCH v2][BZ 16852] Do not clobber recvmmsg argument.
  2014-05-04 15:35       ` Ondřej Bílka
  2014-05-23 12:50         ` [PING][PATCH v2][BZ 16852] Fix recvmmsg prototype Ondřej Bílka
  2014-08-02 14:16         ` [PATCH v2][BZ 16852] Do not clobber recvmmsg argument Mike Frysinger
@ 2015-02-18 17:45         ` Andreas Schwab
  2 siblings, 0 replies; 17+ messages in thread
From: Andreas Schwab @ 2015-02-18 17:45 UTC (permalink / raw)
  To: Ondřej Bílka; +Cc: David Miller, libc-alpha

Ondřej Bílka <neleai@seznam.cz> writes:

> 	* socket/recvmmsg.c (recvmmsg): Drop const argument.
                                                  ^from
> 	* socket/sys/socket.h: Likewise
> 	* sysdeps/unix/sysv/linux/recvmmsg.c: Likewise.

Ok.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

end of thread, other threads:[~2015-02-18 17:45 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-28 15:29 [PATCH][BZ 16852] Do not clobber recvmmsg argument Ondřej Bílka
2014-04-28 15:41 ` Andreas Schwab
2014-04-28 16:04   ` [PATCH v2][BZ " Ondřej Bílka
2014-04-28 17:01     ` David Miller
2014-04-30  8:29       ` Michael Kerrisk (man-pages)
2014-04-30  9:07         ` Ondřej Bílka
2014-04-30 11:17           ` Michael Kerrisk (man-pages)
2014-04-30 13:36             ` Michael Kerrisk (man-pages)
2014-04-30 16:05               ` Rich Felker
2014-05-04 19:31                 ` Michael Kerrisk (man-pages)
2014-05-04 15:35       ` Ondřej Bílka
2014-05-23 12:50         ` [PING][PATCH v2][BZ 16852] Fix recvmmsg prototype Ondřej Bílka
2014-06-04 15:57           ` Ondřej Bílka
2014-08-02 14:16         ` [PATCH v2][BZ 16852] Do not clobber recvmmsg argument Mike Frysinger
2014-09-20 11:55           ` Ondřej Bílka
2015-02-18 17:45         ` Andreas Schwab
2014-04-28 18:07     ` Rich Felker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).