lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAB9W1A3kabX9qMm56k=FJ1jcL8ou4APqt8teT38oFCiu=g1wNg@mail.gmail.com>
Date:	Thu, 22 Jan 2015 14:05:43 -0500
From:	Stephen Smalley <stephen.smalley@...il.com>
To:	Ethan Zhao <ethan.kernel@...il.com>
Cc:	Manfred Spraul <manfred@...orfullife.com>,
	Stephen Smalley <sds@...ho.nsa.gov>,
	Ethan Zhao <ethan.zhao@...cle.com>,
	James Morris <james.l.morris@...cle.com>,
	"Serge E. Hallyn" <serge@...lyn.com>,
	Eric Paris <eparis@...isplace.org>,
	Paul Moore <paul@...l-moore.com>,
	selinux <selinux@...ho.nsa.gov>,
	linux-security-module@...r.kernel.org,
	LKML <linux-kernel@...r.kernel.org>, ethan.kernel@...il.conm
Subject: Re: [PATCH] Selinux/hooks.c: Fix a NULL pointer dereference caused by semop()

On Wed, Jan 21, 2015 at 9:44 PM, Ethan Zhao <ethan.kernel@...il.com> wrote:
> On Wed, Jan 21, 2015 at 1:30 PM, Manfred Spraul
> <manfred@...orfullife.com> wrote:
>> On 01/21/2015 04:53 AM, Ethan Zhao wrote:
>>>
>>> On Tue, Jan 20, 2015 at 10:10 PM, Stephen Smalley <sds@...ho.nsa.gov>
>>> wrote:
>>>>
>>>> On 01/20/2015 04:18 AM, Ethan Zhao wrote:
>>>>>
>>>>>       sys_semget()
>>>>>       ->newary()
>>>>>           ->security_sem_alloc()
>>>>>             ->sem_alloc_security()
>>>>>                   selinux_sem_alloc_security()
>>>>>                   ->ipc_alloc_security() {
>>>>>                     ->rc = avc_has_perm()
>>>>>                                if (rc) {
>>>>>
>>>>> ipc_free_security(&sma->sem_perm);
>>>>>                                        return rc;
>>>>
>>>> We free the security structure here to avoid a memory leak on a
>>>> failed/denied semaphore set creation.  In this situation, we return an
>>>> error to the caller (ultimately to newary), it does an
>>>> ipc_rcu_putref(sma, ipc_rcu_free), and it returns an error to the
>>>> caller.  Thus, it never calls ipc_addid() and the semaphore set is not
>>>> created.  So how then can you call semtimedop() on it?
>>>
>>> Seems it wouldn't happen after commit
>>> e8577d1f0329d4842e8302e289fb2c22156abef4 ?
>>
>> That was my first guess when I read the bug report - but it can't be the
>> fix, because security_sem_alloc() is before the ipc_addid(), with or without
>> the patch.
>>
>> thread A:
>>             thread B:
>>
>> semtimedop()
>> -> sem_obtain_object_check()
>>             semctl(IPC_RMID)
>>             -> freeary()
>>             -> ipc_rcu_putref()
>>             -> call_rcu()
>> -> somehow a grace period
>>             -> sem_rcu_free()
>>             -> security_sem_free()
>>
>> Perhaps: modify ipc_free_security() to hexdump perm and a few more bytes if
>> the pointer is NULL?
>
> I tried to ask for vmcore and do more analysis, basically, the race condition
> still exists and open a hole to be DoS.

You said the patch was tested with 3.19-rc5.  But did you reproduce
the bug on that kernel version before the patch?  If not, what kernel
version were you running when you triggered the bug?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