From owner-freebsd-current Thu Feb 7 22:29:34 2002 Delivered-To: freebsd-current@freebsd.org Received: from falcon.prod.itd.earthlink.net (falcon.mail.pas.earthlink.net [207.217.120.74]) by hub.freebsd.org (Postfix) with ESMTP id 1E67637B404; Thu, 7 Feb 2002 22:29:25 -0800 (PST) Received: from pool0339.cvx22-bradley.dialup.earthlink.net ([209.179.199.84] helo=mindspring.com) by falcon.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 16Z4X5-0006yL-00; Thu, 07 Feb 2002 22:29:17 -0800 Message-ID: <3C636F6C.96506043@mindspring.com> Date: Thu, 07 Feb 2002 22:25:48 -0800 From: Terry Lambert X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: John Baldwin Cc: current@freebsd.org, Julian Elischer Subject: Re: ucred for threads References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG John Baldwin wrote: > No, an unlocked compare is _not_ ok. What if the p_ucred pointer was changed > on some other processor by another thread from this processor? I saw your response to Julian... I understand the concern, but I think it's unfounded. Let me explain. > Without a lock > you don't have a guarantee that that other processor's writes are visible to > you. We really don't want to be using stale credentials for syscalls given the > past history of race conditions involving credentials. If in the future it is > deemed that getting a stale cred is an acceptable race, then this can be > optimized then, but for now we had better get it right. There's "stale" and there's "Stale". I thnk "stale" is OK. Here's how I see it: If there's a race between changing and using a cred in kernel space, it can only come about because of a similar race in user space. This means that if I change from cred A to cred B, there's no difference in the closure between losing the race in the kernel (and getting a stale value) and losing the race in user space (and getting a stale value). Basically, if it's an issue, then user level primitives have to be used to protect the request for the credential change. Maybe a picture would be better: Threads Creds 1 2 A B case i: setuid x------>x create x case ii: setuid create x <- user race lost x------>x case iii: setuid x------>x create x <- stale > FreeBSD doesn't run on just the i386 anymore, we have Alpha, ia64, and sparc64 > SMP machines to deal with as well. I understand; I'm very noisy about this point myself, e.g. the recent binutils breakage that made Alpha not build at all. However, I'm not convinced that it's possible to have the kernel race be present, without a corresponding user race, which means protecting against "case iii" doe nothing for you, if you can still get the inversion from "case ii". If, on the other hand, you have user space synchornization that guards against "case ii", then the fact that the synchornization operates across the same barrier as the credential change call means that the you also protect against "case iii". Are there any obvious cases that I'm just not seeing here where a "case iii" is possible without a "case ii"? -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message