Linux Security Modules development
 help / color / mirror / Atom feed
* [PATCH -next] lockdown: Add break in lockdown_write
@ 2026-01-19  9:12 Cai Xinchen
  2026-01-22  9:31 ` Xiu Jianfeng
  0 siblings, 1 reply; 5+ messages in thread
From: Cai Xinchen @ 2026-01-19  9:12 UTC (permalink / raw)
  To: nicolas.bouchinet, xiujianfeng, paul, jmorris, serge
  Cc: linux-security-module, linux-kernel, caixinchen1

After the label is matched successful, any other levels judgements
are meaningless. Therefore, add break to return early

Signed-off-by: Cai Xinchen <caixinchen1@huawei.com>
---
 security/lockdown/lockdown.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/security/lockdown/lockdown.c b/security/lockdown/lockdown.c
index 8d46886d2cca..263dcc80d839 100644
--- a/security/lockdown/lockdown.c
+++ b/security/lockdown/lockdown.c
@@ -139,8 +139,10 @@ static ssize_t lockdown_write(struct file *file, const char __user *buf,
 		enum lockdown_reason level = lockdown_levels[i];
 		const char *label = lockdown_reasons[level];
 
-		if (label && !strcmp(state, label))
+		if (label && !strcmp(state, label)) {
 			err = lock_kernel_down("securityfs", level);
+			break;
+		}
 	}
 
 	kfree(state);
-- 
2.34.1


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

end of thread, other threads:[~2026-07-03  8:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-19  9:12 [PATCH -next] lockdown: Add break in lockdown_write Cai Xinchen
2026-01-22  9:31 ` Xiu Jianfeng
2026-01-22 17:41   ` Paul Moore
2026-07-02 16:50     ` Paul Moore
2026-07-03  7:39       ` Nicolas Bouchinet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox