Fix build with -fno-common
Subsystems (2)
v2 cover Fix build with -fno-common
GCC 10 is going to enable -fno-common by default [1], so fix all build errors uncovered by it and add it to global CFLAGS to avoid introducing new bugs.
Changes in v2:
- remove also struct te_assert definition, which is also useless
- redo cil_mem_error_handler to match commit 4459d635b8f1 as suggested by Jim Carter
Travis build: [2]
[1] https://gcc.gnu.org/gcc-10/porting_to.html#common
[2] https://travis-ci.org/WOnder93/selinux/builds/640875119
Ondrej Mosnacek (4):
libsepol: fix CIL_KEY_* build errors with -fno-common
libsepol: remove leftovers of cil_mem_error_handler
checkpolicy: remove unused te_assertions
Makefile: always build with -fno-common
Makefile | 3 +- checkpolicy/checkpolicy.h | 14 -- libsepol/cil/src/cil.c | 162 ++++++++++++++++ libsepol/cil/src/cil_internal.h | 322 ++++++++++++++++---------------- libsepol/cil/src/cil_mem.h | 1 - libsepol/cil/src/cil_strpool.c | 8 +- 6 files changed, 329 insertions(+), 181 deletions(-)
Signature · 1 line
2.24.1
PATCH v2 1/4 libsepol: fix CIL_KEY_* build errors with -fno-common
GCC 10 comes with -fno-common enabled by default - fix the CIL_KEY_* global variables to be defined only once in cil.c and declared in the header file correctly with the 'extern' keyword, so that other units including the file don't generate duplicate definitions.
--- libsepol/cil/src/cil.c | 162 ++++++++++++++++ libsepol/cil/src/cil_internal.h | 322 ++++++++++++++++---------------- 2 files changed, 323 insertions(+), 161 deletions(-)
libsepol/cil/src/cil.c +162 -0
@@ -77,6 +77,168 @@ int cil_sym_sizes[CIL_SYM_ARRAY_NUM][CIL_SYM_NUM] = { {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} }; +char *CIL_KEY_CONS_T1 ; +char *CIL_KEY_CONS_T2 ; +char *CIL_KEY_CONS_T3 ; +char *CIL_KEY_CONS_R1 ; +char *CIL_KEY_CONS_R2 ; +char *CIL_KEY_CONS_R3 ; +char *CIL_KEY_CONS_U1 ; +char *CIL_KEY_CONS_U2 ; +char *CIL_KEY_CONS_U3 ; +char *CIL_KEY_CONS_L1 ; +char *CIL_KEY_CONS_L2 ; +char *CIL_KEY_CONS_H1 ; +char *CIL_KEY_CONS_H2 ; +char *CIL_KEY_AND ; +char *CIL_KEY_OR ; +char *CIL_KEY_NOT ; +char *CIL_KEY_EQ ; +char *CIL_KEY_NEQ ; +char *CIL_KEY_CONS_DOM ; +char *CIL_KEY_CONS_DOMBY ; +char *CIL_KEY_CONS_INCOMP ; +char *CIL_KEY_CONDTRUE ; +char *CIL_KEY_CONDFALSE ; +char *CIL_KEY_SELF ; +char *CIL_KEY_OBJECT_R ; +char *CIL_KEY_STAR ; +char *CIL_KEY_TCP ; +char *CIL_KEY_UDP ; +char *CIL_KEY_DCCP ; +char *CIL_KEY_SCTP ; +char *CIL_KEY_AUDITALLOW ; +char *CIL_KEY_TUNABLEIF ; +char *CIL_KEY_ALLOW ; +char *CIL_KEY_DONTAUDIT ; +char *CIL_KEY_TYPETRANSITION ; +char *CIL_KEY_TYPECHANGE ; +char *CIL_KEY_CALL ; +char *CIL_KEY_TUNABLE ; +char *CIL_KEY_XOR ; +char *CIL_KEY_ALL ; +char *CIL_KEY_RANGE ; +char *CIL_KEY_GLOB ; +char *CIL_KEY_FILE ; +char *CIL_KEY_DIR ; +char *CIL_KEY_CHAR ; +char *CIL_KEY_BLOCK ; +char *CIL_KEY_SOCKET ; +char *CIL_KEY_PIPE ; +char *CIL_KEY_SYMLINK ; +char *CIL_KEY_ANY ; +char *CIL_KEY_XATTR ; +char *CIL_KEY_TASK ; +char *CIL_KEY_TRANS ; +char *CIL_KEY_TYPE ; +char *CIL_KEY_ROLE ; +char *CIL_KEY_USER ; +char *CIL_KEY_USERATTRIBUTE ; +char *CIL_KEY_USERATTRIBUTESET ; +char *CIL_KEY_SENSITIVITY ; +char *CIL_KEY_CATEGORY ; +char *CIL_KEY_CATSET ; +char *CIL_KEY_LEVEL ; +char *CIL_KEY_LEVELRANGE ; +char *CIL_KEY_CLASS ; +char *CIL_KEY_IPADDR ; +char *CIL_KEY_MAP_CLASS ; +char *CIL_KEY_CLASSPERMISSION ; +char *CIL_KEY_BOOL ; +char *CIL_KEY_STRING ; +char *CIL_KEY_NAME ; +char *CIL_KEY_SOURCE ; +char *CIL_KEY_TARGET ; +char *CIL_KEY_LOW ; +char *CIL_KEY_HIGH ; +char *CIL_KEY_LOW_HIGH ; +char *CIL_KEY_GLBLUB ; +char *CIL_KEY_HANDLEUNKNOWN ; +char *CIL_KEY_HANDLEUNKNOWN_ALLOW ; +char *CIL_KEY_HANDLEUNKNOWN_DENY ; +char *CIL_KEY_HANDLEUNKNOWN_REJECT ; +char *CIL_KEY_MACRO ; +char *CIL_KEY_IN ; +char *CIL_KEY_MLS ; +char *CIL_KEY_DEFAULTRANGE ; +char *CIL_KEY_BLOCKINHERIT ; +char *CIL_KEY_BLOCKABSTRACT ; +char *CIL_KEY_CLASSORDER ; +char *CIL_KEY_CLASSMAPPING ; +char *CIL_KEY_CLASSPERMISSIONSET ; +char *CIL_KEY_COMMON ; +char *CIL_KEY_CLASSCOMMON ; +char *CIL_KEY_SID ; +char *CIL_KEY_SIDCONTEXT ; +char *CIL_KEY_SIDORDER ; +char *CIL_KEY_USERLEVEL ; +char *CIL_KEY_USERRANGE ; +char *CIL_KEY_USERBOUNDS ; +char *CIL_KEY_USERPREFIX ; +char *CIL_KEY_SELINUXUSER ; +char *CIL_KEY_SELINUXUSERDEFAULT ; +char *CIL_KEY_TYPEATTRIBUTE ; +char *CIL_KEY_TYPEATTRIBUTESET ; +char *CIL_KEY_EXPANDTYPEATTRIBUTE ; +char *CIL_KEY_TYPEALIAS ; +char *CIL_KEY_TYPEALIASACTUAL ; +char *CIL_KEY_TYPEBOUNDS ; +char *CIL_KEY_TYPEPERMISSIVE ; +char *CIL_KEY_RANGETRANSITION ; +char *CIL_KEY_USERROLE ; +char *CIL_KEY_ROLETYPE ; +char *CIL_KEY_ROLETRANSITION ; +char *CIL_KEY_ROLEALLOW ; +char *CIL_KEY_ROLEATTRIBUTE ; +char *CIL_KEY_ROLEATTRIBUTESET ; +char *CIL_KEY_ROLEBOUNDS ; +char *CIL_KEY_BOOLEANIF ; +char *CIL_KEY_NEVERALLOW ; +char *CIL_KEY_TYPEMEMBER ; +char *CIL_KEY_SENSALIAS ; +char *CIL_KEY_SENSALIASACTUAL ; +char *CIL_KEY_CATALIAS ; +char *CIL_KEY_CATALIASACTUAL ; +char *CIL_KEY_CATORDER ; +char *CIL_KEY_SENSITIVITYORDER ; +char *CIL_KEY_SENSCAT ; +char *CIL_KEY_CONSTRAIN ; +char *CIL_KEY_MLSCONSTRAIN ; +char *CIL_KEY_VALIDATETRANS ; +char *CIL_KEY_MLSVALIDATETRANS ; +char *CIL_KEY_CONTEXT ; +char *CIL_KEY_FILECON ; +char *CIL_KEY_IBPKEYCON ; +char *CIL_KEY_IBENDPORTCON ; +char *CIL_KEY_PORTCON ; +char *CIL_KEY_NODECON ; +char *CIL_KEY_GENFSCON ; +char *CIL_KEY_NETIFCON ; +char *CIL_KEY_PIRQCON ; +char *CIL_KEY_IOMEMCON ; +char *CIL_KEY_IOPORTCON ; +char *CIL_KEY_PCIDEVICECON ; +char *CIL_KEY_DEVICETREECON ; +char *CIL_KEY_FSUSE ; +char *CIL_KEY_POLICYCAP ; +char *CIL_KEY_OPTIONAL ; +char *CIL_KEY_DEFAULTUSER ; +char *CIL_KEY_DEFAULTROLE ; +char *CIL_KEY_DEFAULTTYPE ; +char *CIL_KEY_ROOT ; +char *CIL_KEY_NODE ; +char *CIL_KEY_PERM ; +char *CIL_KEY_ALLOWX ; +char *CIL_KEY_AUDITALLOWX ; +char *CIL_KEY_DONTAUDITX ; +char *CIL_KEY_NEVERALLOWX ; +char *CIL_KEY_PERMISSIONX ; +char *CIL_KEY_IOCTL ; +char *CIL_KEY_UNORDERED ; +char *CIL_KEY_SRC_INFO ; +char *CIL_KEY_SRC_CIL ; +char *CIL_KEY_SRC_HLL ; +static void cil_init_keys (void ) {/* Initialize CIL Keys into strpool */
libsepol/cil/src/cil_internal.h +161 -161
328 lines not on this page · raw message
Signature · 1 line
2.24.1
PATCH v2 2/4 libsepol: remove leftovers of cil_mem_error_handler
In reply to Ondrej MosnacekCommit 4459d635b8f1 ("libsepol: Remove cil_mem_error_handler() function pointer") replaced cil_mem_error_handler usage with inline contents of the default handler. However, it left over the header declaration and two callers. Convert these as well and remove the header declaration.
This also fixes a build failure with -fno-common.
--- libsepol/cil/src/cil_mem.h | 1 - libsepol/cil/src/cil_strpool.c | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-)
libsepol/cil/src/cil_mem.h +0 -1
@@ -36,7 +36,6 @@ void *cil_calloc(size_t num_elements, size_t element_size);void *cil_realloc (void *ptr,size_t size);char *cil_strdup (const char *str);int cil_asprintf (char **strp,const char *fmt, ...); -void (*cil_mem_error_handler)(void );#endif /* CIL_MEM_H_ */
libsepol/cil/src/cil_strpool.c +4 -4
@@ -80,8 +80,8 @@ char *cil_strpool_add(const char *str)int rc =hashtab_insert (cil_strpool_tab, (hashtab_key_t )strpool_ref->str, strpool_ref);if (rc !=SEPOL_OK ) {pthread_mutex_unlock (&cil_strpool_mutex); - (*cil_mem_error_handler)(); -pthread_mutex_lock (&cil_strpool_mutex); +cil_log (CIL_ERR ,"Failed to allocate memory\n" ); +exit (1 ); } }
@@ -104,8 +104,8 @@ void cil_strpool_init(void) cil_strpool_tab =hashtab_create (cil_strpool_hash, cil_strpool_compare,CIL_STRPOOL_TABLE_SIZE );if (cil_strpool_tab ==NULL ) {pthread_mutex_unlock (&cil_strpool_mutex); - (*cil_mem_error_handler)(); -return ; +cil_log (CIL_ERR ,"Failed to allocate memory\n" ); +exit (1 ); } } cil_strpool_readers++;
Signature · 1 line
2.24.1
PATCH v2 3/4 checkpolicy: remove unused te_assertions
In reply to Ondrej MosnacekThis variable is declared in a header file, but never defined or used. The te_assert structure definition is only used in this declaration, so remove both.
--- checkpolicy/checkpolicy.h | 14 -------------- 1 file changed, 14 deletions(-)
checkpolicy/checkpolicy.h +0 -14
@@ -1,20 +1,6 @@#ifndef _CHECKPOLICY_H_#define _CHECKPOLICY_H_ -#include <sepol/policydb/ebitmap.h> - -typedef struct te_assert { -ebitmap_t stypes; -ebitmap_t ttypes; -ebitmap_t tclasses; -int self; -sepol_access_vector_t *avp; -unsigned long line; -struct te_assert *next; -}te_assert_t ; - -te_assert_t *te_assertions; -extern unsigned int policyvers;#endif
Signature · 1 line
2.24.1
PATCH v2 4/4 Makefile: always build with -fno-common
In reply to Ondrej MosnacekGCC 10 has it enabled by default and everything now builds OK with it, so add it to CFLAGS to avoid breaking the build in the future.
--- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Makefile +2 -1
@@ -16,7 +16,8 @@ else -Wstrict-prototypes \ -Wundef \ -Wunused \ - -Wwrite-strings + -Wwrite-strings \ + -fno-common endif ifneq ($(DESTDIR),)
Signature · 1 line
2.24.1
Re: [Non-DoD Source] [PATCH userspace v2 4/4] Makefile: always build with -fno-common
Quoted 4 lines · Ondrej Mosnacek
GCC 10 has it enabled by default and everything now builds OK with it, so add it to CFLAGS to avoid breaking the build in the future.
Signed-off-by Ondrej Mosnacek <[email protected]>
For all four patches,
Quoted 19 lines
--- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Makefile +2
-1@@ -16,7 +16,8 @@ else -Wstrict-prototypes \ -Wundef \ -Wunused \ - -Wwrite-strings + -Wwrite-strings \ + -fno-common endif ifneq ($(DESTDIR),)
Signature · 2 lines
James Carter <[email protected]> National Security Agency
Re: [PATCH userspace v2 4/4] Makefile: always build with -fno-common
In reply to Ondrej MosnacekQuoted 13 lines · Ondrej Mosnacek
GCC 10 has it enabled by default and everything now builds OK with it, so add it to CFLAGS to avoid breaking the build in the future.
Signed-off-by Ondrej Mosnacek <[email protected]>--- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Makefile +0
-0
Makefile else · line 23
Quoted 9 lines
Makefile +2
-1@@ -16,7 +16,8 @@ else -Wstrict-prototypes \ -Wundef \ -Wunused \ - -Wwrite-strings + -Wwrite-strings \ + -fno-common endif ifneq ($(DESTDIR),)
This change applies only when you run a build from root directory. Would it make sense to propagate it also to libsepol/src/Makefile and checkpolicy/Makefile so it's used when users builds components from released tar balls?
Quoted 3 lines · Ondrej Mosnacek
GCC 10 is going to enable -fno-common by default [1], so fix all build errors uncovered by it and add it to global CFLAGS to avoid introducing new bugs.
How far back does -fno-common go? Will this affect our minimum GCC version at all? I assume it wont but figured I'd ask just in case.
-- Jason
Quoted 27 lines
Changes in v2:
- remove also structte_assertdefinition, which is also useless
- redocil_mem_error_handlerto match commit4459d635b8f1as suggested by Jim CarterTravis build: [2]
[1] https://gcc.gnu.org/gcc-10/porting_to.html#common
[2] https://travis-ci.org/WOnder93/selinux/builds/640875119Ondrej Mosnacek (4):
libsepol: fix CIL_KEY_* build errors with -fno-common
libsepol: remove leftovers ofcil_mem_error_handler
checkpolicy: remove unusedte_assertions
Makefile: always build with -fno-commonMakefile | 3 +- checkpolicy/checkpolicy.h | 14 -- libsepol/cil/src/cil.c | 162 ++++++++++++++++ libsepol/cil/src/cil_internal.h | 322 ++++++++++++++++---------------- libsepol/cil/src/cil_mem.h | 1 - libsepol/cil/src/cil_strpool.c | 8 +- 6 files changed, 329 insertions(+), 181 deletions(-)Signature · 1 line
2.24.1
Quoted 7 lines · Jason Zaman
Quoted 3 lines · Ondrej Mosnacek
GCC 10 is going to enable -fno-common by default [1], so fix all build errors uncovered by it and add it to global CFLAGS to avoid introducing new bugs.
How far back does -fno-common go? Will this affect our minimum GCC version at all? I assume it wont but figured I'd ask just in case.
Good question... It looks like it's been around since at least 1996:
https://github.com/gcc-mirror/gcc/commit/9493f1421183f7c39598629fe60d37c599dfe2af
(That doesn't seem to be the commit that introduced it, but I hope it suffices as evidence :)
Quoted 31 lines
-- Jason
Quoted 27 lines
Changes in v2:
- remove also structte_assertdefinition, which is also useless
- redocil_mem_error_handlerto match commit4459d635b8f1as suggested by Jim CarterTravis build: [2]
[1] https://gcc.gnu.org/gcc-10/porting_to.html#common
[2] https://travis-ci.org/WOnder93/selinux/builds/640875119Ondrej Mosnacek (4):
libsepol: fix CIL_KEY_* build errors with -fno-common
libsepol: remove leftovers ofcil_mem_error_handler
checkpolicy: remove unusedte_assertions
Makefile: always build with -fno-commonMakefile | 3 +- checkpolicy/checkpolicy.h | 14 -- libsepol/cil/src/cil.c | 162 ++++++++++++++++ libsepol/cil/src/cil_internal.h | 322 ++++++++++++++++---------------- libsepol/cil/src/cil_mem.h | 1 - libsepol/cil/src/cil_strpool.c | 8 +- 6 files changed, 329 insertions(+), 181 deletions(-)--
2.24.1
Signature · 3 lines
Ondrej Mosnacek <omosnace at redhat dot com> Software Engineer, Security Technologies Red Hat, Inc.
Quoted 20 lines · Ondrej Mosnacek
GCC 10 is going to enable -fno-common by default [1], so fix all build errors uncovered by it and add it to global CFLAGS to avoid introducing new bugs.
Changes in v2:
- remove also structte_assertdefinition, which is also useless
- redocil_mem_error_handlerto match commit4459d635b8f1as suggested by Jim CarterTravis build: [2]
[1] https://gcc.gnu.org/gcc-10/porting_to.html#common
[2] https://travis-ci.org/WOnder93/selinux/builds/640875119Ondrej Mosnacek (4):
libsepol: fix CIL_KEY_* build errors with -fno-common
libsepol: remove leftovers ofcil_mem_error_handler
checkpolicy: remove unusedte_assertions
Makefile: always build with -fno-common
Quoted 8 lines
Makefile | 3 +- checkpolicy/checkpolicy.h | 14 -- libsepol/cil/src/cil.c | 162 ++++++++++++++++ libsepol/cil/src/cil_internal.h | 322 ++++++++++++++++---------------- libsepol/cil/src/cil_mem.h | 1 - libsepol/cil/src/cil_strpool.c | 8 +- 6 files changed, 329 insertions(+), 181 deletions(-)
This whole series was applied.
Thanks,
Jim
Signature · 2 lines
James Carter <[email protected]> National Security Agency