glibc:hjl/pr19363/clobber

Last commit made on 2015-12-15
Get this branch:
git clone -b hjl/pr19363/clobber https://git.launchpad.net/glibc

Branch merges

Branch information

Name:
hjl/pr19363/clobber
Repository:
lp:glibc

Recent commits

bed04d2... by "H.J. Lu" <email address hidden>

Use REGISTERS_CLOBBERED_BY_SYSCALL

d4f465d... by "H.J. Lu" <email address hidden>

Add REGISTERS_CLOBBERED_BY_SYSCALL

8a4f1e5... by "H.J. Lu" <email address hidden>

Use INTERNAL_SYSCALL_TIMES for Linux times

The Linux times function, which returns clock_t, is implemented with
INTERNAL_SYSCALL. Since INTERNAL_SYSCALL returns 32-bit integer and
and clock_t is 64-bit on x32, this is a mismatch on x32. times is the
only such function. This patch replaces INTERNAL_SYSCALL in Linux
times.c with INTERNAL_SYSCALL_TIMES which is default to INTERNAL_SYSCALL
and provides x32 times.c with proper INTERNAL_SYSCALL_TIMES.

There is no code change on times for i686 nor x86-64. For x32, before
this patch, there are

0000000 <__times>:
   0: b8 64 00 00 40 mov $0x40000064,%eax
   5: 0f 05 syscall
   7: 48 63 d0 movslq %eax,%rdx
                                ^^^^^^^^^^ Incorrect signed extension
   a: 48 83 fa f2 cmp $0xfffffffffffffff2,%rdx
   e: 75 07 jne 17 <__times+0x17>
  10: 3d 00 f0 ff ff cmp $0xfffff000,%eax
  15: 77 11 ja 28 <__times+0x28>
  17: 48 83 fa ff cmp $0xffffffffffffffff,%rdx
  1b: b8 00 00 00 00 mov $0x0,%eax
  20: 48 0f 45 c2 cmovne %rdx,%rax
  24: c3 retq

After this patch, there are

00000000 <__times>:
   0: b8 64 00 00 40 mov $0x40000064,%eax
   5: 0f 05 syscall
   7: 48 83 f8 f2 cmp $0xfffffffffffffff2,%rax
   b: 75 07 jne 14 <__times+0x14>
   d: 3d 00 f0 ff ff cmp $0xfffff000,%eax
  12: 77 14 ja 28 <__times+0x28>
  14: 48 83 f8 ff cmp $0xffffffffffffffff,%rax
  18: ba 00 00 00 00 mov $0x0,%edx
  1d: 48 0f 44 c2 cmove %rdx,%rax
  21: c3 retq

