Message ID | f0bd7ca129f6dd3df2e9b03270e6fbd5990ace70.1707491940.git.fweimer@redhat.com |
---|---|
State | New |
Headers | show |
Series | Build getdomainname, gethostname, syslog with fortification | expand |
On 09/02/24 12:24, Florian Weimer wrote: > Introduce __glibc_nofortify_gethostname to request disabling > the fortification wrapper. LGTM, thanks. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> > --- > misc/Makefile | 1 - > misc/gethostname.c | 2 ++ > posix/bits/unistd.h | 3 ++- > sysdeps/mach/hurd/gethostname.c | 2 ++ > sysdeps/posix/gethostname.c | 2 ++ > sysdeps/unix/sysv/linux/alpha/gethostname.c | 2 ++ > 6 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/misc/Makefile b/misc/Makefile > index 44ae89670a..6d8528c925 100644 > --- a/misc/Makefile > +++ b/misc/Makefile > @@ -209,7 +209,6 @@ routines := \ > > # Exclude fortified routines from being built with _FORTIFY_SOURCE > routines_no_fortify += \ > - gethostname \ > syslog \ > # routines_no_fortify > > diff --git a/misc/gethostname.c b/misc/gethostname.c > index 2c849a95c3..82800f8abb 100644 > --- a/misc/gethostname.c > +++ b/misc/gethostname.c > @@ -15,6 +15,8 @@ > License along with the GNU C Library; if not, see > <https://www.gnu.org/licenses/>. */ > > +#define __glibc_nofortify_gethostname > + > #include <errno.h> > #include <unistd.h> > > diff --git a/posix/bits/unistd.h b/posix/bits/unistd.h > index 6ed2943bf1..1230bba9a5 100644 > --- a/posix/bits/unistd.h > +++ b/posix/bits/unistd.h > @@ -138,7 +138,8 @@ getlogin_r (char *__buf, size_t __buflen) > #endif > > > -#if defined __USE_MISC || defined __USE_UNIX98 > +#if defined __USE_MISC || defined __USE_UNIX98 \ > + && !defined __glibc_nofortify_gethostname > __fortify_function int > __NTH (gethostname (char *__buf, size_t __buflen)) > { > diff --git a/sysdeps/mach/hurd/gethostname.c b/sysdeps/mach/hurd/gethostname.c > index 91d7f45d6e..dbb7d75713 100644 > --- a/sysdeps/mach/hurd/gethostname.c > +++ b/sysdeps/mach/hurd/gethostname.c > @@ -15,6 +15,8 @@ > License along with the GNU C Library; if not, see > <https://www.gnu.org/licenses/>. */ > > +#define __glibc_nofortify_gethostname > + > #include <unistd.h> > #include "hurdhost.h" > > diff --git a/sysdeps/posix/gethostname.c b/sysdeps/posix/gethostname.c > index 3c50706b58..3c79f77dd3 100644 > --- a/sysdeps/posix/gethostname.c > +++ b/sysdeps/posix/gethostname.c > @@ -15,6 +15,8 @@ > License along with the GNU C Library; if not, see > <https://www.gnu.org/licenses/>. */ > > +#define __glibc_nofortify_gethostname > + > #include <errno.h> > #include <string.h> > #include <unistd.h> > diff --git a/sysdeps/unix/sysv/linux/alpha/gethostname.c b/sysdeps/unix/sysv/linux/alpha/gethostname.c > index 30da8f30e4..45eb1788d4 100644 > --- a/sysdeps/unix/sysv/linux/alpha/gethostname.c > +++ b/sysdeps/unix/sysv/linux/alpha/gethostname.c > @@ -15,6 +15,8 @@ > License along with the GNU C Library. If not, see > <https://www.gnu.org/licenses/>. */ > > +#define __glibc_nofortify_gethostname > + > #include <errno.h> > #include <string.h> > #include <unistd.h>
diff --git a/misc/Makefile b/misc/Makefile index 44ae89670a..6d8528c925 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -209,7 +209,6 @@ routines := \ # Exclude fortified routines from being built with _FORTIFY_SOURCE routines_no_fortify += \ - gethostname \ syslog \ # routines_no_fortify diff --git a/misc/gethostname.c b/misc/gethostname.c index 2c849a95c3..82800f8abb 100644 --- a/misc/gethostname.c +++ b/misc/gethostname.c @@ -15,6 +15,8 @@ License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ +#define __glibc_nofortify_gethostname + #include <errno.h> #include <unistd.h> diff --git a/posix/bits/unistd.h b/posix/bits/unistd.h index 6ed2943bf1..1230bba9a5 100644 --- a/posix/bits/unistd.h +++ b/posix/bits/unistd.h @@ -138,7 +138,8 @@ getlogin_r (char *__buf, size_t __buflen) #endif -#if defined __USE_MISC || defined __USE_UNIX98 +#if defined __USE_MISC || defined __USE_UNIX98 \ + && !defined __glibc_nofortify_gethostname __fortify_function int __NTH (gethostname (char *__buf, size_t __buflen)) { diff --git a/sysdeps/mach/hurd/gethostname.c b/sysdeps/mach/hurd/gethostname.c index 91d7f45d6e..dbb7d75713 100644 --- a/sysdeps/mach/hurd/gethostname.c +++ b/sysdeps/mach/hurd/gethostname.c @@ -15,6 +15,8 @@ License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ +#define __glibc_nofortify_gethostname + #include <unistd.h> #include "hurdhost.h" diff --git a/sysdeps/posix/gethostname.c b/sysdeps/posix/gethostname.c index 3c50706b58..3c79f77dd3 100644 --- a/sysdeps/posix/gethostname.c +++ b/sysdeps/posix/gethostname.c @@ -15,6 +15,8 @@ License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ +#define __glibc_nofortify_gethostname + #include <errno.h> #include <string.h> #include <unistd.h> diff --git a/sysdeps/unix/sysv/linux/alpha/gethostname.c b/sysdeps/unix/sysv/linux/alpha/gethostname.c index 30da8f30e4..45eb1788d4 100644 --- a/sysdeps/unix/sysv/linux/alpha/gethostname.c +++ b/sysdeps/unix/sysv/linux/alpha/gethostname.c @@ -15,6 +15,8 @@ License along with the GNU C Library. If not, see <https://www.gnu.org/licenses/>. */ +#define __glibc_nofortify_gethostname + #include <errno.h> #include <string.h> #include <unistd.h>