From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2838 Path: news.gmane.org!not-for-mail From: KOSAKI Motohiro Newsgroups: gmane.linux.lib.musl.general Subject: Re: O_EXEC and O_SEARCH Date: Sat, 23 Feb 2013 00:01:39 -0500 Message-ID: References: <20130222004540.GA8836@brightrain.aerifal.cx> <20130223031708.GU20323@brightrain.aerifal.cx> <20130223043336.GV20323@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1361595737 547 80.91.229.3 (23 Feb 2013 05:02:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 23 Feb 2013 05:02:17 +0000 (UTC) Cc: libc-alpha , musl@lists.openwall.com To: Rich Felker Original-X-From: musl-return-2839-gllmg-musl=m.gmane.org@lists.openwall.com Sat Feb 23 06:02:40 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1U97Fp-0005Zu-4a for gllmg-musl@plane.gmane.org; Sat, 23 Feb 2013 06:02:33 +0100 Original-Received: (qmail 16292 invoked by uid 550); 23 Feb 2013 05:02:12 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 16284 invoked from network); 23 Feb 2013 05:02:12 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=NXgKT7JB9C+++sEvtmalRZFxs92CcHlXUyfrC3U4MHk=; b=LECddb41t7by0Ux+ynLGls4JshUSjke6RbGygrU6nqYwSb/aY76I+IFOSsY4TvL0Rc Ie1AVKRvRz0Z9layu/zlSz2fr8S+LoZf0kWjTAgmlC/A+O/qNTcZgphmCctdm+DRrJIr YgguU1LLDGk0RhbnEj+g2LN3cFBNIuA6y0kjEJ2VqGd8mIZ4qIKSYgvN+/9IW85lWLU6 rK/XrOJqQHvnrRzUO7PzrflcMQte0E1R+9ubICjYAAtHyqVf/60/TJQq0MuNR+wbE6nW QMidx9izC6GTockNU1PTigedmIQ+P7cDEgqXVqHJYnbxsDs5CkqyBD8cZU75Ag2Jtguf qfqg== X-Received: by 10.60.13.162 with SMTP id i2mr1759028oec.121.1361595720073; Fri, 22 Feb 2013 21:02:00 -0800 (PST) In-Reply-To: <20130223043336.GV20323@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:2838 Archived-At: > 1. Try to open with O_RDONLY. If it succeeds, we're done. This is > REALLY nice because it means O_SEARCH and O_EXEC "just work" even on > ancient or broken kernels as long as the target file is readable. Hmm.. This algorithm seems slightly strange to me. Why do you want to try O_RDONLY at first? O_RDONLY require read permission and O_SEARCH, if i understand correctly, doesn't. I think you should try O_PATH at first. > > 2. Else, add O_PATH and try again. If it still fails, we have a > pre-2.6.39 kernel and there's nothing we can do, so just report > failure. > > 3. If open succeeds with O_PATH, then if O_NOFOLLOW is also specified, > check fstat, and close the file and report error if fstat succeeded > and the obtained fd was a symbolic link. > > 4. If fstat failed, we have a buggy kernel, so either close and report > an error, or just ignore the failure (possibly ignoring the > requirements of O_NOFOLLOW), as there seems to be no way to handle it > correctly on such kernels. > > If the kernel developers ever add O_SEARCH/O_EXEC at the kernel level > with our proposed value of 3, a step 0, just passing the value to the > kernel directly and seeing if it works, could also be added. > > Rich