Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp873489ybz; Fri, 24 Apr 2020 10:40:21 -0700 (PDT) X-Google-Smtp-Source: APiQypKGd8E192yyYtARCdE3mpLO7XVsQFFy67zqNuHrQfPyd3asHpxpkP17gGfg8yhcl6A0koWJ X-Received: by 2002:a05:6402:154:: with SMTP id s20mr8570792edu.224.1587750021197; Fri, 24 Apr 2020 10:40:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587750021; cv=none; d=google.com; s=arc-20160816; b=LfKqCxh+xm6q3DlG8HvRmLthvVxHGmo91gxkJ2yXJ1EUCZ2US42dh4cqzucGWePWbS oRGUr3I0jZVxTznBsm28KcfmfFoS3TsXbnipYn2Poaax3J40MMpi6XJoUeOvfWOsOzHG e+DGnF1ozkfkcWV6btJRTWVRzdaBFpnNawGwNpg5jXGN4ST8WG+xQ/nkVhjX2cnvfoNK 7Ovyg7ml6HC8I3DnoWqh2MEX/wH9KXKKO4/KJtl4coTpEEZel+/sxmk52STpbGNA9y1o SypzvdI25noRrww3uWzqER55IGrX4m5uTJCYwit7Ma1ysYk9dG8IZt1iFOKUSKAEZuoA 89TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=+B/QuJEXCS5JW+lvgXU+oZJxIZ0OsZECrH80ZV2ahoI=; b=Bgm4jcigE1v3h5ES6uQrvAcjsUE15q1dN3mDeL/i+jDxVTxTrtepYeiwBf/wS78Csh X4MHAST9aGWgcDHv6psg7RmPH04jYexrCvswB8WT/zr0t+kfvj4+dWjIE49HIz+OGunr fObTFVQzmJQMeTUXj4mP99VYFsEnUVTRi+S9ejZYlLrriZG6A764iZ0eGZAPpOOPfE1Y oomQo9RV55cTkw2E3IuB1WDRsaFJcSKQPmdwQfWViI7AaYW5R1ha4kqgr+XfY6aZb5BB R+235oLwbWz4ZmHAnZ6mNi2qxt7BakjApxTZnLnh3Ci+EdekWy7m5saHPmNzMmsMqMHs e77w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g22si3695624ejr.228.2020.04.24.10.39.58; Fri, 24 Apr 2020 10:40:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727108AbgDXRik (ORCPT + 99 others); Fri, 24 Apr 2020 13:38:40 -0400 Received: from mother.openwall.net ([195.42.179.200]:54079 "HELO mother.openwall.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726813AbgDXRik (ORCPT ); Fri, 24 Apr 2020 13:38:40 -0400 Received: (qmail 12213 invoked from network); 24 Apr 2020 17:38:38 -0000 Received: from localhost (HELO pvt.openwall.com) (127.0.0.1) by localhost with SMTP; 24 Apr 2020 17:38:38 -0000 Received: by pvt.openwall.com (Postfix, from userid 503) id CF163AB5C7; Fri, 24 Apr 2020 19:38:28 +0200 (CEST) Date: Fri, 24 Apr 2020 19:38:28 +0200 From: Solar Designer To: Ben Hutchings Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, akpm@linux-foundation.org, Denis Kirjanov , Dan Carpenter , Al Viro , Kees Cook , Salvatore Mesoraca , Linus Torvalds Subject: Re: [PATCH 3.16 208/245] namei: allow restricted O_CREAT of FIFOs and regular files Message-ID: <20200424173828.GA27528@openwall.com> References: <20200424135205.GA27204@openwall.com> <8783c94cb802ade8a45cdf4233fe3b7341cca5c9.camel@decadent.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8783c94cb802ade8a45cdf4233fe3b7341cca5c9.camel@decadent.org.uk> User-Agent: Mutt/1.4.2.3i Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 24, 2020 at 04:13:22PM +0100, Ben Hutchings wrote: > On Fri, 2020-04-24 at 15:52 +0200, Solar Designer wrote: > > On Fri, Apr 24, 2020 at 12:07:15AM +0100, Ben Hutchings wrote: > > > 3.16.83-rc1 review patch. If anyone has any objections, please let me know. > > > > I do. This patch is currently known-buggy, see this thread: > > > > https://www.openwall.com/lists/oss-security/2020/01/28/2 > > > > It is (partially) fixed with these newer commits in 5.5 and 5.5.2: > > > > commit d0cb50185ae942b03c4327be322055d622dc79f6 > > Author: Al Viro > > Date: Sun Jan 26 09:29:34 2020 -0500 > > > > do_last(): fetch directory ->i_mode and ->i_uid before it's too late > > > > may_create_in_sticky() call is done when we already have dropped the > > reference to dir. > > > > Fixes: 30aba6656f61e (namei: allow restricted O_CREAT of FIFOs and regular files) > > Signed-off-by: Al Viro > > > > commit d76341d93dedbcf6ed5a08dfc8bce82d3e9a772b > > Author: Al Viro > > Date: Sat Feb 1 16:26:45 2020 +0000 > > > > vfs: fix do_last() regression > > > > commit 6404674acd596de41fd3ad5f267b4525494a891a upstream. > [...] > > At least inclusion of the above fixes is mandatory for any backports. > > I know, and those are the next 2 patches in the series. Ah, then no objections from me. > > Also, I think no one has fixed the logic of may_create_in_sticky() so > > that it wouldn't unintentionally apply the "protection" when the file > > is neither a FIFO nor a regular file (something I found and mentioned in > > the oss-security posting above). > [...] > > I think the implementation of may_create_in_sticky() should be rewritten > > such that it'd directly correspond to the textual description in the > > comment above. As we've seen, trying to write the code "more optimally" > > resulted in its logic actually being different from the description. > > > > Meanwhile, I think backporting known-so-buggy code is a bad idea. > > I can see that it's not quite right, but does it matter in practice? > Directories and symlinks are handled separately; sockets can't be > opened anyway; block and character devices wonn't normally appear in a > sticky directory. Clearly, it doesn't matter all that much in practice - I'm not aware of anyone having complained about it causing issues on their system. I think it primarily mattered as an attack vector on the issue fixed with Al's commits above. I think we should nevertheless fix the code to match its intent and the comment, but meanwhile this isn't a blocker for the backport. Alexander