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]
Date:	Sun, 13 Apr 2008 13:36:24 +0200
From:	Manfred Spraul <manfred@...orfullife.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
CC:	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	"Serge E. Hallyn" <serue@...ibm.com>,
	"Eric W. Biederman" <ebiederm@...ssion.com>,
	Pavel Emelyanov <xemul@...nvz.org>,
	Sukadev Bhattiprolu <sukadev@...ibm.com>
Subject: Re: [PATCH 1/2] fix sys_unshare()+SEM_UNDO: add support for CLONE_SYSVSEM

Andrew Morton wrote:
> On Sun, 13 Apr 2008 10:04:17 +0200 Manfred Spraul <manfred@...orfullife.com> wrote:
>
>   
>> sys_unshare(CLONE_NEWIPC) doesn't handle the undo lists properly, this can
>> cause a kernel memory corruption. CLONE_NEWIPC must detach from the existing
>> undo lists.
>> Fix, part 1: add support for sys_unshare(CLONE_SYSVSEM)
>>
>>     
>
> Is this a non-back-compatible change?
>
>   
It adds a new feature - previously sys_unshare(CLONE_SYSVSEM) returned 
-EINVAL.

>> Signed-off-by: Manfred Spraul <manfred@...orfullife.com>
>> ---
>>  ipc/sem.c     |    1 +
>>  kernel/fork.c |   18 ++++++++++++++----
>>  2 files changed, 15 insertions(+), 4 deletions(-)
>>
>> diff --git a/ipc/sem.c b/ipc/sem.c
>> index 0b45a4d..35841bd 100644
>> --- a/ipc/sem.c
>> +++ b/ipc/sem.c
>> @@ -1298,6 +1298,7 @@ void exit_sem(struct task_struct *tsk)
>>  	undo_list = tsk->sysvsem.undo_list;
>>  	if (!undo_list)
>>  		return;
>> +	tsk->sysvsem.undo_list = NULL;
>>  
>>  	if (!atomic_dec_and_test(&undo_list->refcnt))
>>  		return;
>> diff --git a/kernel/fork.c b/kernel/fork.c
>> index 9c042f9..7f242b0 100644
>> --- a/kernel/fork.c
>> +++ b/kernel/fork.c
>> @@ -1675,13 +1675,17 @@ static int unshare_fd(unsigned long unshare_flags, struct files_struct **new_fdp
>>  }
>>  
>>  /*
>> - * Unsharing of semundo for tasks created with CLONE_SYSVSEM is not
>> - * supported yet
>> + * Unsharing of semundo for tasks created with CLONE_SYSVSEM doesn't require
>> + * any allocations: it means that the task leaves the existing undo lists,
>> + * just like sys_exit(). The new undo lists are allocated on demand in the
>> + * ipc syscalls.
>> + * new_ulistp is set to a non-NULL value, the caller expects that on success.
>>   */
>>  static int unshare_semundo(unsigned long unshare_flags, struct sem_undo_list **new_ulistp)
>>  {
>> -	if (unshare_flags & CLONE_SYSVSEM)
>> -		return -EINVAL;
>> +	if (unshare_flags & CLONE_SYSVSEM) {
>> +		*new_ulistp = (void*)1;
>> +	}
>>     
>
> And can we do anything nicer than this?
>
>   
Attached is an alternative. If you prefer it, I'll send another patch set.

--
    Manfred

View attachment "patch-step1-alternative" of type "text/plain" (2367 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