Skip to contentSkip to conversation

lsm: align based on pointer length in lsm_fill_user_ctx()

PATCH Applied Paul Moore 2 participants 4 messages Nov 2, 2023 – Nov 13, 2023 Security (LSM)

lore
Share & tools
lore

Paul Moore

author maintainer
#0 lore raw

PATCH 1/1 lsm: align based on pointer length in lsm_fill_user_ctx()

Using the size of a void pointer is much cleaner than BITS_PER_LONG / 8.

---
 security/security.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/security.c +1 -1
index 86f7a1995991..a808fd5eba6d 100644
@@ -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), BITS_PER_LONG / 8);
+	nctx_len = ALIGN(struct_size(nctx, ctx, val_len), sizeof(void *));
 	if (nctx_len > *uctx_len) {
 		rc = -E2BIG;
 		goto out;
Signature · 1 line
2.42.0
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Paul Moore

Using the size of a void pointer is much cleaner than BITS_PER_LONG / 8.

Quoted 17 lines
---
 security/security.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/security.c +1 -1
index 86f7a1995991..a808fd5eba6d 100644
@@ -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), BITS_PER_LONG / 8);
+	nctx_len = ALIGN(struct_size(nctx, ctx, val_len), sizeof(void *));
 	if (nctx_len > *uctx_len) {
 		rc = -E2BIG;
 		goto out;
author maintainer Applied
#2 lore raw
In reply to Paul Moore
Quoted 8 lines · Paul Moore

Using the size of a void pointer is much cleaner than BITS_PER_LONG / 8.

---
 security/security.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Merged into lsm/dev-staging.

Signature · 1 line
paul-moore.com
author maintainer
#3 lore raw
Quoted 6 lines · Paul Moore
Quoted 4 lines · Paul Moore

Using the size of a void pointer is much cleaner than BITS_PER_LONG / 8.

Quoted 6 lines
Quoted 4 lines
---
 security/security.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Merged into lsm/dev-staging.

Now merged into lsm/dev.

Signature · 1 line
paul-moore.com