[v2,BZ,16852] Do not clobber recvmmsg argument.

Message ID 20140504153424.GA16138@domone.podge
State Superseded
Headers

Commit Message

Ondrej Bilka May 4, 2014, 3:34 p.m. UTC
  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(-)
  

Comments

Ondrej Bilka May 23, 2014, 12:02 p.m. UTC | #1
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
  
Ondrej Bilka June 4, 2014, 3:57 p.m. UTC | #2
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
  
Mike Frysinger Aug. 2, 2014, 2:16 p.m. UTC | #3
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
  
Ondrej Bilka Sept. 20, 2014, 11:55 a.m. UTC | #4
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.
  
Andreas Schwab Feb. 18, 2015, 5:45 p.m. UTC | #5
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.
  

Patch

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))
     {