Linux Security Modules development
 help / color / mirror / Atom feed
* [PATCH] lsm: Resolve compiling 'security.c' error
@ 2024-01-17  1:45 Lu Yao
  2024-01-17 14:32 ` Paul Moore
  0 siblings, 1 reply; 4+ messages in thread
From: Lu Yao @ 2024-01-17  1:45 UTC (permalink / raw)
  To: paul, jmorris, serge; +Cc: linux-security-module, linux-kernel, Lu Yao

The following error log is displayed during the current compilation
  > 'security/security.c:810:2: error: ‘memcpy’ offset 32 is
  > out of the bounds [0, 0] [-Werror=array-bounds]'

GCC version is '10.3.0 (Ubuntu 10.3.0-1ubuntu1~18.04~1)'

Signed-off-by: Lu Yao <yaolu@kylinos.cn>
---
 security/security.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/security/security.c b/security/security.c
index 0144a98d3712..37168f6bee25 100644
--- a/security/security.c
+++ b/security/security.c
@@ -792,7 +792,7 @@ int lsm_fill_user_ctx(struct lsm_ctx __user *uctx, size_t *uctx_len,
 	size_t nctx_len;
 	int rc = 0;
 
-	nctx_len = ALIGN(struct_size(nctx, ctx, val_len), sizeof(void *));
+	nctx_len = ALIGN(sizeof(struct lsm_ctx) + val_len, sizeof(void *));
 	if (nctx_len > *uctx_len) {
 		rc = -E2BIG;
 		goto out;
-- 
2.25.1


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

end of thread, other threads:[~2024-01-17 22:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-17  1:45 [PATCH] lsm: Resolve compiling 'security.c' error Lu Yao
2024-01-17 14:32 ` Paul Moore
2024-01-17 20:51   ` Kees Cook
2024-01-17 22:03     ` Paul Moore

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