All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] SELinux testsuite compilation fixes
@ 2015-06-04 19:41 Paul Moore
  2015-06-04 19:41 ` [PATCH 1/6] selinux-testsuite: add _GNU_SOURCE to tests/Makefile Paul Moore
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Paul Moore @ 2015-06-04 19:41 UTC (permalink / raw)
  To: selinux

A collection of compilation fixes.

---

Paul Moore (6):
      selinux-testsuite: add _GNU_SOURCE to tests/Makefile
      selinux-testsuite: add some default CFLAGS
      selinux-testsuite: fix some compile warnings in tests/nnp
      selinux-testsuite: fix compile warnings in tests/setnice
      selinux-testsuite: fix compile problems in tests/shm
      selinux-testsuite: fix compile problems in tests/capable_file


 tests/Makefile                  |    3 +++
 tests/capable_file/test_lease.c |    9 +++++----
 tests/msg/msgrcv.c              |    5 -----
 tests/msg/msgsnd.c              |    5 -----
 tests/nnp/execnnp.c             |    2 ++
 tests/setnice/parent.c          |    2 ++
 tests/shm/shmat.c               |    6 +-----
 tests/shm/shmctl.c              |    6 +-----
 tests/shm/shmget.c              |    6 +-----
 9 files changed, 15 insertions(+), 29 deletions(-)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/6] selinux-testsuite: add _GNU_SOURCE to tests/Makefile
  2015-06-04 19:41 [PATCH v2 0/6] SELinux testsuite compilation fixes Paul Moore
@ 2015-06-04 19:41 ` Paul Moore
  2015-06-04 19:50   ` Stephen Smalley
  2015-06-04 19:41 ` [PATCH 2/6] selinux-testsuite: add some default CFLAGS Paul Moore
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: Paul Moore @ 2015-06-04 19:41 UTC (permalink / raw)
  To: selinux

As suggested by Stephen Smalley.  A couple of msgbuf struct
definitions had to be removed as they were conflicting with system
definitions.

Signed-off-by: Paul Moore <paul@paul-moore.com>
---
 tests/Makefile     |    3 +++
 tests/msg/msgrcv.c |    5 -----
 tests/msg/msgsnd.c |    5 -----
 3 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/tests/Makefile b/tests/Makefile
index e9d4646..8100b8f 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,3 +1,6 @@
+
+export CFLAGS+=-D_GNU_SOURCE
+
 DISTRO=$(shell ./os_detect)
 
 SUBDIRS_COMMON:=domain_trans entrypoint execshare exectrace execute_no_trans fdreceive inherit link mkdir msg open ptrace readlink relabel rename rxdir sem setattr setnice shm sigkill stat sysctl task_create task_setnice task_setscheduler task_getscheduler task_getsid task_getpgid task_setpgid wait file ioctl capable_file capable_net capable_sys
diff --git a/tests/msg/msgrcv.c b/tests/msg/msgrcv.c
index b23c801..285dcad 100644
--- a/tests/msg/msgrcv.c
+++ b/tests/msg/msgrcv.c
@@ -6,11 +6,6 @@
 
 #define MSGMAX 1024
 
