Linux-man Archive on lore.kernel.org
 help / color / Atom feed
* linux-headers-5.2 and proper use of SIOCGSTAMP
@ 2019-07-20 16:48 Sergei Trofimovich
  2019-07-20 18:10 ` Florian Weimer
  0 siblings, 1 reply; 5+ messages in thread
From: Sergei Trofimovich @ 2019-07-20 16:48 UTC (permalink / raw)
  To: netdev, linux-kernel, libc-alpha
  Cc: Arnd Bergmann, David S. Miller, mtk.manpages, linux-man

Commit https://github.com/torvalds/linux/commit/0768e17073dc527ccd18ed5f96ce85f9985e9115
("net: socket: implement 64-bit timestamps") caused a bit of userspace breakage
for existing programs:
- firefox: https://bugs.gentoo.org/689808
- qemu: https://lists.sr.ht/~philmd/qemu/%3C20190604071915.288045-1-borntraeger%40de.ibm.com%3E
- linux-atm: https://gitweb.gentoo.org/repo/gentoo.git/tree/net-dialup/linux-atm/files/linux-atm-2.5.2-linux-5.2-SIOCGSTAMP.patch?id=408621819a85bf67a73efd33a06ea371c20ea5a2

I have a question: how a well-behaved app should include 'SIOCGSTAMP'
definition to keep being buildable against old and new linux-headers?

'man 7 socket' explicitly mentions SIOCGSTAMP and mentions only
    #include <sys/socket.h>
as needed header.

Should #include <linux/sockios.h> always be included by user app?
Or should glibc tweak it's definition of '#include <sys/socket.h>'
to make it available on both old and new version of linux headers?

CCing both kernel and glibc folk as I don't understand on which
side issue should be fixed.

Thanks!

-- 

  Sergei

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

* Re: linux-headers-5.2 and proper use of SIOCGSTAMP
  2019-07-20 16:48 linux-headers-5.2 and proper use of SIOCGSTAMP Sergei Trofimovich
@ 2019-07-20 18:10 ` Florian Weimer
  2019-07-20 18:50   ` Arnd Bergmann
  0 siblings, 1 reply; 5+ messages in thread
From: Florian Weimer @ 2019-07-20 18:10 UTC (permalink / raw)
  To: Sergei Trofimovich
  Cc: netdev, linux-kernel, libc-alpha, Arnd Bergmann, David S. Miller,
	mtk.manpages, linux-man

* Sergei Trofimovich:

> Should #include <linux/sockios.h> always be included by user app?
> Or should glibc tweak it's definition of '#include <sys/socket.h>'
> to make it available on both old and new version of linux headers?

What is the reason for dropping SIOCGSTAMP from <asm/socket.h>?

If we know that, it will be much easier to decide what to do about
<sys/socket.h>.

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

* Re: linux-headers-5.2 and proper use of SIOCGSTAMP
  2019-07-20 18:10 ` Florian Weimer
@ 2019-07-20 18:50   ` Arnd Bergmann
  2019-07-20 19:34     ` Florian Weimer
  0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2019-07-20 18:50 UTC (permalink / raw)
  To: Florian Weimer
  Cc: Sergei Trofimovich, Networking, Linux Kernel Mailing List,
	GNU C Library, David S. Miller, Michael Kerrisk, linux-man

On Sat, Jul 20, 2019 at 8:10 PM Florian Weimer <fw@deneb.enyo.de> wrote:
>
> * Sergei Trofimovich:
>
> > Should #include <linux/sockios.h> always be included by user app?
> > Or should glibc tweak it's definition of '#include <sys/socket.h>'
> > to make it available on both old and new version of linux headers?
>
> What is the reason for dropping SIOCGSTAMP from <asm/socket.h>?
>
> If we know that, it will be much easier to decide what to do about
> <sys/socket.h>.

