Bug 19682 - s390x: Incorrect syscall definitions cause breakage with Linux 4.3 headers
Summary: s390x: Incorrect syscall definitions cause breakage with Linux 4.3 headers
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: network (show other bugs)
Version: 2.22
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-19 20:11 UTC by Florian Weimer
Modified: 2016-03-07 18:04 UTC (History)
3 users (show)

See Also:
Host:
Target: s390x
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Weimer 2016-02-19 20:11:59 UTC
Beginning with Linux 4.3, the kernel headers contain system call numbers __NR_socket etc. on s390x.

In glibc 2.22 and earlier, sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list contains the following syscall definitions:

# proper socket implementations:
accept		-	accept		Ci:iBN	__libc_accept	__accept accept
bind		-	bind		i:ipi	__bind		bind
connect		-	connect		Ci:ipi	__libc_connect	__connect connect
getpeername	-	getpeername	i:ipp	__getpeername	getpeername
getsockname	-	getsockname	i:ipp	__getsockname	getsockname
getsockopt	-	getsockopt	i:iiiBN	__getsockopt	getsockopt
listen		-	listen		i:ii	__listen	listen
recv		-	recv		Ci:ibni	__libc_recv	__recv recv
recvfrom	-	recvfrom	Ci:ibniBN	__libc_recvfrom	__recvfrom recvfrom
recvmsg		-	recvmsg		Ci:ipi	__libc_recvmsg	__recvmsg recvmsg
send		-	send		Ci:ibni	__libc_send	__send send
sendmsg		-	sendmsg		Ci:ipi	__libc_sendmsg	__sendmsg sendmsg
sendto		-	sendto		Ci:ibnibn	__libc_sendto	__sendto sendto
setsockopt	-	setsockopt	i:iiibn	__setsockopt	setsockopt
shutdown	-	shutdown	i:ii	__shutdown	shutdown
socket		-	socket		i:iii	__socket	socket
socketpair	-	socketpair	i:iiif	__socketpair	socketpair

Due to the lack of the __NR_ definitions for them, these were ignored before.

With kernel 4.3 headers, they become active, and somehow override the generic code.  The resulting glibc build will require kernel 4.3 to work, even with --enable-kernel=2.6.32 at configure time.

I suggest to backport the syscalls.list removal patch from glibc commit 016495b818cb61df7d0d10e6db54074271b3e3a5 (S390: Call direct system calls for socket operations.) to address this.
Comment 1 Stefan Liebler 2016-02-25 09:37:27 UTC
I suggest to remove only the direct socket-syscalls in s390-64/syscalls.list for older glibc-versions.

These direct socket syscalls were never used on s390 before Linux 4.3.
Removing them from the list, will enable building older glibc-releases
with Linux 4.3 and newer. Then, the behaviour of the socket functions
are not changed compared to the original release-version
and the socket-multiplexer-syscall is always used.

