1. 08 8月, 2019 5 次提交
  2. 07 8月, 2019 6 次提交
    • R
      fix regression in select with no timeout · d0b547df
      Rich Felker 提交于
      commit 722a1ae3 inadvertently passed a
      copy of {s,us} to the syscall even if the timeout argument tv was
      null, thereby causing immediate timeout (polling) in place of
      unlimited timeout. only archs using SYS_select were affected.
      d0b547df
    • R
      fix failure of glob to match broken symlinks under some conditions · e408deef
      Rich Felker 提交于
      when the pattern ended with one or more literal path components, or
      when the GLOB_MARK flag was passed to request that glob flag directory
      results and the type obtained by readdir was unknown or inconclusive
      (symlink), the stat function was called to evaluate existence and/or
      determine type. however, stat fails with ENOENT for broken symlinks,
      and this caused the match to be omitted from the results.
      
      instead, use stat only for the unknown/inconclusive cases with
      GLOB_MARK, and otherwise, or if stat fails, use lstat existence still
      needs to be determined. this minimizes the number of costly syscalls,
      performing both only in the case where GLOB_MARK is in use and there
      is a final literal path component which is a broken symlink.
      
      based on/simplified from patch by James Y Knight.
      e408deef
    • R
      remove riscv64 bits/user.h contents · d493206d
      Rich Felker 提交于
      the contents conflicted with asm/ptrace.h. glibc does not provide
      anything in user.h for riscv, so software cannot be depending on it.
      
      simplified from patch submitted by Baruch Siach.
      d493206d
    • B
      fix risc64 conflict with kernel headers · 8acc6885
      Baruch Siach 提交于
      Rename user registers struct definitions to avoid conflict with the
      asm/ptrace.h kernel header that defines the same structs. Use the
      __riscv_mc prefix as glibc does.
      8acc6885
    • P
      in arm cancellation point asm, don't unnecessarily preserve link register · e0e8ae75
      Patrick Oppenlander 提交于
      The only reason we needed to preserve the link register was because we
      were using a branch-link instruction to branch to __cp_cancel.
      Replacing this with a branch means we can avoid the save/restore as
      the link register is no longer modified.
      e0e8ae75
    • I
      glob: implement GLOB_TILDE and GLOB_TILDE_CHECK · 49eacf29
      Ismael Luceno 提交于
      49eacf29
  3. 06 8月, 2019 4 次提交
    • R
      use setitimer function rather than syscall to implement alarm · f522de81
      Rich Felker 提交于
      otherwise alarm will break on 32-bit archs when time_t is changed to
      64-bit. a second itimerval object is introduced for retrieving the old
      value, since the setitimer function has restrict-qualified arguments.
      f522de81
    • R
      fix build regression in i386 asm for atan2, atan2f · 6818c31c
      Rich Felker 提交于
      commit f3ed8bfe inadvertently removed
      labels that were still needed.
      6818c31c
    • R
      fix x87 stack imbalance in corner cases of i386 math asm · f3ed8bfe
      Rich Felker 提交于
      commit 31c5fb80 introduced underflow
      code paths for the i386 math asm, along with checks on the fpu status
      word to skip the underflow-generation instructions if the underflow
      flag was already raised. unfortunately, at least one such path, in
      log1p, returned with 2 items on the x87 stack rather than just 1 item
      for the return value. this is a violation of the ABI's calling
      convention, and could cause subsequent floating point code to produce
      NANs due to x87 stack overflow. if floating point results are used in
      flow control, this can lead to runaway wrong code execution.
      
      rather than reviewing each "underflow already raised" code path for
      correctness, remove them all. they're likely slower than just
      performing the underflow code unconditionally, and significantly more
      complex.
      
      all of this code should be ripped out and replaced by C source files
      with inline asm. doing so would preclude this kind of error by having
      the compiler perform all x87 stack register allocation and stack
      manipulation, and would produce comparable or better code. however
      such a change is a much larger project.
      f3ed8bfe
    • R
      fix regression in clock_gettime on 32-bit archs without vdso · 244778f7
      Rich Felker 提交于
      commit 72f50245 broke this by creating
      a code path where r is uninitialized.
      244778f7
  4. 04 8月, 2019 1 次提交
    • R
      update riscv64 syscall numbers to linux v5.1 · 6fcb440d
      Rich Felker 提交于
      commit f3f96f2d added these for the
      rest of the archs, but the patch it corresponded to missed riscv64
      since riscv64 was not yet upstream at the time. this caused commit
      dfc81828 to break riscv64 build, due
      to a wrong assumption that SYS_statx was unconditionally defined.
      6fcb440d
  5. 03 8月, 2019 1 次提交
    • R
      clock_gettime: add support for 32-bit vdso with 64-bit time_t · 0705fe93
      Rich Felker 提交于
      this fixes a major upcoming performance regression introduced by
      commit 72f50245, whereby 32-bit archs
      would lose vdso clock_gettime after switching to 64-bit time_t, unless
      the kernel supports time64 and provides a time64 version of the vdso
      function. this would incur not just one but two syscalls: first, the
      failed time64 syscall, then the fallback time32 one.
      
      overflow of the 32-bit result is detected and triggers a revert to
      syscalls. normally, on a system that's not Y2038-ready, this would
      still overflow, but if the process has been migrated to a
      time64-capable kernel or if the kernel has been hot-patched to add
      time64 syscalls, it may conceivably work.
      0705fe93
  6. 02 8月, 2019 5 次提交
    • R
      move IPC_STAT definition to a new bits/ipcstat.h file · 006a75a9
      Rich Felker 提交于
      otherwise, 32-bit archs that could otherwise share the generic
      bits/ipc.h would need to duplicate the struct ipc_perm definition,
      obscuring the fact that it's the same. sysvipc is not widely used and
      these headers are not commonly included, so there is no performance
      gain to be had by limiting the number of indirectly included files
      here.
      
      files with the existing time32 definition of IPC_STAT are added to all
      current 32-bit archs now, so that when it's changed the change will
      show up as a change rather than addition of a new file where it's less
      obvious that the value is changing vs the generic one that was used
      before.
      006a75a9
    • R
      fix missing declarations for pthread_join extensions in source file · 3541925f
      Rich Felker 提交于
      per policy, define the feature test macro to get declarations for the
      pthread_tryjoin_np and pthread_timedjoin_np functions. in the past
      this has been only for checking; with 32-bit archs getting 64-bit
      time_t it will also be necessary for symbols to get redirected
      correctly.
      3541925f
    • R
      allow archs to define IPC_STAT, propagate time64 bit to other macros · 3c02bacf
      Rich Felker 提交于
      to make use of {sem,shm,msg}ctl IPC_STAT functionality to provide
      64-bit time_t on 32-bit archs, IPC_STAT and related macros must be
      defined with bit 8 (0x100) set. allow archs to define IPC_STAT in
      bits/ipc.h, and define the other macros in terms of it so that they
      all get the same value of the time64 bit.
      3c02bacf
    • R
      clock_gettime: add time64 syscall support, decouple 32-bit time_t · 72f50245
      Rich Felker 提交于
      the time64 syscall has to be used if time_t is 64-bit, since there's
      no way of knowing before making a syscall whether the result will fit
      in 32 bits, and the 32-bit syscalls do not report overflow as an
      error.
      
      on 64-bit archs, there is no change to the code after preprocessing.
      on current 32-bit archs, the result is now read from the kernel
      through long[2] array, then copied into the timespec, to remove the
      assumption that time_t is the same as long.
      
      vdso clock_gettime is still used in place of a syscall if available.
      32-bit archs with 64-bit time_t must use the time64 version of the
      vdso function; if it's not available, performance will significantly
      suffer. support for both vdso functions could be added, but would
      break the ability to move a long-lived process from a pre-time64
      kernel to one that can outlast Y2038 with checkpoint/resume, at least
      without added hacks to identify that the 32-bit function is no longer
      usable and stop using it (e.g. by seeing negative tv_sec). this
      possibility may be explored in future work on the function.
      72f50245
    • R
      clock_adjtime: add time64 support, decouple 32-bit time_t, fix x32 · 2b4fd6f7
      Rich Felker 提交于
      the 64-bit/time64 version of the syscall is not API-compatible with
      the userspace timex structure definition; fields specified as long
      have type long long. so when using the time64 syscall, we have to
      convert the entire structure. this was always the case for x32 as
      well, but went unnoticed, meaning that clock_adjtime just passed junk
      to the kernel on x32. it should be fixed now.
      
      for the fallback case, we avoid encoding any assumptions about the new
      location of the time member or naming of the legacy slots by accessing
      them through a union of the kernel type and the new userspace type.
      the only assumption is that the non-time members live at the same
      offsets as in the (non-time64, long-based) kernel timex struct. this
      property saves us from having to convert the whole thing, and avoids a
      lot of additional work in compat shims.
      
      the new code is statically unreachable for now except on x32, where it
      fixes major brokenness. it is permanently unreachable on 64-bit.
      2b4fd6f7
  7. 01 8月, 2019 5 次提交
    • R
      ioctl: add fallback for new time64 SIOCGSTAMP[NS] · 2e554617
      Rich Felker 提交于
      without this, the SIOCGSTAMP and SIOCGSTAMPNS ioctl commands, for
      obtaining timestamps, would stop working on pre-5.1 kernels after
      time_t is switched to 64-bit and their values are changed to the new
      time64 versions.
      
      new code is written such that it's statically unreachable on 64-bit
      archs, and on existing 32-bit archs until the macro values are changed
      to activate 64-bit time_t.
      2e554617
    • R
      get/setsockopt: add fallback for new time64 SO_RCVTIMEO/SO_SNDTIMEO · 51fd67fc
      Rich Felker 提交于
      without this, the SO_RCVTIMEO and SO_SNDTIMEO socket options would
      stop working on pre-5.1 kernels after time_t is switched to 64-bit and
      their values are changed to the new time64 versions.
      
      new code is written such that it's statically unreachable on 64-bit
      archs, and on existing 32-bit archs until the macro values are changed
      to activate 64-bit time_t.
      51fd67fc
    • R
      make __socketcall analogous to __syscall, error-returning · 59324c8b
      Rich Felker 提交于
      the __socketcall and __socketcall_cp macros are remnants from a really
      old version of the syscall-mechanism infrastructure, and don't follow
      the pattern that the "__" version of the macro returns the raw negated
      error number rather than setting errno and returning -1.
      
      for time64 purposes, some socket syscalls will need to operate on the
      error value rather than returning immediately, so fix this up so they
      can use it.
      59324c8b
    • R
      sysvipc: overhaul {sem,shm,msg}ctl for time64 · 8b249704
      Rich Felker 提交于
      being "ctl" functions that take command numbers, these will be handled
      like ioctl/sockopt/etc., using new command numbers for the time64
      variants with an "IPC_TIME64" bit added to their values. to obtain
      such a reserved bit, we reuse the IPC_64 bit, 0x100, which served only
      as part of the libc-to-kernel interface, not as a public interface of
      the libc functions.
      
      using new command numbers avoids the need for compat shims (in ABIs
      doing time64 through symbol redirection and compat shims) and, by
      virtue of having a fixed time64 bit for all commands, we can ensure
      that libc can perform the appropriate translations, even if the
      application is using new commands from a newer version of the libc
      headers than the libc available at runtime.
      
      for the vast majority of 32-bit archs, the kernel {sem,shm,msq}id64_ds
      definitions left padding space intended for expanding their time_t
      fields to 64 bits in-place, and it would have been really nice to be
      able to do time64 support that way. however the padding was almost
      always in little-endian order (except on powerpc, and for msqid_ds
      only on mips, where it matched the arch's byte order), and more
      importantly, the alignment was overlooked. in semid_ds and msqid_ds,
      the time_t members were not suitably aligned to be expanded to 64-bit,
      due to the ipc_perm header consisting of 9 32-bit words -- except on
      powerpc where ipc_perm contains an extra padding word. in shmid_ds,
      the time_t members were suitably aligned, except that mips
      (accidentally?) omitted the padding for them alltogether.
      
      as a result, we're stuck with adding new time_t fields on the end of
      the structures, and assembling the 32-bit lo/hi parts (or 16-bit hi
      parts, for mips shmid_ds, which lacked sufficient reserved space for
      full 32-bit hi parts) to fill them in.
      
      all of the functional changes here are conditional on the IPC_TIME64
      macro having a nonzero definition, which will only happen when
      IPC_STAT is redefined for 32-bit archs, and on time_t being larger
      than long, so for now the new code is all dead code.
      8b249704
    • R
      fix semctl with SEM_STAT_ANY · fe5e72ae
      Rich Felker 提交于
      due to the variadic signature, semctl needs to be made aware of any
      new commands that take arguments. this was overlooked when commit
      af55070e added SEM_STAT_ANY.
      fe5e72ae
  8. 31 7月, 2019 4 次提交
    • R
      remove gratuitously-different arch-specific bits/ipc.h files · 319b2d02
      Rich Felker 提交于
      these differ from generic only in using endian-matched padding with a
      short __ipc_perm_seq field in place of the int field in generic. this
      is not a documented public interface anyway, and the original intent
      was to use int here. some ports just inadvertently slipped in the
      kernel short+padding form.
      319b2d02
    • R
      remove arch-specific bits/ipc.h that are identical to generic · 2a0bb9e0
      Rich Felker 提交于
      previously these differed from generic because they needed their own
      definitions of IPC_64. now that it's no longer in public header,
      they're identical.
      2a0bb9e0
    • R
      move IPC_64 from public bits/ipc.h to syscall_arch.h · f56d57f8
      Rich Felker 提交于
      the definition of the IPC_64 macro controls the interface between libc
      and the kernel through syscalls; it's not a public API. the meaning is
      rather obscure. long ago, Linux's sysvipc *id_ds structures used
      16-bit uids/gids and wrong types for a few other fields. this was in
      the libc5 era, before glibc. the IPC_64 flag (64 is a misnomer; it's
      more like 32) tells the kernel to use the modern[-ish] versions of the
      structures.
      
      the definition of IPC_64 has nothing to do with whether the arch is
      32- or 64-bit. rather, due to either historical accident or
      intentional obnoxiousness, the kernel only accepts and masks off the
      0x100 IPC_64 flag conditional on CONFIG_ARCH_WANT_IPC_PARSE_VERSION,
      i.e. for archs that want to provide, or that accidentally provided,
      both. for archs which don't define this option, no masking is
      performed and commands with the 0x100 bit set will fail as invalid. so
      ultimately, the definition is just a matter of matching an arbitrary
      switch defined per-arch in the kernel.
      f56d57f8
    • R
      select: overhaul for time64 · 722a1ae3
      Rich Felker 提交于
      major changes are made alongside adding time64 syscall support to
      account for issues found during research. select historically accepts
      non-normalized (tv_usec not restricted to less than 1000000) timeouts,
      and the kernel normalizes them, but the normalization code is buggy
      and subject to integer overflows. since normalization is needed anyway
      when using SYS_pselect6 or SYS_pselect6_time64 as the backend, simply
      do it up-front to eliminate both code path complexity and the
      possibility of kernel bugs.
      
      as a side effect, select no longer updates the caller's timeout
      timeval with the remaining time. previously, archs that used
      SYS_select updated it and archs that used SYS_pselect6 didn't. this
      change may turn out to be controversial and may need revisiting, but
      in any case the old behavior was not strictly conforming.
      
      POSIX allows modification of the timeout "upon successful completion",
      but the Linux syscall modifies it upon unsuccessful completion (EINTR)
      as well (and presumably each time the syscall stops and restarts
      before it's known whether completion will be successful). it's
      possible that this language does not reflect the actual intent of the
      standard, since other historical implementations probably behaved like
      Linux, but that should be clarified if there's a desire to bring the
      old behavior back. regardless, programs that are depending on this are
      not correct and are already broken on some archs we support.
      722a1ae3
  9. 30 7月, 2019 9 次提交