As far as I can tell, nobody thought it would be a problem to move it
from asm/sockios.h to linux/sockios.h, as the general rule is that one
should use the linux/*.h version if both exist, and that the asm/*.h
version only contains architecture specific definitions. The new
definition is the same across all architectures, so it made sense to
have it in the common file.

If the assumption was wrong, the obvious solution is to duplicate the
definitions everywhere or move the common parts into
asm-generic/sockios.h, but it would have been better to hear about
that earlier.

      Arnd

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

* Re: linux-headers-5.2 and proper use of SIOCGSTAMP
  2019-07-20 18:50   ` Arnd Bergmann
@ 2019-07-20 19:34     ` Florian Weimer
  2019-07-20 20:40       ` Arnd Bergmann
  0 siblings, 1 reply; 5+ messages in thread
From: Florian Weimer @ 2019-07-20 19:34 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Sergei Trofimovich, Networking, Linux Kernel Mailing List,
	GNU C Library, David S. Miller, Michael Kerrisk, linux-man

* Arnd Bergmann:

> On Sat, Jul 20, 2019 at 8:10 PM Florian Weimer <fw@deneb.enyo.de> wrote:
>>
>> * Sergei Trofimovich:
>>
>> > Should #include <linux/sockios.h> always be included by user app?
>> > Or should glibc tweak it's definition of '#include <sys/socket.h>'
>> > to make it available on both old and new version of linux headers?
>>
>> What is the reason for dropping SIOCGSTAMP from <asm/socket.h>?
>>
>> If we know that, it will be much easier to decide what to do about
>> <sys/socket.h>.
>
> As far as I can tell, nobody thought it would be a problem to move it
> from asm/sockios.h to linux/sockios.h, as the general rule is that one
> should use the linux/*.h version if both exist, and that the asm/*.h
> version only contains architecture specific definitions. The new
> definition is the same across all architectures, so it made sense to
> have it in the common file.

Most of the socket-related constants are not exposed in UAPI headers,
although userspace is expected to use them.  It seems to me that due
to the lack of other options among the UAPI headers, <asm/socket.h>
has been a dumping ground for various socket-related things in the
past, whether actually architecture-specific or not.

<linux/socket.h> does not include <asm/socket.h>, so that's why we
usually end up with including <asm/socket.h> (perhaps indirectly via
<sys/socket.h>), which used to include <asm/sockios.h> on most (all?)
architectures.  That in turn provided some of the SIOC* constants in
the past, so people didn't investigate other options.

I think we can change glibc to include <linux/sockios.h> in addition
to <asm/socket.h>.  <linux/sockios.h> looks reasonably clean to me,
much better than <asm/socket.h>.  I'm still working on the other
breakage, and I'm severely limited by the machine resources I have
access to.

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

* Re: linux-headers-5.2 and proper use of SIOCGSTAMP
  2019-07-20 19:34     ` Florian Weimer
@ 2019-07-20 20:40       ` Arnd Bergmann
  0 siblings, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2019-07-20 20:40 UTC (permalink / raw)
  To: Florian Weimer
  Cc: Sergei Trofimovich, Networking, Linux Kernel Mailing List,
	GNU C Library, David S. Miller, Michael Kerrisk, linux-man

On Sat, Jul 20, 2019 at 9:34 PM Florian Weimer <fw@deneb.enyo.de> wrote:
> * Arnd Bergmann:
> > On Sat, Jul 20, 2019 at 8:10 PM Florian Weimer <fw@deneb.enyo.de> wrote:
> > As far as I can tell, nobody thought it would be a problem to move it
> > from asm/sockios.h to linux/sockios.h, as the general rule is that one
> > should use the linux/*.h version if both exist, and that the asm/*.h
> > version only contains architecture specific definitions. The new
> > definition is the same across all architectures, so it made sense to
> > have it in the common file.
>
> Most of the socket-related constants are not exposed in UAPI headers,
> although userspace is expected to use them.  It seems to me that due
> to the lack of other options among the UAPI headers, <asm/socket.h>
> has been a dumping ground for various socket-related things in the
> past, whether actually architecture-specific or not.
>
> <linux/socket.h> does not include <asm/socket.h>, so that's why we
> usually end up with including <asm/socket.h> (perhaps indirectly via
> <sys/socket.h>), which used to include <asm/sockios.h> on most (all?)
> architectures.  That in turn provided some of the SIOC* constants in
> the past, so people didn't investigate other options.

It seems that both the missing constants and the fact that
linux/socket.h doesn't include asm/socket.h and linux/sockios.h
goes back to a 21 year old commit:

commit 74f513101058f7585176ea8cdf6fb026faea8a7e
Author: linus1 <torvalds@linuxfoundation.org>
Date:   Wed May 20 11:00:00 1998 -0800

    [tytso] include/asm-i386/posix_types.h
    This quick fix eliminates a lot of warning messages when
    compiling e2fsprogs under glibc.  This is because the glibc header files
    defines its own version of FD_SET, FD_ZERO, etc., and so if you need to
    #include the kernel include files, you get a lot of duplicate defined
    macro warning messages.  This patch simply #ifdef's out the kernel
    versions of these function if the kernel is not being compiled and the
    glibc header files are in use.

diff --git a/include/linux/socket.h b/include/linux/socket.h
index 08f0d281401c..35a7629b6b70 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -1,6 +1,8 @@
 #ifndef _LINUX_SOCKET_H
 #define _LINUX_SOCKET_H

+#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
+
 #include <asm/socket.h>                        /* arch-dependent
defines       */
 #include <linux/sockios.h>             /* the SIOCxxx I/O controls     */
 #include <linux/uio.h>                 /* iovec support                */
@@ -256,4 +258,5 @@ extern int move_addr_to_user(void *kaddr, int
klen, void *uaddr, int *ulen);
 extern int move_addr_to_kernel(void *uaddr, int ulen, void *kaddr);
 extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data);
 #endif
+#endif /* not kernel and not glibc */
 #endif /* _LINUX_SOCKET_H */

(the same commit did similar changes in linux/stat.h and asm/posix_types.h)

Over time, the check for glibc was removed (to allow including linux/socket.h
before sys/socket.h), and all the #ifdef __KERNEL__ bits were removed
from the installed header as part of the uapi header split.

> I think we can change glibc to include <linux/sockios.h> in addition
> to <asm/socket.h>.  <linux/sockios.h> looks reasonably clean to me,
> much better than <asm/socket.h>.

That seems reasonable to me, but overall my fear is that these headers
are already so broken that any change will risk breaking something
in more or less unexpected ways.

        Arnd

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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-20 16:48 linux-headers-5.2 and proper use of SIOCGSTAMP Sergei Trofimovich
2019-07-20 18:10 ` Florian Weimer
2019-07-20 18:50   ` Arnd Bergmann
2019-07-20 19:34     ` Florian Weimer
2019-07-20 20:40       ` Arnd Bergmann

Linux-man Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-man/0 linux-man/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-man linux-man/ https://lore.kernel.org/linux-man \
		linux-man@vger.kernel.org linux-man@archiver.kernel.org
	public-inbox-index linux-man


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-man


AGPL code for this site: git clone https://public-inbox.org/ public-inbox