NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
lib/57288: include/ssp/ssp.h: Use __builtin_dynamic_object_size for LLVM > 9 and GCC > 12
>Number: 57288
>Category: lib
>Synopsis: include/ssp/ssp.h: Use __builtin_dynamic_object_size for LLVM > 9 and GCC > 12
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Mar 24 06:05:00 +0000 2023
>Originator: Mingye Wang
>Release: trunk, 24 March 2023
>Organization:
>Environment:
Irrelevant, just reading the source code.
>Description:
LLVM 9.0 and GCC 12.0 introduced support for __builtin_dynamic_object_size, which feeds into glibc's level 3 of _FORTIFY_SOURCE -- the point of the new builtin is to also give sizes unknown at compile time. NetBSD trunk currently uses LLVM 10.0git, which does have the feature.
NetBSD has its own implementation of the stuff in ssp, but its headers have not yet been updated to use the new thing. This affects downstream projects such as newlib and Cygwin, which use the NetBSD ssp.
>How-To-Repeat:
grep for __builtin_dynamic_object_size.
>Fix:
In the part that defines __SSP_FORTIFY_LEVEL, write instead:
```
#if !defined(__cplusplus)
# if _FORTIFY_SOURCE > 0 && !defined(__lint__) && \
(__OPTIMIZE__ > 0 || defined(__clang__)) && __GNUC_PREREQ__(4, 1)
# if _FORTIFY_SOURCE > 2 && __has_builtin(__builtin_dynamic_object_size)
# define __SSP_FORTIFY_LEVEL 3
# elif _FORTIFY_SOURCE > 1
# define __SSP_FORTIFY_LEVEL 2
# else
# define __SSP_FORTIFY_LEVEL 1
# endif
# else
# define __SSP_FORTIFY_LEVEL 0
# endif
#else
# define __SSP_FORTIFY_LEVEL 0
#endif
```
In the part that defines __ssp_bos{,0}, write instead:
```
#if __SSP_FORTIFY_LEVEL > 2
# define __ssp_bos(ptr) __builtin_dynamic_object_size(ptr, 1)
# define __ssp_bos0(ptr) __builtin_dynamic_object_size(ptr, 0)
#else
# define __ssp_bos(ptr) __builtin_object_size(ptr, __SSP_FORTIFY_LEVEL > 1)
# define __ssp_bos0(ptr) __builtin_object_size(ptr, 0)
#endif
```
Home |
Main Index |
Thread Index |
Old Index