Re: keys: GPF in request_key
From: David Howells
Date: Wed Feb 01 2017 - 10:42:42 EST
Dmitry Vyukov <dvyukov@xxxxxxxxxx> wrote:
> >> I actually know what were the arguments to the syscall.
The program resolves to the attached C file. I can't see how you can tell
which of the six request_key() calls triggered.
Also, what OS are running this on? If you have PAM set up properly, none of
the request_key() calls should find a match since the key being added is
stored in the user_session keyring, but there should have been a session
keyring set up by PAM which would override that.
David
---
#include <sys/types.h>
#include <keyutils.h>
static const char type_1[] = "dead";
static const char type_2[] = "user";
static const char type_3[] = "\272eld";
static const char type_4[] = ".request_key_auth";
static const char type_5[] = "syzkaller";
static const char desc_1[] = "syz";
static const char desc_2[] = "syz\1";
static const char callout_1[] = "/dev/vcs#";
static const char callout_2[] = ")}]";
static const char payload_1[] = {
0x44, 0xeb, 0x63, 0xab, 0xd2, 0xdb, 0x6f, 0xd3, 0x4e, 0x9d, 0xfa, 0x7d, 0x35, 0x53, 0x90,
0x35, 0xf8, 0x8d, 0x7c, 0xbe, 0x94, 0x91, 0xcf, 0xb5, 0xb5, 0xe8, 0x93, 0x47, 0x32, 0x3e,
0x1f, 0x0f, 0x50, 0xd8, 0x07, 0x9f, 0x65, 0xf8, 0x9f, 0x4e, 0x2c, 0xa8, 0x58, 0xdb, 0xe4,
0x6c, 0x35, 0x7f, 0x96, 0x34, 0x89, 0x93, 0xc0, 0xb3, 0xea, 0xa0, 0x14, 0x18, 0x8f, 0xee,
0xb6, 0xae, 0x8b, 0x40, 0xd0, 0x36, 0x95, 0x34, 0x10, 0x17, 0xeb, 0xbe, 0x4d, 0xd6, 0x44,
0xf4, 0xcd, 0x78, 0x01, 0x63, 0x8a, 0x9e, 0xa9, 0xbf, 0x06, 0x0c, 0x32, 0xc7, 0x4a, 0x63,
0x34, 0x30, 0x5f, 0x57, 0x7a, 0xe7, 0xde, 0x87, 0x7e, 0x83, 0x4d, 0x70, 0x99, 0x23, 0x5d,
0x59, 0xd0, 0xa7, 0xd2, 0x3d, 0x02, 0x0f, 0x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 0xce, 0x08, 0xcb, 0xe6, 0xad, 0xb9,
0x36, 0x39, 0x9e, 0x3a, 0x1e, 0xb2, 0xf4, 0x7f, 0xa1, 0xb7, 0x98, 0x05, 0xaf, 0x18, 0x93,
0xa2, 0xda, 0xa1, 0xfe, 0x71, 0x9b, 0xe8, 0x7d, 0x0a, 0x4a, 0xb3, 0x91, 0x09, 0xe4, 0xa8,
0xee, 0x41, 0x7b, 0x3b, 0xee, 0x25, 0x53, 0xb9, 0x81, 0xef, 0xb6, 0x53, 0x09, 0x14, 0x9e,
0x68, 0xf0, 0x75, 0x03, 0xa9, 0x2e, 0xf5, 0xc4, 0x7a, 0x44, 0xb2, 0x54, 0x86, 0xbc, 0x08,
0xfa, 0x16, 0xbc, 0xd3, 0x5f, 0xe9, 0xdd, 0xd7, 0x34, 0x98, 0x8e, 0xe0, 0xa3, 0xd0, 0x2b,
0x8b, 0x4a, 0xec, 0xf4, 0x23, 0x3c
};
int main()
{
key_serial_t r24, r25, r26;
add_key(type_1, desc_1, payload_1, sizeof(payload_1), 0xffffffffffffffff);
r25 = request_key(type_2, desc_2, callout_1, 0xfffffffffffffffb);
add_key(type_5, desc_2, 0x0, 0x0, 0xfffffffffffffffb);
request_key(type_4, desc_1, callout_2, 0xfffffffffffffffb);
r26 = add_key(type_2, desc_2, payload_2, sizeof(payload_2), 0xfffffffffffffffb);
keyctl_unlink(r25, r26);
add_key(type_3, desc_1, payload_1, sizeof(payload_1) - 1, 0xffffffffffffffff);
r24 = request_key(type_2, desc_2, callout_1, 0xfffffffffffffffb);
add_key(type_5, desc_2, 0x0, 0x0, 0xfffffffffffffffb);
request_key(type_4, desc_1, callout_2, 0xfffffffffffffffb);
r25 = add_key(type_2, desc_2, payload_2, sizeof(payload_2), 0xfffffffffffffffb);
keyctl_unlink(r24, r25);
add_key(type_1, desc_1, payload_1, sizeof(payload_1) - 1, 0xffffffffffffffff);
r25 = request_key(type_2, desc_2, callout_1, 0xfffffffffffffffb);
add_key(type_5, desc_2, 0x0, 0x0, 0xfffffffffffffffb);
request_key(type_4, desc_1, callout_2, 0xfffffffffffffffb);
r26 = add_key(type_2, desc_2, payload_2, sizeof(payload_2), 0xfffffffffffffffb);
keyctl_unlink(r25, r26);
return 0;
}