Skip to content

Commit acc6576

Browse files
dhowellstorvalds
authored andcommitted
keys, dns: Fix size check of V1 server-list header
Fix the size check added to dns_resolver_preparse() for the V1 server-list header so that it doesn't give EINVAL if the size supplied is the same as the size of the header struct (which should be valid). This can be tested with: echo -n -e '\0\0\01\xff\0\0' | keyctl padd dns_resolver desc @p which will give "add_key: Invalid argument" without this fix. Fixes: 1997b3c ("keys, dns: Fix missing size check of V1 server-list header") Reported-by: Pengfei Xu <[email protected]> Link: https://lore.kernel.org/r/[email protected]/ Signed-off-by: David Howells <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 0cb552a commit acc6576

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/dns_resolver/dns_key.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ dns_resolver_preparse(struct key_preparsed_payload *prep)
104104
const struct dns_server_list_v1_header *v1;
105105

106106
/* It may be a server list. */
107-
if (datalen <= sizeof(*v1))
107+
if (datalen < sizeof(*v1))
108108
return -EINVAL;
109109

110110
v1 = (const struct dns_server_list_v1_header *)data;

0 commit comments

Comments
 (0)