diff mbox series

lsm: align based on pointer length in lsm_fill_user_ctx()

Message ID 20231102015337.510827-2-paul@paul-moore.com (mailing list archive)
State Accepted
Delegated to: Paul Moore
Headers show
Series lsm: align based on pointer length in lsm_fill_user_ctx() | expand

Commit Message

Paul Moore Nov. 2, 2023, 1:53 a.m. UTC
Using the size of a void pointer is much cleaner than
BITS_PER_LONG / 8.

Signed-off-by: Paul Moore <paul@paul-moore.com>
---
 security/security.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Casey Schaufler Nov. 2, 2023, 4:42 p.m. UTC | #1
On 11/1/2023 6:53 PM, Paul Moore wrote:
> Using the size of a void pointer is much cleaner than
> BITS_PER_LONG / 8.
>
> Signed-off-by: Paul Moore <paul@paul-moore.com>

Acked-by: Casey Schaufler <casey@schaufler-ca.com>

> ---
>  security/security.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/security/security.c b/security/security.c
> index 86f7a1995991..a808fd5eba6d 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), BITS_PER_LONG / 8);
> +	nctx_len = ALIGN(struct_size(nctx, ctx, val_len), sizeof(void *));
>  	if (nctx_len > *uctx_len) {
>  		rc = -E2BIG;
>  		goto out;
Paul Moore Nov. 5, 2023, 11:24 p.m. UTC | #2
On Wed, Nov 1, 2023 at 9:53 PM Paul Moore <paul@paul-moore.com> wrote:
>
> Using the size of a void pointer is much cleaner than
> BITS_PER_LONG / 8.
>
> Signed-off-by: Paul Moore <paul@paul-moore.com>
> ---
>  security/security.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Merged into lsm/dev-staging.
Paul Moore Nov. 13, 2023, 4:08 a.m. UTC | #3
On Sun, Nov 5, 2023 at 6:24 PM Paul Moore <paul@paul-moore.com> wrote:
>
> On Wed, Nov 1, 2023 at 9:53 PM Paul Moore <paul@paul-moore.com> wrote:
> >
> > Using the size of a void pointer is much cleaner than
> > BITS_PER_LONG / 8.
> >
> > Signed-off-by: Paul Moore <paul@paul-moore.com>
> > ---
> >  security/security.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
>
> Merged into lsm/dev-staging.

Now merged into lsm/dev.
diff mbox series

Patch

diff --git a/security/security.c b/security/security.c
index 86f7a1995991..a808fd5eba6d 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), BITS_PER_LONG / 8);
+	nctx_len = ALIGN(struct_size(nctx, ctx, val_len), sizeof(void *));
 	if (nctx_len > *uctx_len) {
 		rc = -E2BIG;
 		goto out;