Skip to contentSkip to conversation

seccomp: Fix setting number of loaded filters

PATCH In review Wiktor Garbacz 3 participants 3 messages Aug 10, 2021 – Aug 11, 2021 Secure computing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 seccomp: Fix setting number of loaded filters

The value is only reported through procfs so this
is purely cosmetic.

---
 kernel/seccomp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/seccomp.c +1 -1
index 057e17f3215d..6469eca8078c 100644
@@ -602,7 +602,7 @@ static inline void seccomp_sync_threads(unsigned long flags)
 		smp_store_release(&thread->seccomp.filter,
 				  caller->seccomp.filter);
 		atomic_set(&thread->seccomp.filter_count,
-			   atomic_read(&thread->seccomp.filter_count));
+			   atomic_read(&caller->seccomp.filter_count));
 
 		/*
 		 * Don't let an unprivileged task work around
Signature · 1 line
2.32.0.605.g8dce9f2422-goog
#1 lore raw
Quoted 2 lines · Wiktor Garbacz

The value is only reported through procfs so this
is purely cosmetic.

Hi,

Thanks for the patch! I thought this had already been fixed, but I see I dropped the ball. :( Sorry!

I'll get the original fix landed[1], and add you as a reporter.

Out of curiosity, how did you (or Hsuan-Chi Kuo) find this? Broken behavior, code reading, static analysis?

Thanks!

-Kees

[1] https://lore.kernel.org/lkml/[email protected]/

Quoted 22 lines
---
 kernel/seccomp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/seccomp.c +1 -1
index 057e17f3215d..6469eca8078c 100644
@@ -602,7 +602,7 @@ static inline void seccomp_sync_threads(unsigned long flags)
 		smp_store_release(&thread->seccomp.filter,
 				  caller->seccomp.filter);
 		atomic_set(&thread->seccomp.filter_count,
-			   atomic_read(&thread->seccomp.filter_count));
+			   atomic_read(&caller->seccomp.filter_count));
 
 		/*
 		 * Don't let an unprivileged task work around
Signature · 1 line
2.32.0.605.g8dce9f2422-goog
Signature · 1 line
Kees Cook
#2 lore raw

Thanks.

I was just trying to understand how seccomp works by code reading and spotted this bug.

Quoted 40 lines · Kees Cook
Quoted 2 lines · Wiktor Garbacz

The value is only reported through procfs so this
is purely cosmetic.

Hi,

Thanks for the patch! I thought this had already been fixed, but I see I dropped the ball. :( Sorry!

I'll get the original fix landed[1], and add you as a reporter.

Out of curiosity, how did you (or Hsuan-Chi Kuo) find this? Broken behavior, code reading, static analysis?

Thanks!

-Kees

[1] https://lore.kernel.org/lkml/[email protected]/

Quoted 21 lines
---
  kernel/seccomp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
kernel/seccomp.c +1 -1
index 057e17f3215d..6469eca8078c 100644
@@ -602,7 +602,7 @@ static inline void seccomp_sync_threads(unsigned long flags)
  		smp_store_release(&thread->seccomp.filter,
  				  caller->seccomp.filter);
  		atomic_set(&thread->seccomp.filter_count,
-			   atomic_read(&thread->seccomp.filter_count));
+			   atomic_read(&caller->seccomp.filter_count));
 
  		/*
  		 * Don't let an unprivileged task work around
Signature · 1 line
2.32.0.605.g8dce9f2422-goog