Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp728575ybz; Fri, 24 Apr 2020 08:18:47 -0700 (PDT) X-Google-Smtp-Source: APiQypLf3tZH7rPJSDUBWVfwmn3liWyN/Y2IkbpuIo+o83tVOlZ4g+3WFMcip9GR4sfpcGg63+hv X-Received: by 2002:aa7:d3d3:: with SMTP id o19mr7718196edr.76.1587741526589; Fri, 24 Apr 2020 08:18:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587741526; cv=none; d=google.com; s=arc-20160816; b=lAjN+V5+7hqJ6d0nYp/2j+fWXANlTYhDlDsPAIoasyxU03I8mpiv+0gt7tsRVNr/W9 bFqW65tFM9jMPtizPKypvo8uk8ne8rJvjN5m4OFzpyfuudOdwXU4D4nUPJpHBvceAcnx KHz3BrOebduNi81aI5+cXob02MUamvYlknFQ4WjI6SS1rrE86blyS+lmlh/TXxvNk9Nc mI9yOs9PYLtn7UdQxDgx6U/u83ivxaYWdUkkpRmkmZHB6SMZzGokx33l+YwEDBvkweSF q5ahJUUAgLNZuq0149a3LlNVhZhH/3nZMzMz+iqdFTO0Si9xG2pJGKKTNZg/7bB1CmIs NbOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id; bh=rL6zzWOGn+bU6P1w5eV6+BhkST8y+ztA1j+44E2f1XY=; b=gIbLNeVqm/o62yisPiFYptMxJQsHPuk+BJ4LH9QPDBTkfmJfeGv+LehdLKJIvU5/mb CC0tCyEvVtlE7IwYcsv3eQPPqttt+DB+qokZH2xEzI7GATj5VBrC6qxfKFxqywLM4vTt BevdnMOfWSzR/nkQTQ+IWRZXrnFHMQze1bo/yxyLAxq9H82sZ7s30xOvgTQ7DHvpjIwR n01xoJaQ/7NYS9BcaeDObv+V/TXYcNCt9tC1I61Gg8uqMTw9kOtwohJLTDoZW6EaMJq9 69awuBUXwWF9mXkdnuhDA7J7NuIV4oH9FSv+n7gX29JGxHbXAkP+272WFfpx+dDQT8bv hcXQ== 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 z16si3300083ejr.249.2020.04.24.08.18.21; Fri, 24 Apr 2020 08:18:46 -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 S1728251AbgDXPNf (ORCPT + 99 others); Fri, 24 Apr 2020 11:13:35 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:56088 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726908AbgDXPNf (ORCPT ); Fri, 24 Apr 2020 11:13:35 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1jS01F-0008Gr-Is; Fri, 24 Apr 2020 16:13:33 +0100 Received: from ben by deadeye with local (Exim 4.93) (envelope-from ) id 1jS01F-00F5UL-4p; Fri, 24 Apr 2020 16:13:33 +0100 Message-ID: <8783c94cb802ade8a45cdf4233fe3b7341cca5c9.camel@decadent.org.uk> Subject: Re: [PATCH 3.16 208/245] namei: allow restricted O_CREAT of FIFOs and regular files From: Ben Hutchings To: Solar Designer 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 Date: Fri, 24 Apr 2020 16:13:22 +0100 In-Reply-To: <20200424135205.GA27204@openwall.com> References: <20200424135205.GA27204@openwall.com> Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-G7TFAlgBTbsPFt4nkwf+" User-Agent: Evolution 3.36.1-1 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-G7TFAlgBTbsPFt4nkwf+ Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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. >=20 > I do. This patch is currently known-buggy, see this thread: >=20 > https://www.openwall.com/lists/oss-security/2020/01/28/2 >=20 > It is (partially) fixed with these newer commits in 5.5 and 5.5.2: >=20 > commit d0cb50185ae942b03c4327be322055d622dc79f6 > Author: Al Viro > Date: Sun Jan 26 09:29:34 2020 -0500 >=20 > do_last(): fetch directory ->i_mode and ->i_uid before it's too late > =20 > may_create_in_sticky() call is done when we already have dropped the > reference to dir. > =20 > Fixes: 30aba6656f61e (namei: allow restricted O_CREAT of FIFOs and re= gular files) > Signed-off-by: Al Viro >=20 > commit d76341d93dedbcf6ed5a08dfc8bce82d3e9a772b > Author: Al Viro > Date: Sat Feb 1 16:26:45 2020 +0000 >=20 > vfs: fix do_last() regression > =20 > 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. > 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. >=20 > 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?=20 Directories and symlinks are handled separately; sockets can't be opened anyway; block and character devices wonn't normally appear in a sticky directory. Ben. --=20 Ben Hutchings Knowledge is power. France is bacon. --=-G7TFAlgBTbsPFt4nkwf+ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEErCspvTSmr92z9o8157/I7JWGEQkFAl6jAhIACgkQ57/I7JWG EQlUpA/9Er5XJcG/bsXQ/WFew/O336Cp3duv3JdZcKLGCHo+v2TVueTvCkG9mhgC rXDQsVOhHhByqU3jAB39MFCXvnigImZGi7IpEdLRpdJGYSsfRqPOLR6dsyGRoDYp wxCGA3UQHnyLfvwVoS/jY83p31vgBbGgj4t7He2e7/Mrx7CkL3qdjoGzu9Xl6O+3 GvOm4rnkfMbTkKImdzJ6hhh5v4AuMqobfbp8P2xlsv3hwy56tNslhrdVNAH1WbDy tog2jQdWPg24RXTiv1EaYxw6bKCivIK07m/RgqZH/znVk9FUBsUKtfb9Kq4Z5UO7 EyIpgwvOpLA8ctZr0RPL7mlMdiSz8QcHLMBawq0G60OVxIuBMfmGfuTVeBuZs9F2 FxbPN44ULZMra9vbgGvexKnfWAsgpzab7G+95K9cs+vomudPO25soCO8yo9JjdZt llH71ClBc2/kOXJnr5O1hQQ0deo9OdlxxIODeN0S7mbwNxEAMZwe8TJ3gBU9ZMC0 a9pizROPYj846HlEZ8OKuVsnvNiVyf4MdsaYJ7DjkW81nOWyi0fYqRBj5ol2Nqkb eGmgqZtatjkwlLX7L/zImm774E/UOOmcHZIpC3O+wp/zgvwiDhhnKpeBW74VdZS7 9hAww3ZS/1p4P3NQ8l657fu5N/uOGb+ux8ulB1U1HI19oHHNS4I= =xc5f -----END PGP SIGNATURE----- --=-G7TFAlgBTbsPFt4nkwf+--