-struct msgbuf {
-  long mtype;     /* message type, must be > 0 */
-  char mtext[1024];  /* message data */
-};
-
 int main(int argc, char **argv)
 {
 	int ch;
diff --git a/tests/msg/msgsnd.c b/tests/msg/msgsnd.c
index e200aef..7204ab6 100644
--- a/tests/msg/msgsnd.c
+++ b/tests/msg/msgsnd.c
@@ -7,11 +7,6 @@
 
 #define MSGMAX 1024
 
-struct msgbuf {
-  long mtype;     /* message type, must be > 0 */
-  char mtext[1024];  /* message data */
-};
-
 int main(int argc, char **argv)
 {
 	int ch;

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/6] selinux-testsuite: add some default CFLAGS
  2015-06-04 19:41 [PATCH v2 0/6] SELinux testsuite compilation fixes Paul Moore
  2015-06-04 19:41 ` [PATCH 1/6] selinux-testsuite: add _GNU_SOURCE to tests/Makefile Paul Moore
@ 2015-06-04 19:41 ` Paul Moore
  2015-06-04 19:42 ` [PATCH 3/6] selinux-testsuite: fix some compile warnings in tests/nnp Paul Moore
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Paul Moore @ 2015-06-04 19:41 UTC (permalink / raw)
  To: selinux

Signed-off-by: Paul Moore <paul@paul-moore.com>
---
 tests/Makefile |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/Makefile b/tests/Makefile
index 8100b8f..b679137 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,5 +1,5 @@
 
-export CFLAGS+=-D_GNU_SOURCE
+export CFLAGS+=-g -O0 -Wall -D_GNU_SOURCE
 
 DISTRO=$(shell ./os_detect)
 

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/6] selinux-testsuite: fix some compile warnings in tests/nnp
  2015-06-04 19:41 [PATCH v2 0/6] SELinux testsuite compilation fixes Paul Moore
  2015-06-04 19:41 ` [PATCH 1/6] selinux-testsuite: add _GNU_SOURCE to tests/Makefile Paul Moore
  2015-06-04 19:41 ` [PATCH 2/6] selinux-testsuite: add some default CFLAGS Paul Moore
@ 2015-06-04 19:42 ` Paul Moore
  2015-06-04 19:42 ` [PATCH 4/6] selinux-testsuite: fix compile warnings in tests/setnice Paul Moore
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Paul Moore @ 2015-06-04 19:42 UTC (permalink / raw)
  To: selinux

Correct the following:

make[2]: Entering directory '/root/sources/selinux-testsuite/tests/nnp'
cc     execnnp.c  -lselinux -o execnnp
execnnp.c: In function 'main':
execnnp.c:27:9: warning: implicit declaration of function 'strverscmp'
        (strverscmp(uts.release, "3.18") < 0));
         ^
execnnp.c:47:8: warning: implicit declaration of function 'wait'
  pid = wait(&status);

Signed-off-by: Paul Moore <paul@paul-moore.com>
---
 tests/nnp/execnnp.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/nnp/execnnp.c b/tests/nnp/execnnp.c
index a5a80cf..756c2d0 100644
--- a/tests/nnp/execnnp.c
+++ b/tests/nnp/execnnp.c
@@ -5,6 +5,8 @@
 #include <unistd.h>
 #include <sys/utsname.h>
 #include <sys/prctl.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 
 int main(int argc, char **argv)
 {

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/6] selinux-testsuite: fix compile warnings in tests/setnice
  2015-06-04 19:41 [PATCH v2 0/6] SELinux testsuite compilation fixes Paul Moore
                   ` (2 preceding siblings ...)
  2015-06-04 19:42 ` [PATCH 3/6] selinux-testsuite: fix some compile warnings in tests/nnp Paul Moore
@ 2015-06-04 19:42 ` Paul Moore
  2015-06-04 19:42 ` [PATCH 5/6] selinux-testsuite: fix compile problems in tests/shm Paul Moore
  2015-06-04 19:42 ` [PATCH 6/6] selinux-testsuite: fix compile problems in tests/capable_file Paul Moore
  5 siblings, 0 replies; 9+ messages in thread
From: Paul Moore @ 2015-06-04 19:42 UTC (permalink / raw)
  To: selinux

Correct the following:

make[2]: Entering directory '/root/sources/selinux-testsuite/tests/setnice'
cc     parent.c  -lselinux -o parent
parent.c: In function 'main':
parent.c:92:9: warning: implicit declaration of function 'setpriority'
   rc =  setpriority(0,pid,10);
         ^

Signed-off-by: Paul Moore <paul@paul-moore.com>
---
 tests/setnice/parent.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/setnice/parent.c b/tests/setnice/parent.c
index d5a2533..6d3c855 100644
--- a/tests/setnice/parent.c
+++ b/tests/setnice/parent.c
@@ -3,6 +3,8 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <sys/time.h>
+#include <sys/resource.h>
 #include <signal.h>
 #include <selinux/selinux.h>
 #include <selinux/context.h>

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 5/6] selinux-testsuite: fix compile problems in tests/shm
  2015-06-04 19:41 [PATCH v2 0/6] SELinux testsuite compilation fixes Paul Moore
                   ` (3 preceding siblings ...)
  2015-06-04 19:42 ` [PATCH 4/6] selinux-testsuite: fix compile warnings in tests/setnice Paul Moore
