Bug 627440 (CVE-2010-2960) - CVE-2010-2960 keyctl_session_to_parent NULL deref system crash
Summary: CVE-2010-2960 keyctl_session_to_parent NULL deref system crash
Keywords:
Status: ASSIGNED
Alias: CVE-2010-2960
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
high
high
Target Milestone: ---
Assignee: Nobody
QA Contact:
URL:
Whiteboard:
Depends On: 627807 627808
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-08-26 03:07 UTC by Eugene Teo (Security Response)
Modified: 2023-07-07 08:32 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Embargoed:


Attachments (Terms of Use)
Fix missing RCU read lock in keyctl_session_to_parent() (1.99 KB, patch)
2010-08-26 10:16 UTC, David Howells
no flags Details | Diff
Make a check of the parent session keyring's UID conditional (1.82 KB, patch)
2010-08-26 10:19 UTC, David Howells
no flags Details | Diff

Description Eugene Teo (Security Response) 2010-08-26 03:07:46 UTC
Description of problem:
Reported by Taviso Ormandy via the Ubuntu Security Team.

$ gcc keyctl.c -o keyctl -lkeyutils
$ ./keyctl
[ 213.999221] BUG: unable to handle kernel NULL pointer dereference at 00000034
[ 214.002770] IP: [<c02f0f2a>] keyctl_session_to_parent+0x12a/0x1c0
[ 214.006011] *pde = 0fdb0067 *pte = 00000000
[ 214.008007] Oops: 0000 [#1] SMP
[ 214.008973] last sysfs file: /sys/module/ppdev/initstate
[ 214.010466] Modules linked in: binfmt_misc vmblock vsock vmmemctl vmhgfs acpiphp snd_ens1371 gameport snd_ac97_codec ac97_bus snd_pcm_oss snd_mixer_oss snd_pcm snd_seq_dummy snd_seq_oss snd_seq_midi snd_rawmidi snd_seq_midi_event snd_seq snd_timer snd_seq_device ppdev fbcon tileblit font bitblit softcursor snd psmouse serio_raw parport_pc soundcore snd_page_alloc vmci shpchp i2c_piix4 vga16fb vgastate intel_agp agpgart lp parport mptspi mptscsih mptbase floppy scsi_transport_spi vmxnet
[ 214.024416]
[ 214.024899] Pid: 1772, comm: a.out Not tainted (2.6.32-24-generic #41-Ubuntu) VMware Virtual Platform
[ 214.027413] EIP: 0060:[<c02f0f2a>] EFLAGS: 00210046 CPU: 0
[ 214.028927] EIP is at keyctl_session_to_parent+0x12a/0x1c0
[ 214.030419] EAX: d2cde100 EBX: d2cdeb00 ECX: 000003e8 EDX: cfcfc480
[ 214.032132] ESI: cfddb300 EDI: 00000000 EBP: d2c33f94 ESP: d2c33f7c
[ 214.033811] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
[ 214.035292] Process a.out (pid: 1772, ti=d2c32000 task=d79bbfc0 task.ti=d2c32000)
[ 214.037346] Stack:
[ 214.037926] 00000000 000003e8 d2cde700 004370c0 00000012 08048520 d2c33fac c02f22e5
[ 214.040262] <0> 00000004 00000012 00327ff4 08048520 d2c32000 c01033ec 00000012 004370c0
[ 214.042795] <0> 0804852b 00327ff4 08048520 00000001 00000120 0000007b 0000007b 00000000
[ 214.045405] Call Trace:
[ 214.046108] [<c02f22e5>] ? sys_keyctl+0x65/0x170
[ 214.047434] [<c01033ec>] ? syscall_call+0x7/0xb
[ 214.048711] Code: 90 0f 85 77 ff ff ff 8b 7a 08 89 7d ec 3b 78 18 0f 85 68 ff ff ff 3b 7a 18 0f 85 5f ff ff ff 3b 7a 10 0f 85 56 ff ff ff 8b 7d e8 <3b> 4f 34 8d 76 00 0f 85 47 ff ff ff 8b 7d f0 3b 4f 34 0f 85 3b
[ 214.056401] EIP: [<c02f0f2a>] keyctl_session_to_parent+0x12a/0x1c0 SS:ESP 0068:d2c33f7c
[ 214.058676] CR2: 0000000000000034
[ 214.059605] ---[ end trace cc41d96061101854 ]---

Comment 3 David Howells 2010-08-26 09:58:54 UTC
This bit in keyctl_session_to_parent():

	/* the keyrings must have the same UID */
	if (pcred->tgcred->session_keyring->uid != mycred->euid ||
	    mycred->tgcred->session_keyring->uid != mycred->euid)
		goto not_permitted;

is the problem.  It assumes that the parent has a session keyring, which it may not, especially if pam_keyinit hasn't been invoked during the login procedure.

Comment 4 David Howells 2010-08-26 10:16:52 UTC
Created attachment 441164 [details]
Fix missing RCU read lock in keyctl_session_to_parent()

This patch fixes a missing RCU lock, but doesn't actually fix the bug.

Comment 5 David Howells 2010-08-26 10:19:07 UTC
Created attachment 441165 [details]
Make a check of the parent session keyring's UID conditional

The check of the parent's session keyring's UID should be conditional on the parent actually having a session keyring.  This is the fix for the reported bug.

Comment 9 Eugene Teo (Security Response) 2010-08-31 02:01:49 UTC
Acknowledgements:

Red Hat would like to thank Tavis Ormandy for reporting this issue.

Comment 10 Eugene Teo (Security Response) 2010-08-31 02:27:17 UTC
Statement:

This issue did not affect the version of Linux kernel as shipped with Red Hat
Enterprise Linux 3, 4, 5, and Red Hat Enterprise MRG as it did not include upstream commit ee18d64c that introduced the problem.

Comment 15 David Howells 2010-09-10 09:01:56 UTC
Pushed the patches to Linus.

Comment 16 Chuck Ebbert 2010-09-10 16:41:19 UTC
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff_plain;h=9d1ac65a9698513d00e5608d93fca0c53f536c14
"KEYS: Fix RCU no-lock warning in keyctl_session_to_parent()"

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff_plain;h=3d96406c7da1ed5811ea52a3b0905f4f0e295376
"KEYS: Fix bug in keyctl_session_to_parent() if parent has no session keyring"


Note You need to log in before you can comment on or make changes to this bug.