[v3,0/3] Fixes for CVE-2021-3998 and CVE-2021-3999

Message ID 20220120093252.1911498-1-siddhesh@sourceware.org
Headers
Series Fixes for CVE-2021-3998 and CVE-2021-3999 |

Message

Siddhesh Poyarekar Jan. 20, 2022, 9:32 a.m. UTC
  Add functions to make directory trees with paths longer than PATH_MAX
and use them to test fixes for CVE-2021-3998 and CVE-2021-3999.

Tested on x86_64 and i686.

Changes from v2:
- Adjusted test infrastructure to bail out if the filesystem does not support
  creating directory trees greater than PATH_MAX.

Changes from v1:
- Try reducing directory name size to meet lower limits of some fuse
  filesystems
- Fixed review comments
- Credited Qualys in NEWS
- Use x* functions wherever possible
- Drop size check in linux getcwd implementation and rely only on the
  posix one to flag the error
- Fix formatting issues I had missed before.

Siddhesh Poyarekar (3):
  support: Add helpers to create paths longer than PATH_MAX
  realpath: Set errno to ENAMETOOLONG for result larger than PATH_MAX
    [BZ #28770]
  getcwd: Set errno to ERANGE for size == 1 (CVE-2021-3999)

 NEWS                                          |  10 +
 stdlib/Makefile                               |   1 +
 stdlib/canonicalize.c                         |  12 +-
 stdlib/tst-realpath-toolong.c                 |  49 ++++
 support/temp_file.c                           | 159 +++++++++++-
 support/temp_file.h                           |   9 +
 sysdeps/posix/getcwd.c                        |   7 +
 sysdeps/unix/sysv/linux/Makefile              |   7 +-
 .../unix/sysv/linux/tst-getcwd-smallbuff.c    | 245 ++++++++++++++++++
 9 files changed, 487 insertions(+), 12 deletions(-)
 create mode 100644 stdlib/tst-realpath-toolong.c
 create mode 100644 sysdeps/unix/sysv/linux/tst-getcwd-smallbuff.c