@ 2015-06-04 19:42 ` Paul Moore
  2015-06-04 19:42 ` [PATCH 6/6] selinux-testsuite: fix compile problems in tests/capable_file Paul Moore
  5 siblings, 0 replies; 9+ messages in thread
From: Paul Moore @ 2015-06-04 19:42 UTC (permalink / raw)
  To: selinux

Resolve the following problems:

make[2]: Entering directory '/home/pmoore/sources/selinux-testsuite/selinux_testsuite-upstream/tests/shm'
cc -g -O0 -Wall -D_GNU_SOURCE    shmctl.c   -o shmctl
shmctl.c: In function 'main':
shmctl.c:11:6: warning: variable 'num' set but not used
  int num = 1;
      ^
cc -g -O0 -Wall -D_GNU_SOURCE    shmat.c   -o shmat
shmat.c: In function 'main':
shmat.c:11:6: warning: variable 'num' set but not used
  int num = 1;
      ^
cc -g -O0 -Wall -D_GNU_SOURCE    shmget.c   -o shmget
shmget.c: In function 'main':
shmget.c:11:6: warning: variable 'num' set but not used
  int num = 1;
      ^

Signed-off-by: Paul Moore <paul@paul-moore.com>
---
 tests/shm/shmat.c  |    6 +-----
 tests/shm/shmctl.c |    6 +-----
 tests/shm/shmget.c |    6 +-----
 3 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/tests/shm/shmat.c b/tests/shm/shmat.c