Which glibc releases should get the backport or are still maintained?
2.22, 2.21, ...?
Comment 2 Florian Weimer 2016-02-25 09:58:34 UTC
(In reply to Stefan Liebler from comment #1)
> I suggest to remove only the direct socket-syscalls in s390-64/syscalls.list
> for older glibc-versions.

This is what I did in Fedora 23 and 22 (based on glibc 2.22 and glibc 2.21).  The Fedora 22 update has still not been released, but the Fedora 23 update works well (at least there haven't been any angry complaints).

> Which glibc releases should get the backport or are still maintained?
> 2.22, 2.21, ...?

Sorry, no idea.  2.22 and 2.21 still have active stable branches.  2.19 is used by Debian jessie.  But beyond that, I don't know.
Comment 3 Carlos O'Donell 2016-02-25 14:46:17 UTC
(In reply to Florian Weimer from comment #2)
> (In reply to Stefan Liebler from comment #1)
> > I suggest to remove only the direct socket-syscalls in s390-64/syscalls.list
> > for older glibc-versions.
> 
> This is what I did in Fedora 23 and 22 (based on glibc 2.22 and glibc 2.21).
> The Fedora 22 update has still not been released, but the Fedora 23 update
> works well (at least there haven't been any angry complaints).
> 
> > Which glibc releases should get the backport or are still maintained?
> > 2.22, 2.21, ...?
> 
> Sorry, no idea.  2.22 and 2.21 still have active stable branches.  2.19 is
> used by Debian jessie.  But beyond that, I don't know.

The distro maintainers should be contacted for such a list:
https://sourceware.org/glibc/wiki/MAINTAINERS#Distribution_Maintainers
Comment 4 cvs-commit@gcc.gnu.org 2016-03-03 07:20:38 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, release/2.22/master has been updated
       via  425c48c217ef93c2c4f81f9f3bb2fdba096877a2 (commit)
      from  21ab483c6ab94dee43c5db7278a0373be09f122c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=425c48c217ef93c2c4f81f9f3bb2fdba096877a2

commit 425c48c217ef93c2c4f81f9f3bb2fdba096877a2
Author: Stefan Liebler <stli@linux.vnet.ibm.com>
Date:   Thu Mar 3 08:17:09 2016 +0100

    S390: Do not use direct socket syscalls if build on kernels >= 4.3. [BZ #19682]
    
    Beginning with Linux 4.3, the kernel headers contain direct
    system call numbers __NR_socket etc. on s390x. On older kernels,
    the socket-multiplexer syscall __NR_socketcall was used.
    
    To enable these new syscalls, the patch
    "S390: Call direct system calls for socket operations."
    (https://sourceware.org/git/?p=glibc.git;a=commit;h=016495b818cb61df7d0d10e6db54074271b3e3a5)
    was applied upstream.
    
    If glibc 2.23 is configured with --enable-kernel=4.3 and newer,
    the direct socket syscalls are used.
    For older kernels, the socket-multiplexer syscall is used instead.
    
    In glibc 2.22 and earlier, this patch is not applied.
    If you build glibc on a kernel < 4.3, the socket-multiplexer
    syscall is used. But if you build glibc on kernel >= 4.3, the
    direct socket-syscalls are used. If you install this glibc on a
    kernel < 4.3, all socket operations will fail.
    See "Bug 19682 - s390x: Incorrect syscall definitions cause
    breakage with Linux 4.3 headers"
    (https://sourceware.org/bugzilla/show_bug.cgi?id=19682)
    The configure switch --enable-kernel does not influence this
    behaviour on older glibc-releases.
    
    The solution is to remove the direct socket-syscalls in
    sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
    (this patch) on older glibc-releases as it was done by the
    upstream patch, too. These entries were never used on s390x,
    but the c-files in sysdeps/unix/sysv/linux/.
    After this removal, the behaviour of the socket functions are
    not changed compared to the original glibc release version
    and the socket-multiplexer-syscall is always used.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                          |    6 ++++++
 NEWS                                               |    3 ++-
 sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list |   19 -------------------
 3 files changed, 8 insertions(+), 20 deletions(-)
Comment 5 cvs-commit@gcc.gnu.org 2016-03-03 07:23:54 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, release/2.21/master has been updated
       via  1885fe873e0e090fe1e9a1a456c559b909553309 (commit)
      from  16d0a0ce7613552301786bf05d7eba8784b5732c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1885fe873e0e090fe1e9a1a456c559b909553309

commit 1885fe873e0e090fe1e9a1a456c559b909553309
Author: Stefan Liebler <stli@linux.vnet.ibm.com>
Date:   Thu Mar 3 08:22:43 2016 +0100

    S390: Do not use direct socket syscalls if build on kernels >= 4.3. [BZ #19682]
    
    Beginning with Linux 4.3, the kernel headers contain direct
    system call numbers __NR_socket etc. on s390x. On older kernels,
    the socket-multiplexer syscall __NR_socketcall was used.
    
    To enable these new syscalls, the patch
    "S390: Call direct system calls for socket operations."
    (https://sourceware.org/git/?p=glibc.git;a=commit;h=016495b818cb61df7d0d10e6db54074271b3e3a5)
    was applied upstream.
    
    If glibc 2.23 is configured with --enable-kernel=4.3 and newer,
    the direct socket syscalls are used.
    For older kernels, the socket-multiplexer syscall is used instead.
    
    In glibc 2.22 and earlier, this patch is not applied.
    If you build glibc on a kernel < 4.3, the socket-multiplexer
    syscall is used. But if you build glibc on kernel >= 4.3, the
    direct socket-syscalls are used. If you install this glibc on a
    kernel < 4.3, all socket operations will fail.
    See "Bug 19682 - s390x: Incorrect syscall definitions cause
    breakage with Linux 4.3 headers"
    (https://sourceware.org/bugzilla/show_bug.cgi?id=19682)
    The configure switch --enable-kernel does not influence this
    behaviour on older glibc-releases.
    
    The solution is to remove the direct socket-syscalls in
    sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
    (this patch) on older glibc-releases as it was done by the
    upstream patch, too. These entries were never used on s390x,
    but the c-files in sysdeps/unix/sysv/linux/.
    After this removal, the behaviour of the socket functions are
    not changed compared to the original glibc release version
    and the socket-multiplexer-syscall is always used.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                          |    6 ++++++
 NEWS                                               |    3 ++-
 sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list |   19 -------------------
 3 files changed, 8 insertions(+), 20 deletions(-)
Comment 6 cvs-commit@gcc.gnu.org 2016-03-03 07:26:01 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, release/2.20/master has been updated
       via  adba20cf74bc6ea3910afe57d40ed755c92c2ddb (commit)
      from  d5a4840c6b4025302f485b9271e4c72d315221f5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=adba20cf74bc6ea3910afe57d40ed755c92c2ddb

commit adba20cf74bc6ea3910afe57d40ed755c92c2ddb
Author: Stefan Liebler <stli@linux.vnet.ibm.com>
Date:   Thu Mar 3 08:24:18 2016 +0100

    S390: Do not use direct socket syscalls if build on kernels >= 4.3. [BZ #19682]
    
    Beginning with Linux 4.3, the kernel headers contain direct
    system call numbers __NR_socket etc. on s390x. On older kernels,
    the socket-multiplexer syscall __NR_socketcall was used.
    
    To enable these new syscalls, the patch
    "S390: Call direct system calls for socket operations."
    (https://sourceware.org/git/?p=glibc.git;a=commit;h=016495b818cb61df7d0d10e6db54074271b3e3a5)
    was applied upstream.
    
    If glibc 2.23 is configured with --enable-kernel=4.3 and newer,
    the direct socket syscalls are used.
    For older kernels, the socket-multiplexer syscall is used instead.
    
    In glibc 2.22 and earlier, this patch is not applied.
    If you build glibc on a kernel < 4.3, the socket-multiplexer
    syscall is used. But if you build glibc on kernel >= 4.3, the
    direct socket-syscalls are used. If you install this glibc on a
    kernel < 4.3, all socket operations will fail.
    See "Bug 19682 - s390x: Incorrect syscall definitions cause
    breakage with Linux 4.3 headers"
    (https://sourceware.org/bugzilla/show_bug.cgi?id=19682)
    The configure switch --enable-kernel does not influence this
    behaviour on older glibc-releases.
    
    The solution is to remove the direct socket-syscalls in
    sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
    (this patch) on older glibc-releases as it was done by the
    upstream patch, too. These entries were never used on s390x,
    but the c-files in sysdeps/unix/sysv/linux/.
    After this removal, the behaviour of the socket functions are
    not changed compared to the original glibc release version
    and the socket-multiplexer-syscall is always used.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                          |    6 ++++++
 NEWS                                               |    2 +-
 sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list |   19 -------------------
 3 files changed, 7 insertions(+), 20 deletions(-)
Comment 7 Stefan Liebler 2016-03-03 07:44:24 UTC
After talking to the distribution maintainers, the decision
is to backport it to glibc 2.22, 2.21, 2.20 as alredy done.
See comment 4, 5, 6 above.
Comment 8 cvs-commit@gcc.gnu.org 2016-03-07 18:04:48 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, gentoo/2.22 has been updated
       via  3f749c2e7b8226eb8c6f16fb180987dc7efe35ba (commit)
       via  1fd66a522e9262d7ff36b015090f3989f93ba468 (commit)
       via  78b80a22769f07fcd83763d5b8b3625fe4920574 (commit)
       via  e012eafca47020da292f828fe128f3aca50026e1 (commit)
      from  258e9043d8f1a2dafac3754c651b46da1ccb7dba (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=3f749c2e7b8226eb8c6f16fb180987dc7efe35ba

commit 3f749c2e7b8226eb8c6f16fb180987dc7efe35ba
Author: Hongjiu Zhang <noctuorare@gmail.com>
Date:   Sun Mar 6 20:18:21 2016 -0500

    sln: use stat64
    
    When using sln on some filesystems which return 64-bit inodes,
    the stat call might fail during install like so:
    	.../elf/sln .../elf/symlink.list
    	/lib32/libc.so.6: invalid destination: Value too large for defined data type
    	/lib32/ld-linux.so.2: invalid destination: Value too large for defined data type
    	Makefile:104: recipe for target 'install-symbolic-link' failed
    
    Switch to using stat64 all the time to avoid this.
    
    URL: https://bugs.gentoo.org/576396
    (cherry picked from commit f5e753c8c3a18a1e3c715dd11bf4dc341b5c481f)
    (cherry picked from commit d6778fc4b0039b2116f88218212618ca357fee2f)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1fd66a522e9262d7ff36b015090f3989f93ba468

commit 1fd66a522e9262d7ff36b015090f3989f93ba468
Author: Stefan Liebler <stli@linux.vnet.ibm.com>
Date:   Thu Mar 3 08:17:09 2016 +0100

    S390: Do not use direct socket syscalls if build on kernels >= 4.3. [BZ #19682]
    
    Beginning with Linux 4.3, the kernel headers contain direct
    system call numbers __NR_socket etc. on s390x. On older kernels,
    the socket-multiplexer syscall __NR_socketcall was used.
    
    To enable these new syscalls, the patch
    "S390: Call direct system calls for socket operations."
    (https://sourceware.org/git/?p=glibc.git;a=commit;h=016495b818cb61df7d0d10e6db54074271b3e3a5)
    was applied upstream.
    
    If glibc 2.23 is configured with --enable-kernel=4.3 and newer,
    the direct socket syscalls are used.
    For older kernels, the socket-multiplexer syscall is used instead.
    
    In glibc 2.22 and earlier, this patch is not applied.
    If you build glibc on a kernel < 4.3, the socket-multiplexer
    syscall is used. But if you build glibc on kernel >= 4.3, the
    direct socket-syscalls are used. If you install this glibc on a
    kernel < 4.3, all socket operations will fail.
    See "Bug 19682 - s390x: Incorrect syscall definitions cause
    breakage with Linux 4.3 headers"
    (https://sourceware.org/bugzilla/show_bug.cgi?id=19682)
    The configure switch --enable-kernel does not influence this
    behaviour on older glibc-releases.
    
    The solution is to remove the direct socket-syscalls in
    sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
    (this patch) on older glibc-releases as it was done by the
    upstream patch, too. These entries were never used on s390x,
    but the c-files in sysdeps/unix/sysv/linux/.
    After this removal, the behaviour of the socket functions are
    not changed compared to the original glibc release version
    and the socket-multiplexer-syscall is always used.
    
    (cherry picked from commit 425c48c217ef93c2c4f81f9f3bb2fdba096877a2)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=78b80a22769f07fcd83763d5b8b3625fe4920574

commit 78b80a22769f07fcd83763d5b8b3625fe4920574
Author: Paul E. Murphy <murphyp@linux.vnet.ibm.com>
Date:   Wed Jan 20 10:33:19 2016 -0600

    powerpc: Fix macro usage of htm builtins
    
    Some extraneous semicolons were included in a
    recent patch which causes a build failure with
    newer compilers.
    
    (cherry picked from commit af8ea0f449af7d3847351a4a5bafcd435a22ac31)
    (cherry picked from commit a33d347c181cfa0d84c37e9961ebf030495ed248)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=e012eafca47020da292f828fe128f3aca50026e1

commit e012eafca47020da292f828fe128f3aca50026e1
Author: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
Date:   Mon Dec 28 12:24:43 2015 -0200

    powerpc: Enforce compiler barriers on hardware transactions
    
    Work around a GCC behavior with hardware transactional memory built-ins.
    GCC doesn't treat the PowerPC transactional built-ins as compiler
    barriers, moving instructions past the transaction boundaries and
    altering their atomicity.
    
    (cherry picked from commit 42bf1c897170ff951c7fd0ee9da25f97ff787396)
    
    Conflicts:
    	sysdeps/unix/sysv/linux/powerpc/elision-trylock.c
    
    (cherry picked from commit 3803874b4a368eb8245fbf091651b6c8edd90b23)

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                          |    5 +++
 elf/sln.c                                          |    4 +-
 sysdeps/powerpc/nptl/elide.h                       |    8 ++--
 sysdeps/powerpc/sysdep.h                           |    2 +-
 sysdeps/unix/sysv/linux/powerpc/elision-lock.c     |    4 +-
 sysdeps/unix/sysv/linux/powerpc/elision-trylock.c  |    6 ++--
 sysdeps/unix/sysv/linux/powerpc/elision-unlock.c   |    2 +-
 sysdeps/unix/sysv/linux/powerpc/htm.h              |   39 ++++++++++++++++++--
 sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list |   19 ----------
 9 files changed, 53 insertions(+), 36 deletions(-)