From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 3A9E33856DD5; Wed, 4 Oct 2023 11:18:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A9E33856DD5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1696418296; bh=Tv0+Jr0fY957zSSoYpzJsIzuR6ifnCV1SeuBRrf2DiQ=; h=From:To:Subject:Date:From; b=udNuM/UStQJW58H0RN25v93Wh3S203Vha3UJkImzScK9f0AMHIAn/GapHhM0wm2QA RMWZBhtnMA4B7Sf1AdPDhg2GQdxZWmqrrv/CJH6mclCpGVUHjvHQwFb302asTxOoy/ 6VbrNbJ0PDTuAKwPCe41QviK8ZfAMQzc1QL/J4j0= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc] Fix FORTIFY_SOURCE false positive X-Act-Checkin: glibc X-Git-Author: =?utf-8?q?Volker_Wei=C3=9Fmann?= X-Git-Refname: refs/heads/master X-Git-Oldrev: 751850cf5a87e463f0f8b508672594e54853495c X-Git-Newrev: 7bb8045ec0595a031e68383849c3fbd9af134312 Message-Id: <20231004111816.3A9E33856DD5@sourceware.org> Date: Wed, 4 Oct 2023 11:18:16 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=7bb8045ec0595a031e68383849c3fbd9af134312 commit 7bb8045ec0595a031e68383849c3fbd9af134312 Author: Volker Weißmann 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 Reviewed-by: Siddhesh Poyarekar 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; }