public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/28770] New: Unexpected return value from realpath() for too long results (CVE-2021-3998)
@ 2022-01-12 17:45 siddhesh at sourceware dot org
  2022-01-12 17:46 ` [Bug libc/28770] " siddhesh at sourceware dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: siddhesh at sourceware dot org @ 2022-01-12 17:45 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28770

            Bug ID: 28770
           Summary: Unexpected return value from realpath() for too long
                    results (CVE-2021-3998)
           Product: glibc
           Version: 2.35
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: siddhesh at sourceware dot org
          Reporter: siddhesh at sourceware dot org
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

When the resolved_path argument for realpath is non-NULL and the result is
longer than PATH_MAX, the return value is an allocated string instead of
resolved_path, which may result in a memory leak since the caller expects
resolved_path.

Another problem with this behaviour is that if the caller uses resolved_path
instead of the return value from realpath; it may potentially end up using
uninitialized memory.

The expected behaviour in case of result being greater than PATH_MAX is to
return NULL and set ENAMETOOLONG.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libc/28770] Unexpected return value from realpath() for too long results (CVE-2021-3998)
  2022-01-12 17:45 [Bug libc/28770] New: Unexpected return value from realpath() for too long results (CVE-2021-3998) siddhesh at sourceware dot org
@ 2022-01-12 17:46 ` siddhesh at sourceware dot org
  2022-01-13  5:44 ` sam at gentoo dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: siddhesh at sourceware dot org @ 2022-01-12 17:46 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28770

Siddhesh Poyarekar <siddhesh at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security+

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libc/28770] Unexpected return value from realpath() for too long results (CVE-2021-3998)
  2022-01-12 17:45 [Bug libc/28770] New: Unexpected return value from realpath() for too long results (CVE-2021-3998) siddhesh at sourceware dot org
  2022-01-12 17:46 ` [Bug libc/28770] " siddhesh at sourceware dot org
@ 2022-01-13  5:44 ` sam at gentoo dot org
  2022-01-13  6:10 ` siddhesh at sourceware dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: sam at gentoo dot org @ 2022-01-13  5:44 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28770

Sam James <sam at gentoo dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sam at gentoo dot org

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libc/28770] Unexpected return value from realpath() for too long results (CVE-2021-3998)
  2022-01-12 17:45 [Bug libc/28770] New: Unexpected return value from realpath() for too long results (CVE-2021-3998) siddhesh at sourceware dot org
  2022-01-12 17:46 ` [Bug libc/28770] " siddhesh at sourceware dot org
  2022-01-13  5:44 ` sam at gentoo dot org
@ 2022-01-13  6:10 ` siddhesh at sourceware dot org
  2022-01-13 11:59 ` fweimer at redhat dot com
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: siddhesh at sourceware dot org @ 2022-01-13  6:10 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28770

Siddhesh Poyarekar <siddhesh at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libc/28770] Unexpected return value from realpath() for too long results (CVE-2021-3998)
  2022-01-12 17:45 [Bug libc/28770] New: Unexpected return value from realpath() for too long results (CVE-2021-3998) siddhesh at sourceware dot org
                   ` (2 preceding siblings ...)
  2022-01-13  6:10 ` siddhesh at sourceware dot org
@ 2022-01-13 11:59 ` fweimer at redhat dot com
  2022-01-15 15:41 ` aurelien at aurel32 dot net
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: fweimer at redhat dot com @ 2022-01-13 11:59 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28770

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fweimer at redhat dot com

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libc/28770] Unexpected return value from realpath() for too long results (CVE-2021-3998)
  2022-01-12 17:45 [Bug libc/28770] New: Unexpected return value from realpath() for too long results (CVE-2021-3998) siddhesh at sourceware dot org
                   ` (3 preceding siblings ...)
  2022-01-13 11:59 ` fweimer at redhat dot com
@ 2022-01-15 15:41 ` aurelien at aurel32 dot net
  2022-01-17  9:08 ` pgowda.cve at gmail dot com
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: aurelien at aurel32 dot net @ 2022-01-15 15:41 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28770

Aurelien Jarno <aurelien at aurel32 dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aurelien at aurel32 dot net

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libc/28770] Unexpected return value from realpath() for too long results (CVE-2021-3998)
  2022-01-12 17:45 [Bug libc/28770] New: Unexpected return value from realpath() for too long results (CVE-2021-3998) siddhesh at sourceware dot org
                   ` (4 preceding siblings ...)
  2022-01-15 15:41 ` aurelien at aurel32 dot net
