Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2043610ybe; Sat, 7 Sep 2019 07:50:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/3tvQGKeE2LpE1a8J1SSIeHJ15UKAhKUm2sY3xTeqWGEJ60PX5ferBT/5Aq5gK66UhfKy X-Received: by 2002:a62:2c85:: with SMTP id s127mr13436129pfs.55.1567867811944; Sat, 07 Sep 2019 07:50:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567867811; cv=none; d=google.com; s=arc-20160816; b=bm4JPT3yquOZo2qKpL9MRfbqWi9tpQ7A03LJ4u+5d3KsX+MfxX/ZxeGDX8IbIrvEAS 5CtFk/vD/lCqPttp6AweDWuNmzCNm6GYhw01fzMD2cDt6BdL42UDcuoI1xLXM3CRwTII vaONElyIe1DSg4VGP+7/zwuf/zgoDg8nvGeq+mOegA/Uc4dqU0w7MTdNRQChd5vuATse AML7xK1hCw1A3+8TCqWW9wmwqBr2iRjtQQ06XlXbnF9PgW/xndPgPT1EHAUVO2wGo49v FbeQ8eXuLmnl4cO0XAhORnAoSkHB8pxPDdXMZ7MoDpoudrO6/oUBnvu1hT5bt/Gs7C81 ennw== 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; bh=R7WB+90pAGYUO6pWT9eesG5qzbbNmf9seBrco35crcc=; b=IGQIO2fZGLHV1RKelT1KlxNoXDPAGi5WZHM+WXy8+Uu11bH/IGtIptt2Yj0O8nxyMs ZHAbvxg8iHL6ZioBTxkks/YIARqxgMXEpanx6JpI0o3va6IklZXMoYe6plVDYV1JezDJ KNM6iKxlVuDEEtSlLkj32MobxhELgieMte+OhQmLw8JJX/cn1WcFHMbHsjBbylOAGcI3 M+jHe7w+Wy5X68cVGfzXxkNewufa3sSrR2V8q1UPiuxwwCaNoDTKME375IV+FfJj6wa4 mNXd2ZkWVZlcUm4MvaNVkt2omquHfo2bdJeMS7ZHXJAgjdj456LDUG7vJqlBeWCv9t1d mWzg== ARC-Authentication-Results: i=1; mx.google.com; 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 bb7si7573599plb.35.2019.09.07.07.49.57; Sat, 07 Sep 2019 07:50:11 -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; 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 S2406052AbfIFRVB (ORCPT + 99 others); Fri, 6 Sep 2019 13:21:01 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:54469 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729928AbfIFRVA (ORCPT ); Fri, 6 Sep 2019 13:21:00 -0400 Received: from [213.220.153.21] (helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1i6Hum-000463-IN; Fri, 06 Sep 2019 17:20:52 +0000 Date: Fri, 6 Sep 2019 19:20:51 +0200 From: Christian Brauner To: Aleksa Sarai Cc: =?utf-8?Q?Micka=C3=ABl_Sala=C3=BCn?= , Florian Weimer , =?utf-8?Q?Micka=C3=ABl_Sala=C3=BCn?= , 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 =?utf-8?Q?Tr=C3=A9buchet?= , 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: <20190906172050.v44f43psd6qc6awi@wittgenstein> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190906170739.kk3opr2phidb7ilb@yavin.dot.cyphar.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Christian