From: Paul Moore Date: Tue, 24 Oct 2023 16:38:40 +0000 (-0400) Subject: lsm: cleanup the size counters in security_getselfattr() X-Git-Tag: v6.8-rc1~176^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc46db78b9747f8114030982ee5c2faf2faaeddd;p=thirdparty%2Fkernel%2Flinux.git lsm: cleanup the size counters in security_getselfattr() Zero out all of the size counters in the -E2BIG case (buffer too small) to help make the current code a bit more robust in the face of future code changes. Acked-by: Casey Schaufler Reviewed-by: Mickaël Salaün Signed-off-by: Paul Moore --- diff --git a/security/security.c b/security/security.c index 7281aa90ca202..74ff9a48bd66d 100644 --- a/security/security.c +++ b/security/security.c @@ -3950,8 +3950,9 @@ int security_getselfattr(unsigned int attr, struct lsm_ctx __user *uctx, continue; } if (rc == -E2BIG) { - toobig = true; + rc = 0; left = 0; + toobig = true; } else if (rc < 0) return rc; else