From owner-svn-src-head@freebsd.org Wed Mar 13 19:36:50 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0F9DE153F5A4; Wed, 13 Mar 2019 19:36:50 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [88.99.82.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9CF686C789; Wed, 13 Mar 2019 19:36:49 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2016.home.selasky.org (unknown [176.74.212.121]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 3CEA726027C; Wed, 13 Mar 2019 20:36:47 +0100 (CET) Subject: Re: svn commit: r345100 - head/sys/compat/linuxkpi/common/include/linux To: Konstantin Belousov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201903131855.x2DItg7s091824@repo.freebsd.org> <20190313191447.GC2492@kib.kiev.ua> From: Hans Petter Selasky Message-ID: <57128db9-2ea0-f4e7-87d9-205397c9cbd2@selasky.org> Date: Wed, 13 Mar 2019 20:36:22 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190313191447.GC2492@kib.kiev.ua> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 9CF686C789 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.98 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.98)[-0.979,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Mar 2019 19:36:50 -0000 On 3/13/19 8:14 PM, Konstantin Belousov wrote: > On Wed, Mar 13, 2019 at 06:55:42PM +0000, Hans Petter Selasky wrote: >> Author: hselasky >> Date: Wed Mar 13 18:55:41 2019 >> New Revision: 345100 >> URL: https://svnweb.freebsd.org/changeset/base/345100 >> >> Log: >> Implement task_euid() and get_task_state() function macros in the LinuxKPI. >> >> Submitted by: Johannes Lundberg >> MFC after: 1 week >> Sponsored by: Limelight Networks >> Sponsored by: Mellanox Technologies >> >> Modified: >> head/sys/compat/linuxkpi/common/include/linux/sched.h >> >> Modified: head/sys/compat/linuxkpi/common/include/linux/sched.h >> ============================================================================== >> --- head/sys/compat/linuxkpi/common/include/linux/sched.h Wed Mar 13 18:53:29 2019 (r345099) >> +++ head/sys/compat/linuxkpi/common/include/linux/sched.h Wed Mar 13 18:55:41 2019 (r345100) >> @@ -95,7 +95,9 @@ struct task_struct { >> #define get_pid(x) (x) >> #define put_pid(x) do { } while (0) >> #define current_euid() (curthread->td_ucred->cr_uid) >> +#define task_euid(task) ((task)->task_thread->td_ucred->cr_uid) > This looks very strange if you compare the definition of task_euid() > with the definition of linux_task_exiting() in r345098. > > There you access td_ucred which is basically volatile and invalid unless > the thread is known to be inhibited or sleeping (and not exiting). So > to use the macro safely for task not associated with current thread, > you must have very strong and unusual external guarantees. > > On the other hand, linux_task_exiting() correctly locks the target process. > But, since the lock is dropped before the function returns, the process > might exit wheh the callers gets to use the result. Again, some external > guarantees must be ensured to give safe use for this macro as well, for > the target process != curproc. Thanks for the feedback. I've forwarded it to Johannes Lundberg. There are more patches at: https://reviews.freebsd.org/D19565 --HPS