index 89ac299..704d676 100644
--- a/tests/shm/shmat.c
+++ b/tests/shm/shmat.c
@@ -8,20 +8,16 @@
 int main(int argc, char **argv)
 {
 	int ch;
-	int num = 1;
 	int key = 0x8888;
 	int id;
 	int error;
 	char *buf;
 
-	while ((ch = getopt(argc, argv, "k:-n:")) != -1) {
+	while ((ch = getopt(argc, argv, "k:")) != -1) {
 		switch (ch) {
 		case 'k':
 			key = atoi(optarg);
 			break;
-		case 'n':
-			num = atoi(optarg);
-			break;
 		}
 	}
 
diff --git a/tests/shm/shmctl.c b/tests/shm/shmctl.c
index 78397b6..d17a804 100644
--- a/tests/shm/shmctl.c
+++ b/tests/shm/shmctl.c
@@ -8,20 +8,16 @@
 int main(int argc, char **argv)
 {
 	int ch;
-	int num = 1;
 	int key = 0x8888;
 	int id;
 	int error;
 	struct shmid_ds buf;
 
-	while ((ch = getopt(argc, argv, "k:-n:")) != -1) {
+	while ((ch = getopt(argc, argv, "k:")) != -1) {
 		switch (ch) {
 		case 'k':
 			key = atoi(optarg);
 			break;
-		case 'n':
-			num = atoi(optarg);
-			break;
 		}
 	}
 
diff --git a/tests/shm/shmget.c b/tests/shm/shmget.c
index a04da25..42d6394 100644
--- a/tests/shm/shmget.c
+++ b/tests/shm/shmget.c
@@ -8,18 +8,14 @@
 int main(int argc, char **argv)
 {
 	int ch;
-	int num = 1;
 	int key = 0x8888;
 	int id;
 
-	while ((ch = getopt(argc, argv, "k:-n:")) != -1) {
+	while ((ch = getopt(argc, argv, "k:")) != -1) {
 		switch (ch) {
 		case 'k':
 			key = atoi(optarg);
 			break;
-		case 'n':
-			num = atoi(optarg);
-			break;
 		}
 	}
 

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 6/6] selinux-testsuite: fix compile problems in tests/capable_file
  2015-06-04 19:41 [PATCH v2 0/6] SELinux testsuite compilation fixes Paul Moore
                   ` (4 preceding siblings ...)
  2015-06-04 19:42 ` [PATCH 5/6] selinux-testsuite: fix compile problems in tests/shm Paul Moore
@ 2015-06-04 19:42 ` Paul Moore
  5 siblings, 0 replies; 9+ messages in thread
From: Paul Moore @ 2015-06-04 19:42 UTC (permalink / raw)
  To: selinux

Fix the following warnings:

make[2]: Entering directory '/home/pmoore/sources/selinux-testsuite/selinux_testsuite-upstream/tests/capable_file'
cc -g -O0 -Wall -D_GNU_SOURCE    test_lease.c   -o test_lease
test_lease.c: In function 'main':
test_lease.c:22:3: warning: implicit declaration of function 'open'
   fd = open(argv[1], O_RDONLY, 0);
   ^
test_lease.c:29:3: warning: implicit declaration of function 'fcntl'
   rc = fcntl(fd, F_SETLEASE, 0);
   ^

Signed-off-by: Paul Moore <paul@paul-moore.com>
---
 tests/capable_file/test_lease.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/tests/capable_file/test_lease.c b/tests/capable_file/test_lease.c
index 606d75c..e8f29eb 100644
--- a/tests/capable_file/test_lease.c
+++ b/tests/capable_file/test_lease.c
@@ -1,9 +1,10 @@
-#include<stdio.h>
-#include<stdlib.h>
-#include<sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <linux/posix_types.h>
-#include<linux/fcntl.h>
 #include <unistd.h>
+#include <fcntl.h>
 
 /*
  * Test the fcntl F_SETLEASE operation on a file whose name is given as 

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/6] selinux-testsuite: add _GNU_SOURCE to tests/Makefile
  2015-06-04 19:41 ` [PATCH 1/6] selinux-testsuite: add _GNU_SOURCE to tests/Makefile Paul Moore
@ 2015-06-04 19:50   ` Stephen Smalley
  2015-06-04 20:50     ` Paul Moore
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Smalley @ 2015-06-04 19:50 UTC (permalink / raw)
  To: Paul Moore, selinux

On 06/04/2015 03:41 PM, Paul Moore wrote:
> As suggested by Stephen Smalley.  A couple of msgbuf struct
> definitions had to be removed as they were conflicting with system
> definitions.
> 
> Signed-off-by: Paul Moore <paul@paul-moore.com>
> ---
>  tests/Makefile     |    3 +++
>  tests/msg/msgrcv.c |    5 -----
>  tests/msg/msgsnd.c |    5 -----
>  3 files changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/tests/Makefile b/tests/Makefile
> index e9d4646..8100b8f 100644
> --- a/tests/Makefile
> +++ b/tests/Makefile
> @@ -1,3 +1,6 @@
> +
> +export CFLAGS+=-D_GNU_SOURCE
> +
>  DISTRO=$(shell ./os_detect)
>  
>  SUBDIRS_COMMON:=domain_trans entrypoint execshare exectrace execute_no_trans fdreceive inherit link mkdir msg open ptrace readlink relabel rename rxdir sem setattr setnice shm sigkill stat sysctl task_create task_setnice task_setscheduler task_getscheduler task_getsid task_getpgid task_setpgid wait file ioctl capable_file capable_net capable_sys
> diff --git a/tests/msg/msgrcv.c b/tests/msg/msgrcv.c
> index b23c801..285dcad 100644
> --- a/tests/msg/msgrcv.c
> +++ b/tests/msg/msgrcv.c
> @@ -6,11 +6,6 @@
>  
>  #define MSGMAX 1024
>  
> -struct msgbuf {
> -  long mtype;     /* message type, must be > 0 */
> -  char mtext[1024];  /* message data */
> -};
> -

This doesn't seem right.  I see that the _GNU_SOURCE definition triggers
inclusion of a struct msgbuf definition from sys/msg.h, but that
definition doesn't allocate any space for the mtext buffer.  So then
when we try to msgsnd() or msgrcv() with MSGMAX, we'll be
reading/writing memory past the end of the structure?

Maybe you were right the first time, sorry.

>  int main(int argc, char **argv)
>  {
>  	int ch;
> diff --git a/tests/msg/msgsnd.c b/tests/msg/msgsnd.c
> index e200aef..7204ab6 100644
> --- a/tests/msg/msgsnd.c
> +++ b/tests/msg/msgsnd.c
> @@ -7,11 +7,6 @@
>  
>  #define MSGMAX 1024
>  
> -struct msgbuf {
> -  long mtype;     /* message type, must be > 0 */
> -  char mtext[1024];  /* message data */
> -};
> -
>  int main(int argc, char **argv)
>  {
>  	int ch;
> 
> _______________________________________________
> Selinux mailing list
> Selinux@tycho.nsa.gov
> To unsubscribe, send email to Selinux-leave@tycho.nsa.gov.
> To get help, send an email containing "help" to Selinux-request@tycho.nsa.gov.
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/6] selinux-testsuite: add _GNU_SOURCE to tests/Makefile
  2015-06-04 19:50   ` Stephen Smalley
@ 2015-06-04 20:50     ` Paul Moore
  0 siblings, 0 replies; 9+ messages in thread
From: Paul Moore @ 2015-06-04 20:50 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: selinux

On Thu, Jun 4, 2015 at 3:50 PM, Stephen Smalley <sds@tycho.nsa.gov> wrote:
> On 06/04/2015 03:41 PM, Paul Moore wrote:
>> diff --git a/tests/msg/msgrcv.c b/tests/msg/msgrcv.c
>> index b23c801..285dcad 100644
>> --- a/tests/msg/msgrcv.c
>> +++ b/tests/msg/msgrcv.c
>> @@ -6,11 +6,6 @@
>>
>>  #define MSGMAX 1024
>>
>> -struct msgbuf {
>> -  long mtype;     /* message type, must be > 0 */
>> -  char mtext[1024];  /* message data */
>> -};
>> -
>
> This doesn't seem right.  I see that the _GNU_SOURCE definition triggers
> inclusion of a struct msgbuf definition from sys/msg.h, but that
> definition doesn't allocate any space for the mtext buffer.  So then
> when we try to msgsnd() or msgrcv() with MSGMAX, we'll be
> reading/writing memory past the end of the structure?
>
> Maybe you were right the first time, sorry.

My mistake, I should have looked closer then I saw the conflict; I was
rushing to get some other things sorted and did something stupid,
thanks for the sanity check.

I like your idea of defining _GNU_SOURCE at a higher level, I think
the right solution here is to just rename our local definition of the
msgbuf struct.  A new patchset due shortly ...

-- 
paul moore
www.paul-moore.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-06-04 20:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-04 19:41 [PATCH v2 0/6] SELinux testsuite compilation fixes Paul Moore
2015-06-04 19:41 ` [PATCH 1/6] selinux-testsuite: add _GNU_SOURCE to tests/Makefile Paul Moore
2015-06-04 19:50   ` Stephen Smalley
2015-06-04 20:50     ` Paul Moore
2015-06-04 19:41 ` [PATCH 2/6] selinux-testsuite: add some default CFLAGS Paul Moore
2015-06-04 19:42 ` [PATCH 3/6] selinux-testsuite: fix some compile warnings in tests/nnp Paul Moore
2015-06-04 19:42 ` [PATCH 4/6] selinux-testsuite: fix compile warnings in tests/setnice Paul Moore
2015-06-04 19:42 ` [PATCH 5/6] selinux-testsuite: fix compile problems in tests/shm Paul Moore
2015-06-04 19:42 ` [PATCH 6/6] selinux-testsuite: fix compile problems in tests/capable_file Paul Moore

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.