Skip to contentSkip to conversation

syscalls/capget02: Use pid=0 instead of getpid()

PATCH New Yang Xu 3 participants 6 messages Jan 9, 2020 – Jan 13, 2020

lore
Share & tools
lore

Yang Xu

author
#0 lore raw

PATCH 1/1 syscalls/capget02: Use pid=0 instead of getpid()

Since pid=0 returns the capabilities for the calling thread, we can remove getpid and use pid=0 instead of it. Also we can cover this test point.

---
 testcases/kernel/syscalls/capget/capget02.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
testcases/kernel/syscalls/capget/capget02.c +3 -5
index 42c76a011..0a23700b9 100644
@@ -69,15 +69,13 @@ static void verify_capget(unsigned int n)
 
 static void setup(void)
 {
-	unsigned int i, pid;
-
-	pid = getpid();
+	unsigned int i;
 
 	header.version = 0x19980330;
-	header.pid = pid;
+	header.pid = 0;
 
 	bad_version_header.version = 0;
-	bad_version_header.pid = pid;
+	bad_version_header.pid = 0;
 
 	bad_pid_header.version = 0x19980330;
 	bad_pid_header.pid = -1;
Signature · 1 line
2.18.0
author
#1 lore raw

PATCH 1/1 syscalls/capget02: Use pid=0 instead of getpid()

Hi

Quoted 3 lines

Since pid=0 returns the capabilities for the calling thread, we can remove getpid and use pid=0 instead of it. Also we can cover this test point.

Since I defined static struct, I think it doesn't need pid=0 assignment. I will send a v2 and add comment.

Quoted 30 lines
---
  testcases/kernel/syscalls/capget/capget02.c | 8 +++-----
  1 file changed, 3 insertions(+), 5 deletions(-)
testcases/kernel/syscalls/capget/capget02.c +3 -5
index 42c76a011..0a23700b9 100644
@@ -69,15 +69,13 @@ static void verify_capget(unsigned int n)
 
  static void setup(void)
  {
-	unsigned int i, pid;
-
-	pid = getpid();
+	unsigned int i;
 
  	header.version = 0x19980330;
-	header.pid = pid;
+	header.pid = 0;
 
  	bad_version_header.version = 0;
-	bad_version_header.pid = pid;
+	bad_version_header.pid = 0;
 
  	bad_pid_header.version = 0x19980330;
  	bad_pid_header.pid = -1;
#2 lore raw

PATCH 1/1 syscalls/capget02: Use pid=0 instead of getpid()

Hi!

Quoted 5 lines
Quoted 3 lines

Since pid=0 returns the capabilities for the calling thread, we can remove getpid and use pid=0 instead of it. Also we can cover this test point.

Since I defined static struct, I think it doesn't need pid=0 assignment. I will send a v2 and add comment.

If you are at it, can you also allocate guarded buffers instead?

https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines#2231-guarded-buffers

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#3 lore raw

PATCH 1/1 syscalls/capget02: Use pid=0 instead of getpid()

Hi!> Hi!

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Since pid=0 returns the capabilities for the calling thread, we can remove getpid and use pid=0 instead of it. Also we can cover this test point.

Since I defined static struct, I think it doesn't need pid=0 assignment. I will send a v2 and add comment.

If you are at it, can you also allocate guarded buffers instead?

Sure, I will use guarded buffers instead.

Quoted 3 lines

https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines#2231-guarded-buffers

author
#5 lore raw

PATCH 1/1 syscalls/capget02: Use pid=0 instead of getpid()

Hi

Quoted 6 lines

Hi,

FYI this was replaced by
https://patchwork.ozlabs.org/patch/1220805/
and merged as ad57b6090 syscalls/capget[set]: Make use of guarded buffers

Thanks for your review and merge.

Best Regards
Yang Xu

Quoted 5 lines

Kind regards,
Petr