keys, dns: drop unused upayload->data NUL terminator
Subsystems (3)
PATCH RESEND 1/2 keys, dns: drop unused upayload->data NUL terminator
In dns_resolver_preparse(), do not NUL-terminate ->data and allocate one byte less. The NUL terminator is never used and only ->datalen bytes are accessed.
---
Resending this because patch 2/2 didn't go to netdev@ (Jakub)
Cc: [email protected]
--- net/dns_resolver/dns_key.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/dns_resolver/dns_key.c +1 -2
@@ -203,7 +203,7 @@ dns_resolver_preparse(struct key_preparsed_payload *prep)kdebug ("store result" ); prep->quotalen = result_len; - upayload =kmalloc_flex (*upayload, data, result_len +1 ); + upayload =kmalloc_flex (*upayload, data, result_len);if (!upayload) {kleave (" = -ENOMEM" );return -ENOMEM ;
@@ -211,7 +211,6 @@ dns_resolver_preparse(struct key_preparsed_payload *prep) upayload->datalen = result_len;memcpy (upayload->data, data, result_len); - upayload->data[result_len] ='\0' ; prep->payload.data[dns_key_data] = upayload;kleave (" = 0" );
PATCH RESEND 2/2 KEYS: annotate struct user_key_payload with __counted_by
Add the __counted_by() compiler attribute to the flexible array member 'data' to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE.
---
Resending this because patch 2/2 didn't go to netdev@ (Jakub)
Cc: [email protected]
--- include/keys/user-type.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/keys/user-type.h +2 -1
@@ -27,7 +27,8 @@struct user_key_payload {struct rcu_head rcu;/* RCU destructor */ unsigned short datalen;/* length of this data */ -char data[]__aligned(__alignof__(u64)) ;/* actual data */ + char data[] /* actual data */ +__aligned(__alignof__(u64)) __counted_by(datalen ); };extern struct key_type key_type_user;
David Howells
maintainerRe: [PATCH RESEND net-next 2/2] KEYS: annotate struct user_key_payload with __counted_by
include/keys/user-type.h line 31
Quoted 1 line · Thorsten Blum
include/keys/user-type.h +1
-0+__aligned(__alignof__(u64)) __counted_by (datalen);
Can that be __aligned(8)?
David
Re: [PATCH RESEND net-next 2/2] KEYS: annotate struct user_key_payload with __counted_by
Quoted 5 lines · David Howells
include/keys/user-type.h line 31
Quoted 1 line · Thorsten Blum
include/keys/user-type.h +1
-0+__aligned(__alignof__(u64)) __counted_by (datalen);Can that be
__aligned(8)?
Sure, I can send a v2 with __aligned(8).