The incorrect signed extension is gone.

 [BZ #19363]
 * sysdeps/unix/sysv/linux/times.c (INTERNAL_SYSCALL_TIMES): New.
 (__times): Replace INTERNAL_SYSCALL with INTERNAL_SYSCALL_TIMES.
 * sysdeps/unix/sysv/linux/x86_64/x32/times.c: New file.

xxx

eed3e1e... by Joseph Myers <email address hidden>

Make obsolete syscall wrappers into compat symbols (bug 18472).

Various Linux kernel syscalls have become obsolete over time.
Specifically, the following are obsolete in all kernel versions
supported by glibc, are not present for architectures more recently
added to the kernel, and as such, the wrapper functions for them
should be compat symbols, not in static libc and not available for new
links with shared libc.

* bdflush: in Linux 2.6, does nothing if present.

* create_module get_kernel_syms query_module: Linux 2.4 module
  interface, syscalls not present in Linux 2.6.

* uselib: part of the mechanism for loading a.out shared libraries,
  irrelevant with ELF.

This patch adds support for syscalls.list to list syscall aliases of
the form NAME@VERSION:OBSOLETED, with SHLIB_COMPAT conditionals being
generated for such aliases. Those five syscalls are then made into
compat symbols (obsoleted in glibc 2.23, so future ports won't have
these symbols at all), with the header <sys/kdaemon.h> declaring
bdflush being removed. When we move to 3.2 as minimum kernel version,
the same can be done for nfsservctl (removed in Linux 3.1) as well.

Tested for x86_64 and x86 (testsuite, as well as checking that the
symbols in question indeed become compat symbols, that they are indeed
omitted from static libc, and that the generated SHLIB_COMPAT
conditionals look right).

 [BZ #18472]
 * sysdeps/unix/Makefile ($(objpfx)stub-syscalls.c): Handle entries
 for the form NAME@VERSION:OBSOLETED and generate SHLIB_COMPAT
 conditionals for them.
 * sysdeps/unix/make-syscalls.sh (emit_weak_aliases): Likewise.
 * sysdeps/unix/sysv/linux/sys/kdaemon.h: Remove file.
 * sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Remove
 sys/kdaemon.h.
 * sysdeps/unix/sysv/linux/syscalls.list (bdflush): Make into
 compat-only syscall, obsoleted in glibc 2.23.
 (create_module): Likewise.
 (get_kernel_syms): Likewise.
 (query_module): Likewise.
 (uselib): Likewise.
 * manual/sysinfo.texi (System Parameters): Do not mention bdflush.

5db0877... by Aurelien Jarno <email address hidden>

Cleanup ARM ioperm implementation

Since GLIBC requires a minimum 2.6.32 kernel, the patch cleanups
the ARM ioperm by removing pre-2.4.23 kernel support.

976ef87... by Steve Ellcey <email address hidden>

Fix indentation.

 * sysdeps/ieee754/flt-32/k_rem_pio2f.c (__kernel_rem_pio2f):
 Fix indentation.

996b03d... by Steve Ellcey <email address hidden>

    Fix indentation.

 * stdio-common/vfscanf.c (_IO_vfscanf_internal): Fix indentation.

895f3a1... by Steve Ellcey <email address hidden>

    Fix indentation.

 * stdlib/strtol_l.c (__strtol_l): Fix indentation.

85bafe6... by Joseph Myers <email address hidden>

Automate LC_CTYPE generation for tr_TR, update to Unicode 8.0.0 (bug 18491).

This patch makes the automation of Unicode LC_CTYPE generation also
support generating the modified LC_CTYPE used for Turkish (where case
conversions of 'i' and 'I' differ from ASCII conventions), so allowing
that to be more readily kept in sync for future Unicode updates. The
patch includes the locale update generated by the scripts.

Tested for x86_64.

 [BZ #18491]
 * unicode-gen/unicode_utils.py (to_upper_turkish): New function.
 (to_lower_turkish): Likewise.
 * unicode-gen/gen_unicode_ctype.py (output_tables): Support
 producing output with Turkish case conversions.
 (--turkish): New command-line option.
 * unicode-gen/Makefile (GENERATED): Add tr_TR.
 (tr_TR): New rule.
 * locales/tr_TR: Regenerate LC_CTYPE.

7735691... by Aurelien Jarno <email address hidden>

grantpt: trust the kernel about pty group and permission mode

According to POSIX the grantpt() function does the following:

  The grantpt() function shall change the mode and ownership of the
  slave pseudo-terminal device associated with its master
  pseudo-terminal counterpart. The fildes argument is a file descriptor
  that refers to a master pseudo-terminal device. The user ID of the
  slave shall be set to the real UID of the calling process and the
  group ID shall be set to an unspecified group ID. The permission
  mode of the slave pseudo-terminal shall be set to readable and
  writable by the owner, and writable by the group.

Historically the GNU libc has been responsible to setup the permission
mode to 0620 and the group to 'tty' usually number 5, using the pt_chown
helper, badly known for its security issues. With the creation of the
devpts filesytem in the Linux kernel, this responsibility has been moved
to the Linux kernel. The system is responsible to mount the devpts
filesystem in /dev/pts with the options gid=5 and mode=0620. In that
case the GNU libc has nothing to do and pt_chown is not need anymore. So
far so good.

The problem is that by default the devpts filesystem is shared between
all mounts, and that contrary to other filesystem, the mount options are
honored at the second mount, including for the default mount options.
Given it corresponds to mode=0600 without gid parameter (that is the
filesystem GID of the creating process), it's common to see systems
where the devpts filesystem is mounted using these options. It is enough
to run a "mount -t devpts devpts /mychroot/dev/pts" to come into this
situation, and it's unfortunately wrongly used in a lot of scripts
dealing with chroots, or for creating virtual machines images.

When this happens the GNU libc tries to fix the group and permission
mode of the pty nodes, and given it fails to do so for non-root users,
grantpt() almost always fail. It means users are not able to open new
terminals.

This patch changes grantpt() to not enforce this anymore, while still
enforcing minimum security measures to the permission mode. Therefore
the responsibility to follow POSIX is now shared at the system level,
i.e. kernel + system scripts + GNU libc. It stops trying to change the
group, and makes the pty node readable and writable by the owner, and
writable by the group only when originally writable and when the group
is the tty one.

As a result, on a system wrongly mounted with gid=0 and mode=0600, the
pty nodes won't be accessible by the tty group, but the grantpt()
function will succeed and users will have a working system. The system
is not fully POSIX compliant (which might be an admin choice to default
to "mesg n" mode), but the GNU libc is not to blame here, as without the
pt_chown helper it can't do anything.

With this patch there should not be any reason left to build the GNU
libc with the --enable-pt_chown configure option on a GNU/Linux system.