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: <AM6PR03MB5170412C2B0318C40CED55E5E4F10@AM6PR03MB5170.eurprd03.prod.outlook.com>
Date:   Fri, 4 Dec 2020 17:08:01 +0100
From:   Bernd Edlinger <bernd.edlinger@...mail.de>
To:     "Eric W. Biederman" <ebiederm@...ssion.com>,
        linux-kernel@...r.kernel.org
Cc:     Linus Torvalds <torvalds@...ux-foundation.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>, Will Deacon <will@...nel.org>,
        Jann Horn <jannh@...gle.com>,
        Vasiliy Kulikov <segoon@...nwall.com>,
        Al Viro <viro@...iv.linux.org.uk>,
        Oleg Nesterov <oleg@...hat.com>,
        Christopher Yeoh <cyeoh@....ibm.com>,
        Cyrill Gorcunov <gorcunov@...il.com>,
        Sargun Dhillon <sargun@...gun.me>,
        Christian Brauner <christian.brauner@...ntu.com>,
        Arnd Bergmann <arnd@...db.de>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Waiman Long <longman@...hat.com>,
        Davidlohr Bueso <dave@...olabs.net>
Subject: Re: [PATCH 3/3] exec: Transform exec_update_mutex into a rw_semaphore

Hi Eric,

I think I remembered from a previous discussion about this topic,
that it was unclear if the rw_semaphores are working the same
in RT-Linux.  Will this fix work in RT as well?

On 12/3/20 9:12 PM, Eric W. Biederman wrote:
> --- a/kernel/kcmp.c
> +++ b/kernel/kcmp.c
> @@ -70,25 +70,25 @@ get_file_raw_ptr(struct task_struct *task, unsigned int idx)
>  	return file;
>  }
>  
> -static void kcmp_unlock(struct mutex *m1, struct mutex *m2)
> +static void kcmp_unlock(struct rw_semaphore *l1, struct rw_semaphore *l2)
>  {
> -	if (likely(m2 != m1))
> -		mutex_unlock(m2);
> -	mutex_unlock(m1);
> +	if (likely(l2 != l1))

is this still necessary ?

> +		up_read(l2);
> +	up_read(l1);
>  }
>  
> -static int kcmp_lock(struct mutex *m1, struct mutex *m2)
> +static int kcmp_lock(struct rw_semaphore *l1, struct rw_semaphore *l2)
>  {
>  	int err;
>  
> -	if (m2 > m1)
> -		swap(m1, m2);
> +	if (l2 > l1)
> +		swap(l1, l2);

and this is probably also no longer necessary?


>  
> -	err = mutex_lock_killable(m1);
> -	if (!err && likely(m1 != m2)) {
> -		err = mutex_lock_killable_nested(m2, SINGLE_DEPTH_NESTING);
> +	err = down_read_killable(l1);
> +	if (!err && likely(l1 != l2)) {

and this can now be unconditionally, right?

> +		err = down_read_killable_nested(l2, SINGLE_DEPTH_NESTING);
>  		if (err)
> -			mutex_unlock(m1);
> +			up_read(l1);
>  	}
>  
>  	return err;
> @@ -156,8 +156,8 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
>  	/*
>  	 * One should have enough rights to inspect task details.
>  	 */
> -	ret = kcmp_lock(&task1->signal->exec_update_mutex,
> -			&task2->signal->exec_update_mutex);
> +	ret = kcmp_lock(&task1->signal->exec_update_lock,
> +			&task2->signal->exec_update_lock);
>  	if (ret)
>  		goto err;
>  	if (!ptrace_may_access(task1, PTRACE_MODE_READ_REALCREDS) ||
> @@ -212,8 +212,8 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
>  	}
>  
>  err_unlock:
> -	kcmp_unlock(&task1->signal->exec_update_mutex,
> -		    &task2->signal->exec_update_mutex);
> +	kcmp_unlock(&task1->signal->exec_update_lock,
> +		    &task2->signal->exec_update_lock);
>  err:
>  	put_task_struct(task1);
>  	put_task_struct(task2);


Thanks
Bernd.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