public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] Fix FORTIFY_SOURCE false positive
@ 2023-10-04 11:18 Adhemerval Zanella
  0 siblings, 0 replies; only message in thread
From: Adhemerval Zanella @ 2023-10-04 11:18 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=7bb8045ec0595a031e68383849c3fbd9af134312

commit 7bb8045ec0595a031e68383849c3fbd9af134312
Author: Volker Weißmann <volker.weissmann@gmx.de>
Date:   Tue Oct 3 19:18:44 2023 +0200

    Fix FORTIFY_SOURCE false positive
    
    When -D_FORTIFY_SOURCE=2 was given during compilation,
    sprintf and similar functions will check if their
    first argument is in read-only memory and exit with
    *** %n in writable segment detected ***
    otherwise. To check if the memory is read-only, glibc
    reads frpm the file "/proc/self/maps". If opening this
    file fails due to too many open files (EMFILE), glibc
    will now ignore this error.
    
    Fixes [BZ #30932]
    
    Signed-off-by: Volker Weißmann <volker.weissmann@gmx.de>
    Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

Diff:
---
 sysdeps/unix/sysv/linux/readonly-area.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sysdeps/unix/sysv/linux/readonly-area.c b/sysdeps/unix/sysv/linux/readonly-area.c
index edc68873f6..ba32372ebb 100644
--- a/sysdeps/unix/sysv/linux/readonly-area.c
+++ b/sysdeps/unix/sysv/linux/readonly-area.c
@@ -42,7 +42,9 @@ __readonly_area (const char *ptr, size_t size)
 	     to the /proc filesystem if it is set[ug]id.  There has
 	     been no willingness to change this in the kernel so
 	     far.  */
-	  || errno == EACCES)
+	  || errno == EACCES
+	  /* Process has reached the maximum number of open files.  */
+	  || errno == EMFILE)
 	return 1;
       return -1;
     }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-10-04 11:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-04 11:18 [glibc] Fix FORTIFY_SOURCE false positive Adhemerval Zanella

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).