Bug 836931 - glibc: warn() is not protected by FORTIFY_SOURCE format string protection
Summary: glibc: warn() is not protected by FORTIFY_SOURCE format string protection
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: glibc team
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-07-02 08:45 UTC by Huzaifa S. Sidhpurwala
Modified: 2019-09-10 13:34 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-09-10 13:34:57 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Sourceware 24987 0 None None None 2019-09-10 13:34:56 UTC

Description Huzaifa S. Sidhpurwala 2012-07-02 08:45:52 UTC
While looking into some format string issue, i found that the warn() function does not seem to be protected by the glibc FORTIFY_SOURCE Format string protection mechanism.

Here is a simple example to prove my point:

[huzaifas@babylon ~]$ cat warn1.c 
#include <stdio.h>
#include <err.h>

void main(int argc, char *argv[])
{
warn(argv[1]);
//printf(argv[1]);
}

[huzaifas@babylon ~]$ gcc -O -g -D_FORTIFY_SOURCE=2 -o warn warn1.c
[huzaifas@babylon ~]$ cat print.c 
#include <stdio.h>
#include <err.h>

void main(int argc, char *argv[])
{
//warn(argv[1]);
printf(argv[1]);
}
[huzaifas@babylon ~]$ gcc -O -g -D_FORTIFY_SOURCE=2 -o print print.c

[huzaifas@babylon ~]$ ./warn "%100s%n"
warn:                                                                                               ?&#9646;&#65533;: Segmentation fault
[huzaifas@babylon ~]$ ./print "%100s%n"
*** %n in writable segment detected ***
                                                                                              L&#65533;|&#65533;Aborted
[huzaifas@babylon ~]$

Comment 3 Stefan Cornelius 2012-07-06 09:28:23 UTC
The relevant functions were never meant to be protected by fortify source, so from a security point of view, this is an enhancement only. Since fixing this would break the ABI, we need to work with upstream to see if a protection for these functions can be included in future versions.

In order to track this issue, I've filed a new, non-security bug for glibc in #838050.

Comment 4 Stefan Cornelius 2012-07-09 11:26:05 UTC

*** This bug has been marked as a duplicate of bug 838050 ***

Comment 5 Florian Weimer 2019-09-10 13:34:57 UTC
This is being tracked upstream here: https://sourceware.org/bugzilla/show_bug.cgi?id=24987


Note You need to log in before you can comment on or make changes to this bug.