Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2051105ybe; Sat, 7 Sep 2019 07:59:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfm3d+FYWSwi0gnhw0zm206iOygT0P1JJUPo3Cgvh6unm2Z4vh2Alac4GNd8QjCGnSZpPw X-Received: by 2002:a63:ff66:: with SMTP id s38mr13186900pgk.363.1567868373294; Sat, 07 Sep 2019 07:59:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567868373; cv=none; d=google.com; s=arc-20160816; b=JiEbmqcVKTOGcAJYldmK1xCJqVuo0ZlpJ4Kdxek7wNa+XlOgAom0tgqLjsxUrfpUpq xdzFlKH/m7mbh9+Pts3FrF+1loptMd+7BKwzubNaoCIYTzvcyRo95MAdg117FXh7SsI8 9uGpmKu+6q4hlmCw6p2Wohiwlu/s7g8DiWYXsYWh7SRoywLqa4BVidMnfPU4PsnQaZr+ X8sc8lguJtkENvEgK2B7DDwSPMgqfnDjb+gl95xADq4i4JldD9gOXtSx/Jsxd9iyI+H1 x7kFsWWEtll58aWLM/8aJU8bDYETYx+0tDr6OkUe/PyLQVKYC6ZcjqsOCUQpE64X0pit OWPA== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=zO1msM12y6bK/8fdK5V2QvdumTJtX98CPZgVa4wYua8=; b=EFVBdyN73rr5l0wWqZl218gP4oDsqEQ7eQgpFMk5KW+pCmiuTkFC1WLrzHlqaSvgOo 8VUsv4ivjELpwyTRnfK4XMVEXpBiHZpFF735LkNGg4Ocgqu+G4jKGVDcfvjLpbjLCryc R37BTa9boOkgZ6nSxDSSLG2yIlo+8zaqG3dxmHf3lZBG8Hhp2BAPOBneuVbKsSi2QG7j zJTMGbwXNDSRKBYcB3GWyAe6bZfIDNdCsD0rckscBiJ2FUdcMtYXM4as85j2Z4OBM9Ug +y2cZrDU0XlOEaDYYT8bXplmqpPLmsgh6i1V7NGeB/eQZUdvL0vo06Rd1Wigo0yAlE80 9f3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b="XO/yX7LE"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6si7885856pls.109.2019.09.07.07.59.14; Sat, 07 Sep 2019 07:59:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b="XO/yX7LE"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436466AbfIFRkq (ORCPT + 99 others); Fri, 6 Sep 2019 13:40:46 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:43792 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395260AbfIFRkp (ORCPT ); Fri, 6 Sep 2019 13:40:45 -0400 Received: by mail-pg1-f196.google.com with SMTP id u72so3862054pgb.10 for ; Fri, 06 Sep 2019 10:40:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tycho-ws.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=zO1msM12y6bK/8fdK5V2QvdumTJtX98CPZgVa4wYua8=; b=XO/yX7LEgs5Py5IcR0pKSxv0kqAvd7JX+EvT7RoHkRLj6XBdBgmc5kawEmQSEaOfCF befBBKyBZq+WQzNW+FffURQ7iannWXQeGXIpMnm2Hzrb0KAxm4qATsVouCrf8frCZRJq zJFo/9nCu8DmSzQW9l2UhDNx4m7+OQwYDWTXzt68joRfSKkOCyFG7v38va8fvVkDtCpe kUvye/5As7q+ij7ejRh5Wmz7WJ3EapCZ9iZOpGXBrkmaueHRg+beKqNU+1g3Hxef+haG Z/VemRSCEry5m2XrLM/UaS8LB0wsGl3bzSwE/TNObzcd7CM1464Tm7FWyYCP8aZTPfAg FmMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=zO1msM12y6bK/8fdK5V2QvdumTJtX98CPZgVa4wYua8=; b=mogJUYO/PbO+n1Y4uXjZc0XsS0M0ctb4wS6d/FxdJGa9KQMOXpxCZvm3WSsr7O/g+k INn6/beXvGJCAQH3g6ZHWViyJ5QHT4zDUKnwjvXfKXzbCUYQcQDRvp7M591AcNQD9vIk PBglUJbv8yA4731+tMXQ3WvalIHqxBl+FKeGwiOc//TkN79jlkkScZCG3QHFxNudB+/R FSn5SGM/PCkHKVTXdS35zmqHK+T/Fm77UHaM8eHHSJX+kzlK49lDslRp5pgJzJkzvufh +vp9TmtQNjEdMa+9QUvMCoNgvTlJbywI7GEfQLv6Dxo62mnAXnOr9AxD40tbFV9OGuOJ Z/8g== X-Gm-Message-State: APjAAAWxsf0QnRjIa+hSO69bGn+VfSbJJgU54rI/9B8bCaG8OtTjjz8P lXpWhUjN4ZhbO+4I2mRADw2IZg== X-Received: by 2002:a62:b406:: with SMTP id h6mr11911803pfn.260.1567791644954; Fri, 06 Sep 2019 10:40:44 -0700 (PDT) Received: from cisco ([2601:282:901:dd7b:49a:5f6f:e06:3c33]) by smtp.gmail.com with ESMTPSA id e189sm6807500pgc.15.2019.09.06.10.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2019 10:40:44 -0700 (PDT) Date: Fri, 6 Sep 2019 11:40:41 -0600 From: Tycho Andersen To: Christian Brauner Cc: Aleksa Sarai , =?iso-8859-1?Q?Micka=EBl_Sala=FCn?= , Florian Weimer , =?iso-8859-1?Q?Micka=EBl_Sala=FCn?= , linux-kernel@vger.kernel.org, Alexei Starovoitov , Al Viro , Andy Lutomirski , Christian Heimes , Daniel Borkmann , Eric Chiang , James Morris , Jan Kara , Jann Horn , Jonathan Corbet , Kees Cook , Matthew Garrett , Matthew Wilcox , Michael Kerrisk , Mimi Zohar , Philippe =?iso-8859-1?Q?Tr=E9buchet?= , Scott Shell , Sean Christopherson , Shuah Khan , Song Liu , Steve Dower , Steve Grubb , Thibaut Sautereau , Vincent Strubel , Yves-Alexis Perez , kernel-hardening@lists.openwall.com, linux-api@vger.kernel.org, linux-security-module@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v2 1/5] fs: Add support for an O_MAYEXEC flag on sys_open() Message-ID: <20190906174041.GH7627@cisco> References: <20190906152455.22757-1-mic@digikod.net> <20190906152455.22757-2-mic@digikod.net> <87ef0te7v3.fsf@oldenburg2.str.redhat.com> <75442f3b-a3d8-12db-579a-2c5983426b4d@ssi.gouv.fr> <20190906170739.kk3opr2phidb7ilb@yavin.dot.cyphar.com> <20190906172050.v44f43psd6qc6awi@wittgenstein> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190906172050.v44f43psd6qc6awi@wittgenstein> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 06, 2019 at 07:20:51PM +0200, Christian Brauner wrote: > On Sat, Sep 07, 2019 at 03:07:39AM +1000, Aleksa Sarai wrote: > > On 2019-09-06, Micka?l Sala?n wrote: > > > > > > On 06/09/2019 17:56, Florian Weimer wrote: > > > > Let's assume I want to add support for this to the glibc dynamic loader, > > > > while still being able to run on older kernels. > > > > > > > > Is it safe to try the open call first, with O_MAYEXEC, and if that fails > > > > with EINVAL, try again without O_MAYEXEC? > > > > > > The kernel ignore unknown open(2) flags, so yes, it is safe even for > > > older kernel to use O_MAYEXEC. > > > > Depends on your definition of "safe" -- a security feature that you will > > silently not enable on older kernels doesn't sound super safe to me. > > Unfortunately this is a limitation of open(2) that we cannot change -- > > which is why the openat2(2) proposal I've been posting gives -EINVAL for > > unknown O_* flags. > > > > There is a way to probe for support (though unpleasant), by creating a > > test O_MAYEXEC fd and then checking if the flag is present in > > /proc/self/fdinfo/$n. > > Which Florian said they can't do for various reasons. > > It is a major painpoint if there's no easy way for userspace to probe > for support. Especially if it's security related which usually means > that you want to know whether this feature works or not. What about just trying to violate the policy via fexecve() instead of looking around in /proc? Still ugly, though. Tycho