aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew G. Morgan <morgan@kernel.org>2023-02-08 19:13:37 -0800
committerAndrew G. Morgan <morgan@kernel.org>2023-02-08 19:13:45 -0800
commit329b69ea640960d7afffc1c780ed4dde13549292 (patch)
tree14f53ecb9639612d0bebc429e773e89726fdd3d4
parentdbb9617e6f78784678776b9df197ac24228ac30d (diff)
downloadlibcap-329b69ea640960d7afffc1c780ed4dde13549292.tar.gz
Be more strict about what symbols are externally visible.
Increase the enforcement of the documented libcap API by marking internal library utility functions as "hidden". This also goes for the .so executable entry points. This addresses this bug: https://bugzilla.kernel.org/show_bug.cgi?id=217014 Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
-rw-r--r--libcap/cap_alloc.c3
-rw-r--r--libcap/execable.c3
-rw-r--r--libcap/execable.h3
3 files changed, 7 insertions, 2 deletions
diff --git a/libcap/cap_alloc.c b/libcap/cap_alloc.c
index 2403354..59fe503 100644
--- a/libcap/cap_alloc.c
+++ b/libcap/cap_alloc.c
@@ -17,6 +17,7 @@ static __u8 __libcap_mutex;
*/
static cap_value_t _cap_max_bits;
+__attribute__((visibility ("hidden")))
__attribute__((constructor (300))) void _libcap_initialize(void)
{
int errno_saved = errno;
@@ -95,7 +96,7 @@ cap_t cap_init(void)
* This is an internal library function to duplicate a string and
* tag the result as something cap_free can handle.
*/
-char *_libcap_strdup(const char *old)
+__attribute__((visibility ("hidden"))) char *_libcap_strdup(const char *old)
{
struct _cap_alloc_s *header;
char *raw_data;
diff --git a/libcap/execable.c b/libcap/execable.c
index 9d3ae7f..9f7062e 100644
--- a/libcap/execable.c
+++ b/libcap/execable.c
@@ -18,6 +18,7 @@ static void summary(void)
printf("\nCurrent mode: %s\n", cap_mode_name(mode));
printf("Number of cap values known to: this libcap=%d, running kernel=%d\n",
CAP_LAST_CAP+1, bits);
+
if (bits > CAP_LAST_CAP+1) {
printf("=> Consider upgrading libcap to name:");
for (c = CAP_LAST_CAP+1; c < bits; c++) {
@@ -30,6 +31,8 @@ static void summary(void)
printf(" %s", name);
cap_free(name);
}
+ } else {
+ return;
}
printf("\n");
}
diff --git a/libcap/execable.h b/libcap/execable.h
index fee17b4..7a2d247 100644
--- a/libcap/execable.h
+++ b/libcap/execable.h
@@ -93,7 +93,8 @@ static void __execable_parse_args(int *argc_p, char ***argv_p)
*/
#define SO_MAIN \
static void __execable_main(int, char**); \
-extern void __so_start(void); \
+__attribute__((visibility ("hidden"))) \
+void __so_start(void); \
__SO_FORCE_ARG_ALIGNMENT \
void __so_start(void) \
{ \