diff options
Diffstat (limited to 'net/key/af_key.c')
-rw-r--r-- | net/key/af_key.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/net/key/af_key.c b/net/key/af_key.c index 5502df115a63..17b2a6927f01 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c | |||
@@ -352,16 +352,14 @@ static int verify_address_len(void *p) | |||
352 | 352 | ||
353 | switch (addr->sa_family) { | 353 | switch (addr->sa_family) { |
354 | case AF_INET: | 354 | case AF_INET: |
355 | len = sizeof(*sp) + sizeof(*sin) + (sizeof(uint64_t) - 1); | 355 | len = DIV_ROUND_UP(sizeof(*sp) + sizeof(*sin), sizeof(uint64_t)); |
356 | len /= sizeof(uint64_t); | ||
357 | if (sp->sadb_address_len != len || | 356 | if (sp->sadb_address_len != len || |
358 | sp->sadb_address_prefixlen > 32) | 357 | sp->sadb_address_prefixlen > 32) |
359 | return -EINVAL; | 358 | return -EINVAL; |
360 | break; | 359 | break; |
361 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 360 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
362 | case AF_INET6: | 361 | case AF_INET6: |
363 | len = sizeof(*sp) + sizeof(*sin6) + (sizeof(uint64_t) - 1); | 362 | len = DIV_ROUND_UP(sizeof(*sp) + sizeof(*sin6), sizeof(uint64_t)); |
364 | len /= sizeof(uint64_t); | ||
365 | if (sp->sadb_address_len != len || | 363 | if (sp->sadb_address_len != len || |
366 | sp->sadb_address_prefixlen > 128) | 364 | sp->sadb_address_prefixlen > 128) |
367 | return -EINVAL; | 365 | return -EINVAL; |
@@ -386,14 +384,9 @@ static int verify_address_len(void *p) | |||
386 | 384 | ||
387 | static inline int pfkey_sec_ctx_len(struct sadb_x_sec_ctx *sec_ctx) | 385 | static inline int pfkey_sec_ctx_len(struct sadb_x_sec_ctx *sec_ctx) |
388 | { | 386 | { |
389 | int len = 0; | 387 | return DIV_ROUND_UP(sizeof(struct sadb_x_sec_ctx) + |
390 | 388 | sec_ctx->sadb_x_ctx_len, | |
391 | len += sizeof(struct sadb_x_sec_ctx); | 389 | sizeof(uint64_t)); |
392 | len += sec_ctx->sadb_x_ctx_len; | ||
393 | len += sizeof(uint64_t) - 1; | ||
394 | len /= sizeof(uint64_t); | ||
395 | |||
396 | return len; | ||
397 | } | 390 | } |
398 | 391 | ||
399 | static inline int verify_sec_ctx_len(void *p) | 392 | static inline int verify_sec_ctx_len(void *p) |