diff mbox series

[1/2] ipe: return -ESTALE instead of -EINVAL on update when new policy has a lower version

Message ID 20240922135614.197694-1-luca.boccassi@gmail.com (mailing list archive)
State Handled Elsewhere
Headers show
Series [1/2] ipe: return -ESTALE instead of -EINVAL on update when new policy has a lower version | expand

Commit Message

Luca Boccassi Sept. 22, 2024, 1:56 p.m. UTC
From: Luca Boccassi <bluca@debian.org>

When loading policies in userspace we want a recognizable error when an
update attempts to use an old policy, as that is an error that needs
to be treated differently from an invalid policy. Use -ESTALE as it is
clear enough for an update mechanism.

Signed-off-by: Luca Boccassi <bluca@debian.org>
---
Found while adding policy loading to systemd, like we do for IMA/SELinux
https://github.com/systemd/systemd/pull/34418

 security/ipe/policy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/security/ipe/policy.c b/security/ipe/policy.c
index 67a051620889..5de64441dfe7 100644
--- a/security/ipe/policy.c
+++ b/security/ipe/policy.c
@@ -116,7 +116,7 @@  int ipe_update_policy(struct inode *root, const char *text, size_t textlen,
 	}
 
 	if (ver_to_u64(old) > ver_to_u64(new)) {
-		rc = -EINVAL;
+		rc = -ESTALE;
 		goto err;
 	}