1. 25 3月, 2020 6 次提交
  2. 22 3月, 2020 2 次提交
    • S
      fix parsing offsets after long timezone names · 33338ebc
      Samuel Holland 提交于
      TZ containg a timezone name with >TZNAME_MAX characters currently
      breaks musl's timezone parsing. getname() stops after TZNAME_MAX
      characters. getoff() will consume no characters (because the next
      character is not a digit) and incorrectly return 0. Then, because
      there are remaining alphabetic characters, __daylight == 1, and
      dst_off == -3600.
      
      getname() must consume the entire timezone name, even if it will not
      fit in d/__tzname, so when it returns, s points to the offset digits.
      33338ebc
    • S
      avoid out-of-bounds read for invalid quoted timezone · 8e452aba
      Samuel Holland 提交于
      Parsing the timezone name must stop when reaching the null terminator.
      In that case, there is no '>' to skip.
      8e452aba
  3. 21 3月, 2020 1 次提交
    • A
      remove redundant condition in memccpy · 526df238
      Alexander Monakov 提交于
      Commit d9bdfd16 ("fix memccpy to not access buffer past given size")
      correctly added a check for 'n' nonzero, but made the pre-existing test
      '*s==c' redundant: n!=0 implies *s==c. Remove the unnecessary check.
      
      Reported by Alexey Izbyshev.
      526df238
  4. 15 3月, 2020 2 次提交
    • T
      improve strerror speed · 8343334d
      Timo Teräs 提交于
      change the current O(n) lookup to O(1) based on the machinery
      described in "How To Write Shared Libraries" (Appendix B).
      8343334d
    • R
      fix corrupt sysvipc timestamps on 32-bit archs with old kernels · 2b2c8aaf
      Rich Felker 提交于
      kernel commit 4693916846269d633a3664586650dbfac2c5562f (first included
      in release v4.14) silently fixed a bug whereby the reserved space
      (which was later used for high bits of time) in IPC_STAT structures
      was left untouched rather than zeroed. this means that a caller that
      wants to read the high bits needs to pre-zero the memory.
      
      since it's not clear that these operations are permitted to modify the
      destination buffer on failure, use a temp buffer and copy back to the
      caller's buffer on success.
      2b2c8aaf
  5. 23 2月, 2020 1 次提交
    • R
      use __socketcall to simplify socket() · 7063c459
      Rich Felker 提交于
      commit 59324c8b added __socketcall
      analogous to __syscall, returning the negated error rather than
      setting errno. use it to simplify the fallback path of socket(),
      avoiding extern calls and access to errno.
      
      Author: Rich Felker <dalias@aerifal.cx>
      Date:   Tue Jul 30 17:51:16 2019 -0400
      
          make __socketcall analogous to __syscall, error-returning
      7063c459
  6. 22 2月, 2020 3 次提交
    • R
      remove wrap_write helper from vdprintf · a01f1fe6
      Rich Felker 提交于
      this reverts commit 4ee039f3, which
      added the helper as a hack to make vdprintf usable before relocation,
      contingent on strong assumptions about the arch and tooling, back when
      the dynamic linker did not have a real staged model for
      self-relocation. since commit f3ddd173
      this has been unnecessary and the function was just wasting size and
      execution time.
      a01f1fe6
    • S
      math: fix sinh overflows in non-nearest rounding · d2055814
      Szabolcs Nagy 提交于
      The final rounding operation should be done with the correct sign
      otherwise huge results may incorrectly get rounded to or away from
      infinity in upward or downward rounding modes.
      
      This affected sinh and sinhf which set the sign on the result after
      a potentially overflowing mul. There may be other non-nearest rounding
      issues, but this was a known long standing issue with large ulp error
      (depending on how ulp is defined near infinity).
      
      The fix should have no effect on sinh and sinhf performance but may
      have a tiny effect on cosh and coshf.
      d2055814
    • S
      math: fix __rem_pio2 in non-nearest rounding modes · b3797d3b
      Szabolcs Nagy 提交于
      Handle when after reduction |y| > pi/4+tiny. This happens in directed
      rounding modes because the fast round to int code does not give the
      nearest integer. In such cases the reduction may not be symmetric
      between x and -x so e.g. cos(x)==cos(-x) may not hold (but polynomial
      evaluation is not symmetric either with directed rounding so fixing
      that would require more changes with bigger performance impact).
      
      The fix only adds two predictable branches in nearest rounding mode,
      simple ubenchmark does not show relevant performance regression in
      nearest rounding mode.
      
      The code could be improved: e.g reducing the medium size threshold
      such that two step reduction is enough instead of three, and the
      single precision case can avoid the issue by doing the round to int
      differently, but this fix was kept minimal.
      b3797d3b
  7. 13 2月, 2020 1 次提交
    • R
      fix remaining direct use of stat syscalls outside fstatat.c · c9ebff47
      Rich Felker 提交于
      because struct stat is no longer assumed to correspond to the
      structure used by the stat-family syscalls, it's not valid to make any
      of these syscalls directly using a buffer of type struct stat.
      
      commit 94938920 moved all logic around
      this change for stat-family functions into fstatat.c, making the
      others wrappers for it. but a few other direct uses of the syscall
      were overlooked. the ones in tmpnam/tempnam are harmless since the
      syscalls are just used to test for file existence. however, the uses
      in fchmodat and __map_file depend on getting accurate file properties,
      and these functions may actually have been broken one or more mips
      variants due to removal of conversion hacks from syscall_arch.h.
      
      as a low-risk fix, simply use struct kstat in place of struct stat in
      the affected places.
      c9ebff47
  8. 07 2月, 2020 5 次提交
  9. 05 2月, 2020 3 次提交
  10. 31 1月, 2020 1 次提交
    • R
      remove legacy clock_gettime and gettimeofday from public syscall.h · 5a105f19
      Rich Felker 提交于
      some nontrivial number of applications have historically performed
      direct syscalls for these operations rather than using the public
      functions. such usage is invalid now that time_t is 64-bit and these
      syscalls no longer match the types they are used with, and it was
      already harmful before (by suppressing use of vdso).
      
      since syscall() has no type safety, incorrect usage of these syscalls
      can't be caught at compile-time. so, without manually inspecting or
      running additional tools to check sources, the risk of such errors
      slipping through is high.
      
      this patch renames the syscalls on 32-bit archs to clock_gettime32 and
      gettimeofday_time32, so that applications using the original names
      will fail to build without being fixed.
      
      note that there are a number of other syscalls that may also be unsafe
      to use directly after the time64 switchover, but (1) these are the
      main two that seem to be in widespread use, and (2) most of the others
      continue to have valid usage with a null timeval/timespec argument, as
      the argument is an optional timeout or similar.
      5a105f19
  11. 28 1月, 2020 1 次提交
  12. 17 1月, 2020 1 次提交
    • A
      add thumb2 support to arm assembler memcpy · 91e662d1
      Andre McCurdy 提交于
      For Thumb2 compatibility, replace two instances of a single
      instruction "orr with a variable shift" with the two instruction
      equivalent. Neither of the replacements are in a performance critical
      loop.
      91e662d1
  13. 02 1月, 2020 1 次提交
  14. 01 1月, 2020 1 次提交
  15. 23 12月, 2019 2 次提交
  16. 22 12月, 2019 1 次提交
  17. 21 12月, 2019 1 次提交
  18. 20 12月, 2019 1 次提交
    • R
      add further ioctl time64 fallback conversions · 2412638b
      Rich Felker 提交于
      this commit covers all remaining ioctls I'm aware of that use
      time_t-derived types in their interfaces. it may still be incomplete,
      and has undergone only minimal testing for a few commands used in
      audio playback.
      
      the SNDRV_PCM_IOCTL_SYNC_PTR command is special-cased because, rather
      than the whole structure expanding, it has two substructures each
      padded to 64 bytes that expand within their own 64-byte reserved zone.
      as long as it's the only one of its type, it doesn't really make sense
      to make a general framework for it, but the existing table framework
      is still used for the substructures in the special-case. one of the
      substructures, snd_pcm_mmap_status, has a snd_pcm_uframes_t member
      which is not a timestamp but is expanded just like one, to match the
      64-bit-arch version of the structure. this is handled just like a
      timestamp at offset 8, and is the motivation for the conversions table
      holding offsets of individual values to be expanded rather than
      timespec/timeval type pairs.
      
      for some of the types, the size to which they expand is dependent on
      whether the arch's ABI aligns 8-byte types on 8-byte boundaries.
      new_req entries in the table need to reflect this size to get the
      right ioctl request number that will match what callers pass, but we
      don't have access to the actual structure type definitions here and
      duplicating them would be cumbersome. instead, the new_misaligned
      macro introduced here constructs an artificial object whose size is
      the result of expanding a misaligned timespec/timeval to 64-bit and
      imposing the arch's alignment on the result, which can be passed to
      the _IO{R,W,WR} macros.
      2412638b
  19. 19 12月, 2019 2 次提交
    • R
      improve ioctl time64 conversion fallback framework · 64d0e865
      Rich Felker 提交于
      record offsets of individual slots that expand from 32- to 64-bit,
      rather than timespec/timeval pairs. this flexibility will be needed
      for some ioctls. reduce size of types in table. adjust representation
      of offsets to include a count rather than needing -1 padding so that
      the table is less ugly and doesn't need large diffs if we increase max
      number of slots.
      64d0e865
    • R
      convert ioctl time64 fallbacks to table-driven framework · 221b1a1d
      Rich Felker 提交于
      with the current set of supported ioctls, this conversion is hardly an
      improvement, but it sets the stage for being able to do alsa, v4l2,
      ppp, and other ioctls with timespec/timeval-derived types. without
      this capability, a lot of functionality users depend on would stop
      working with the time64 switchover.
      221b1a1d
  20. 18 12月, 2019 2 次提交
    • R
      hook recvmmsg up to SO_TIMESTAMP[NS] fallback for pre-time64 kernels · 114178dc
      Rich Felker 提交于
      always try the time64 syscall first since we can use its success to
      conclude that no conversion is needed (any setsockopt for the
      timestamp options would have succeeded without need for fallbacks).
      otherwise, we have to remember the original controllen for each
      msghdr, requiring O(vlen) space, so vlen must be bounded. linux clamps
      it to IOV_MAX for sendmmsg only (not recvmmsg), but doing the same for
      recvmmsg is not unreasonable, especially since the limitation will
      only apply to old kernels.
      
      we could optimize to avoid trying SYS_recvmmsg_time64 first if all
      msghdrs have controllen zero, or support unlimited vlen by looping and
      emulating the timeout logic, but I'm not inclined to do complex and
      error-prone optimizations on a function that has so many underlying
      problems it should really never be used.
      114178dc
    • R
      implement SO_TIMESTAMP[NS] fallback for kernels without time64 versions · ae388bec
      Rich Felker 提交于
      the definitions of SO_TIMESTAMP* changed on 32-bit archs in commit
      38143339 to the new versions that
      provide 64-bit versions of timeval/timespec structure in control
      message payload. socket options, being state attached to the socket
      rather than function calls, are not trivial to implement as fallbacks
      on ENOSYS, and support for them was initially omitted on the
      assumption that the ioctl-based polling alternatives (SIOCGSTAMP*)
      could be used instead by applications if setsockopt fails.
      
      unfortunately, it turns out that SO_TIMESTAMP is sufficiently old and
      widely supported that a number of applications assume it's available
      and treat errors as fatal.
      
      this patch introduces emulation of SO_TIMESTAMP[NS] on pre-time64
      kernels by falling back to setting the "_OLD" (time32) versions of the
      options if the time64 ones are not recognized, and performing
      translation of the SCM_TIMESTAMP[NS] control messages in recvmsg.
      since recvmsg does not know whether its caller is legacy time32 code
      or time64, it performs translation for any SCM_TIMESTAMP[NS]_OLD
      control messages it sees, leaving the original time32 timestamp as-is
      (it can't be rewritten in-place anyway, and memmove would be mildly
      expensive) and appending the converted time64 control message at the
      end of the buffer. legacy time32 callers will see the converted one as
      a spurious control message of unknown type; time64 callers running on
      pre-time64 kernels will see the original one as a spurious control
      message of unknown type. a time64 caller running on a kernel with
      native time64 support will only see the time64 version of the control
      message.
      
      emulation of SO_TIMESTAMPING is not included at this time since (1)
      applications which use it seem to be prepared for the possibility that
      it's not present or working, and (2) it can also be used in sendmsg
      control messages, in a manner that looks complex to emulate
      completely, and costly even when running on a time64-supporting
      kernel.
      
      corresponding changes in recvmmsg are not made at this time; they will
      be done separately.
      ae388bec
  21. 08 12月, 2019 2 次提交