[PATCH] cachefiles: return -EEXIST for a repeated secctx command
From: Jianping Liu
Date: Wed Oct 28 2026 - 05:35:02 EST
From: Jianping Liu <frankjpliu@xxxxxxxxxxx>
cachefiles_daemon_secctx() returns -EINVAL when a security context has
already been set. The same errno is used for an empty argument, so
userspace cannot tell the two failures apart.
Return -EEXIST instead, as cachefiles_daemon_dir() and
cachefiles_daemon_tag() do when their setting has already been given.
Fixes: 8667d434b2a9 ("cachefiles: Register a miscdev and parse commands over it")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Jianping Liu <frankjpliu@xxxxxxxxxxx>
---
fs/cachefiles/daemon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
index 1a66e0af2837..ef2ec7afd7cf 100644
--- a/fs/cachefiles/daemon.c
+++ b/fs/cachefiles/daemon.c
@@ -513,7 +513,7 @@ static int cachefiles_daemon_secctx(struct cachefiles_cache *cache, char *args)
if (cache->have_secid) {
pr_err("Second security context specified\n");
- return -EINVAL;
+ return -EEXIST;
}
err = security_secctx_to_secid(args, strlen(args), &cache->secid);
--
2.43.7