[PATCH v3] Fix FORTIFY_SOURCE false positive
Siddhesh Poyarekar
siddhesh@gotplt.org
Tue Oct 3 17:25:15 GMT 2023
On 2023-10-03 13:18, Volker Weißmann wrote:
> 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>
> ---
Thanks! LGTM.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Adhemerval, could you please add this with your test case patch and send
it as a series? I can then review that too.
Thanks,
Sid
> 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;
> }
> --
> 2.42.0
>
More information about the Libc-alpha
mailing list