Summary: | Unexpected return value from realpath() for too long results (CVE-2021-3998) | ||
---|---|---|---|
Product: | glibc | Reporter: | Siddhesh Poyarekar <siddhesh> |
Component: | libc | Assignee: | Siddhesh Poyarekar <siddhesh> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | aurelien, drepper.fsp, fweimer, pgowda.cve, sam |
Priority: | P2 | Flags: | siddhesh:
security+
|
Version: | 2.35 | ||
Target Milestone: | 2.35 | ||
See Also: | https://bugzilla.redhat.com/show_bug.cgi?id=2024633 | ||
Host: | Target: | ||
Build: | Last reconfirmed: |
Description
Siddhesh Poyarekar
2022-01-12 17:45:23 UTC
Fixed on trunk: commit ee8d5e33adb284601c00c94687bc907e10aec9bb Author: Siddhesh Poyarekar <siddhesh@sourceware.org> Date: Thu Jan 13 11:28:36 2022 +0530 realpath: Set errno to ENAMETOOLONG for result larger than PATH_MAX [BZ #28770] realpath returns an allocated string when the result exceeds PATH_MAX, which is unexpected when its second argument is not NULL. This results in the second argument (resolved) being uninitialized and also results in a memory leak since the caller expects resolved to be the same as the returned value. Return NULL and set errno to ENAMETOOLONG if the result exceeds PATH_MAX. This fixes [BZ #28770], which is CVE-2021-3998. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> The master branch has been updated by Siddhesh Poyarekar <siddhesh@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=84d2d0fe20bdf94feed82b21b4d7d136db471f03 commit 84d2d0fe20bdf94feed82b21b4d7d136db471f03 Author: Siddhesh Poyarekar <siddhesh@sourceware.org> Date: Mon Jan 24 21:36:41 2022 +0530 realpath: Avoid overwriting preexisting error (CVE-2021-3998) Set errno and failure for paths that are too long only if no other error occurred earlier. Related: BZ #28770 Reviewed-by: Andreas Schwab <schwab@linux-m68k.org> Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> The release/2.34/master branch has been updated by Siddhesh Poyarekar <siddhesh@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d084965adc7baa8ea804427cccf973cea556d697 commit d084965adc7baa8ea804427cccf973cea556d697 Author: Siddhesh Poyarekar <siddhesh@sourceware.org> Date: Mon Jan 24 21:36:41 2022 +0530 realpath: Avoid overwriting preexisting error (CVE-2021-3998) Set errno and failure for paths that are too long only if no other error occurred earlier. Related: BZ #28770 Reviewed-by: Andreas Schwab <schwab@linux-m68k.org> Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> (cherry picked from commit 84d2d0fe20bdf94feed82b21b4d7d136db471f03) The release/2.34/master branch has been updated by Aurelien Jarno <aurel32@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1b9cd6a7214db1812a20eb3591cf42f9190a5d1a commit 1b9cd6a7214db1812a20eb3591cf42f9190a5d1a Author: Aurelien Jarno <aurelien@aurel32.net> Date: Mon Jan 24 23:45:03 2022 +0100 NEWS: add bug entry for BZ #28769 and BZ #28770 The release/2.33/master branch has been updated by Aurelien Jarno <aurel32@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=41980af2d77ecaef34ef5470dc76f6137279e47f commit 41980af2d77ecaef34ef5470dc76f6137279e47f Author: Siddhesh Poyarekar <siddhesh@sourceware.org> Date: Mon Jan 24 21:36:41 2022 +0530 realpath: Avoid overwriting preexisting error (CVE-2021-3998) Set errno and failure for paths that are too long only if no other error occurred earlier. Related: BZ #28770 Reviewed-by: Andreas Schwab <schwab@linux-m68k.org> Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> (cherry picked from commit 84d2d0fe20bdf94feed82b21b4d7d136db471f03) |