Skip to contentSkip to conversation

libselinux: Do not inline compile_regex()

PATCH In review James Carter 3 participants 5 messages Jun 11, 2025 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libselinux: Do not inline compile_regex()

Since commit bdcbbf89b9548afd452449835e58e84105a71a9a (libselinux:
limit fcontext regex path length), an error would be given if libselinux was compiled directly. (Though, building the whole SELinux userspace still worked.) This is because the flag "-Winline" is used when building libselinux directly, but not when building the whole userspace.

Remove "inline" from the function compile_regex() in label_file.h to allow libselinux to be built directly.

There are four functions defined in label_file.h that are not inlined:
regex_has_meta_chars(), regex_simplify(), compile_regex(), and insert_spec(). The first three functions are called by insert_spec() which is called by the inlined function process_line(). This last function is called by utils/sefcontext_compile.c which prevents relocating the non-inlined functions to label_file.c.

---
 libselinux/src/label_file.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/label_file.h +1 -1
index d1a0713a..8fcf74e3 100644
@@ -390,7 +390,7 @@ static inline void sort_specs(struct saved_data *data)
 	sort_spec_node(data->root, NULL);
 }
 
-static inline int compile_regex(struct regex_spec *spec, char *errbuf, size_t errbuf_size)
+static int compile_regex(struct regex_spec *spec, char *errbuf, size_t errbuf_size)
 {
 	const char *reg_buf;
 	char *anchored_regex, *cp;
Signature · 1 line
2.49.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · James Carter

Since commit bdcbbf89b9548afd452449835e58e84105a71a9a (libselinux:
limit fcontext regex path length), an error would be given if libselinux was compiled directly. (Though, building the whole SELinux userspace still worked.) This is because the flag "-Winline" is used when building libselinux directly, but not when building the whole userspace.

Remove "inline" from the function compile_regex() in label_file.h to allow libselinux to be built directly.

Quoted 8 lines

There are four functions defined in label_file.h that are not inlined:
regex_has_meta_chars(), regex_simplify(), compile_regex(), and insert_spec(). The first three functions are called by insert_spec() which is called by the inlined function process_line(). This last function is called by utils/sefcontext_compile.c which prevents relocating the non-inlined functions to label_file.c.

Quoted 21 lines
---
 libselinux/src/label_file.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/label_file.h +1 -2
index d1a0713a..8fcf74e3 100644
@@ -390,7 +390,7 @@ static inline void sort_specs(struct saved_data *data)
        sort_spec_node(data->root, NULL);
 }
 
-static inline int compile_regex(struct regex_spec *spec, char *errbuf, size_t errbuf_size)
+static int compile_regex(struct regex_spec *spec, char *errbuf, size_t errbuf_size)
 {
        const char *reg_buf;
        char *anchored_regex, *cp;
--

2.49.0

#2 lore raw
Quoted 19 lines · Stephen Smalley
Quoted 18 lines · James Carter

Since commit bdcbbf89b9548afd452449835e58e84105a71a9a (libselinux:
limit fcontext regex path length), an error would be given if libselinux was compiled directly. (Though, building the whole SELinux userspace still worked.) This is because the flag "-Winline" is used when building libselinux directly, but not when building the whole userspace.

Remove "inline" from the function compile_regex() in label_file.h to allow libselinux to be built directly.

There are four functions defined in label_file.h that are not inlined:
regex_has_meta_chars(), regex_simplify(), compile_regex(), and insert_spec(). The first three functions are called by insert_spec() which is called by the inlined function process_line(). This last function is called by utils/sefcontext_compile.c which prevents relocating the non-inlined functions to label_file.c.

Quoted 4 lines
Quoted 1 line

I'm going to postpone 3.9-rc1 to tomorrow so this change can land there.

Ok?

Quoted 21 lines
Quoted 21 lines
---
 libselinux/src/label_file.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/label_file.h +1 -2
index d1a0713a..8fcf74e3 100644
@@ -390,7 +390,7 @@ static inline void sort_specs(struct saved_data *data)
        sort_spec_node(data->root, NULL);
 }
 
-static inline int compile_regex(struct regex_spec *spec, char *errbuf, size_t errbuf_size)
+static int compile_regex(struct regex_spec *spec, char *errbuf, size_t errbuf_size)
 {
        const char *reg_buf;
        char *anchored_regex, *cp;
--

2.49.0

maintainer
#3 lore raw
Quoted 22 lines · Petr Lautrbach
Quoted 19 lines · Stephen Smalley
Quoted 18 lines · James Carter

Since commit bdcbbf89b9548afd452449835e58e84105a71a9a (libselinux:
limit fcontext regex path length), an error would be given if libselinux was compiled directly. (Though, building the whole SELinux userspace still worked.) This is because the flag "-Winline" is used when building libselinux directly, but not when building the whole userspace.

Remove "inline" from the function compile_regex() in label_file.h to allow libselinux to be built directly.

There are four functions defined in label_file.h that are not inlined:
regex_has_meta_chars(), regex_simplify(), compile_regex(), and insert_spec(). The first three functions are called by insert_spec() which is called by the inlined function process_line(). This last function is called by utils/sefcontext_compile.c which prevents relocating the non-inlined functions to label_file.c.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

I'm going to postpone 3.9-rc1 to tomorrow so this change can land there.

Ok?

Or feel free to merge it now (or I can) and you can do it today, whichever is easiest.

#4 lore raw
Quoted 28 lines · Stephen Smalley
Quoted 27 lines · Petr Lautrbach
Quoted 23 lines · Stephen Smalley
Quoted 11 lines · James Carter

Since commit bdcbbf89b9548afd452449835e58e84105a71a9a (libselinux:
limit fcontext regex path length), an error would be given if libselinux was compiled directly. (Though, building the whole SELinux userspace still worked.) This is because the flag "-Winline" is used when building libselinux directly, but not when building the whole userspace.

Remove "inline" from the function compile_regex() in label_file.h to allow libselinux to be built directly.

Quoted 8 lines

There are four functions defined in label_file.h that are not inlined:
regex_has_meta_chars(), regex_simplify(), compile_regex(), and insert_spec(). The first three functions are called by insert_spec() which is called by the inlined function process_line(). This last function is called by utils/sefcontext_compile.c which prevents relocating the non-inlined functions to label_file.c.

Quoted 6 lines
Quoted 3 lines

I'm going to postpone 3.9-rc1 to tomorrow so this change can land there.

Ok?

Or feel free to merge it now (or I can) and you can do it today, whichever is easiest.

I've merged it just now.

expect 3.9-rc1 in next 30 minutes