Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/jmorris/security-testing-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6:
  DNS: Fix a NULL pointer deref when trying to read an error key [CVE-2011-1076]
  • Loading branch information
torvalds committed Mar 3, 2011
2 parents 4438a02 + 1362fa0 commit b65a0e0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
9 changes: 8 additions & 1 deletion Documentation/networking/dns_resolver.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ before the more general line given above as the first match is the one taken.
create dns_resolver foo:* * /usr/sbin/dns.foo %k



=====
USAGE
=====
Expand Down Expand Up @@ -104,6 +103,14 @@ implemented in the module can be called after doing:
returned also.


===============================
READING DNS KEYS FROM USERSPACE
===============================

Keys of dns_resolver type can be read from userspace using keyctl_read() or
"keyctl read/print/pipe".


=========
MECHANISM
=========
Expand Down
20 changes: 17 additions & 3 deletions net/dns_resolver/dns_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ dns_resolver_instantiate(struct key *key, const void *_data, size_t datalen)
size_t result_len = 0;
const char *data = _data, *end, *opt;

kenter("%%%d,%s,'%s',%zu",
key->serial, key->description, data, datalen);
kenter("%%%d,%s,'%*.*s',%zu",
key->serial, key->description,
(int)datalen, (int)datalen, data, datalen);

if (datalen <= 1 || !data || data[datalen - 1] != '\0')
return -EINVAL;
Expand Down Expand Up @@ -217,14 +218,27 @@ static void dns_resolver_describe(const struct key *key, struct seq_file *m)
seq_printf(m, ": %u", key->datalen);
}

/*
* read the DNS data
* - the key's semaphore is read-locked
*/
static long dns_resolver_read(const struct key *key,
char __user *buffer, size_t buflen)
{
if (key->type_data.x[0])
return key->type_data.x[0];

return user_read(key, buffer, buflen);
}

struct key_type key_type_dns_resolver = {
.name = "dns_resolver",
.instantiate = dns_resolver_instantiate,
.match = dns_resolver_match,
.revoke = user_revoke,
.destroy = user_destroy,
.describe = dns_resolver_describe,
.read = user_read,
.read = dns_resolver_read,
};

static int __init init_dns_resolver(void)
Expand Down

0 comments on commit b65a0e0

Please sign in to comment.