@ 2022-01-17  9:08 ` pgowda.cve at gmail dot com
  2022-01-21 17:45 ` siddhesh at sourceware dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pgowda.cve at gmail dot com @ 2022-01-17  9:08 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28770

pgowda <pgowda.cve at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pgowda.cve at gmail dot com

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libc/28770] Unexpected return value from realpath() for too long results (CVE-2021-3998)
  2022-01-12 17:45 [Bug libc/28770] New: Unexpected return value from realpath() for too long results (CVE-2021-3998) siddhesh at sourceware dot org
                   ` (5 preceding siblings ...)
  2022-01-17  9:08 ` pgowda.cve at gmail dot com
@ 2022-01-21 17:45 ` siddhesh at sourceware dot org
  2022-01-24 16:11 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: siddhesh at sourceware dot org @ 2022-01-21 17:45 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28770

Siddhesh Poyarekar <siddhesh at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |2.35
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #1 from Siddhesh Poyarekar <siddhesh at sourceware dot org> ---
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>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libc/28770] Unexpected return value from realpath() for too long results (CVE-2021-3998)
  2022-01-12 17:45 [Bug libc/28770] New: Unexpected return value from realpath() for too long results (CVE-2021-3998) siddhesh at sourceware dot org
                   ` (6 preceding siblings ...)
  2022-01-21 17:45 ` siddhesh at sourceware dot org
@ 2022-01-24 16:11 ` cvs-commit at gcc dot gnu.org
  2022-01-24 16:15 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-24 16:11 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28770

--- Comment #2 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.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>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libc/28770] Unexpected return value from realpath() for too long results (CVE-2021-3998)
  2022-01-12 17:45 [Bug libc/28770] New: Unexpected return value from realpath() for too long results (CVE-2021-3998) siddhesh at sourceware dot org
                   ` (7 preceding siblings ...)
  2022-01-24 16:11 ` cvs-commit at gcc dot gnu.org
@ 2022-01-24 16:15 ` cvs-commit at gcc dot gnu.org
  2022-01-24 22:46 ` cvs-commit at gcc dot gnu.org
  2022-01-24 22:49 ` cvs-commit at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-24 16:15 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28770

--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.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)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libc/28770] Unexpected return value from realpath() for too long results (CVE-2021-3998)
  2022-01-12 17:45 [Bug libc/28770] New: Unexpected return value from realpath() for too long results (CVE-2021-3998) siddhesh at sourceware dot org
                   ` (8 preceding siblings ...)
  2022-01-24 16:15 ` cvs-commit at gcc dot gnu.org
@ 2022-01-24 22:46 ` cvs-commit at gcc dot gnu.org
  2022-01-24 22:49 ` cvs-commit at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-24 22:46 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28770

--- Comment #4 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
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

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libc/28770] Unexpected return value from realpath() for too long results (CVE-2021-3998)
  2022-01-12 17:45 [Bug libc/28770] New: Unexpected return value from realpath() for too long results (CVE-2021-3998) siddhesh at sourceware dot org
                   ` (9 preceding siblings ...)
  2022-01-24 22:46 ` cvs-commit at gcc dot gnu.org
@ 2022-01-24 22:49 ` cvs-commit at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-24 22:49 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28770

--- Comment #5 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
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)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-01-24 22:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-12 17:45 [Bug libc/28770] New: Unexpected return value from realpath() for too long results (CVE-2021-3998) siddhesh at sourceware dot org
2022-01-12 17:46 ` [Bug libc/28770] " siddhesh at sourceware dot org
2022-01-13  5:44 ` sam at gentoo dot org
2022-01-13  6:10 ` siddhesh at sourceware dot org
2022-01-13 11:59 ` fweimer at redhat dot com
2022-01-15 15:41 ` aurelien at aurel32 dot net
2022-01-17  9:08 ` pgowda.cve at gmail dot com
2022-01-21 17:45 ` siddhesh at sourceware dot org
2022-01-24 16:11 ` cvs-commit at gcc dot gnu.org
2022-01-24 16:15 ` cvs-commit at gcc dot gnu.org
2022-01-24 22:46 ` cvs-commit at gcc dot gnu.org
2022-01-24 22:49 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).