Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp557703ybk; Fri, 15 May 2020 07:45:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxw4L8bHdu67e9HwvByxFXHC3NjVDNgz2KSg863mV1+R5QNstKg4MyqvOab1Eu3/hvf/q0P X-Received: by 2002:a05:6402:14d5:: with SMTP id f21mr3207988edx.327.1589553939228; Fri, 15 May 2020 07:45:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589553939; cv=none; d=google.com; s=arc-20160816; b=WszIuicp8s5BingZAkVUaHbI+WbJDnKMiCumxmA6W0/p4PNEnlTa9u1lL/XdQd/LEx TjO1va6sPBBlldyPy/jNTVhp0Txj5Bbzx5w+yOcd2lYSJ2d3NVB0YWjxN8hfX+mKWOls xbwG4BQD2MMn7ort8X5zZKO0L+kSBDzi4ZujD6p/nDFw9YWPH0F/hUyPEWx79DkcyElG N0QNi4yjwTWfMGVJsRfRm4u02KBA0DOcYdE/Bij7klnd/C4tUeJ0s9GxhF8RQCyg+EwA XAdDqbMKierV0d7b1HUDSA8AchVUIzbKD0jJhnVU1Pt+tMH3+TR/qiiCRJh/IsFZtt4K iUeQ== 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:message-id :in-reply-to:date:references:subject:cc:to:from:dkim-signature; bh=hR6lCjnUOV2j2gabpoQGpgvPB5RUTChOvM8hrmj3dmQ=; b=JVcfXxXpbLeHEUllcXM6KSQ2pstC09DaOKB1Tc78Tz4Wbc1muoqoHOw4YGX408hTAG lPMGGOp+UCQZ/S6vM1sWJ5ne3UE+yZxSuImMZX5yEnULcObh9zWqnSmN5/6LYCQ5e/1B 4+X4CIm0WT2I6k2kbWewbSAiu0tluperfYKaxTAJ9bXLD1G0vFVkXbfheqGkF4KG0RNM XtYWGrX0sJoBuOFijqDjjvfV3dC0kRWB7BZT5a+jGKK1DR1IuMbL8CfHhNFpnf7d9z5g KUGhVxLOk+ft7IexV+a3pzGLcsrpZa2oMje3tmDrHOD28GHYqji20j9FCw+msmPv50oV wqDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FKqNBS+H; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b34si1288763edf.411.2020.05.15.07.45.16; Fri, 15 May 2020 07:45:39 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FKqNBS+H; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726582AbgEOOn4 (ORCPT + 99 others); Fri, 15 May 2020 10:43:56 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:49692 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726144AbgEOOn4 (ORCPT ); Fri, 15 May 2020 10:43:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589553834; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hR6lCjnUOV2j2gabpoQGpgvPB5RUTChOvM8hrmj3dmQ=; b=FKqNBS+Hk2mCfqAwAmbGul8UIk4bHZNzykfRliiIOevpZKtEjqovYdjFurgvll+3ESpg7O tUKsHbA1tJfjocp1RsZDry4W7TCQvZkKUWCJiy7yHB0hU6M8UN0H+tgHv9uYjYV782gQi5 rz7370VMZ89t6UqoJ5Pk0U/+zFY6+Xo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-102-IBhV3vZSOp6wkLbJJ_diLA-1; Fri, 15 May 2020 10:43:52 -0400 X-MC-Unique: IBhV3vZSOp6wkLbJJ_diLA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C02C78018A2; Fri, 15 May 2020 14:43:47 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-112-77.ams2.redhat.com [10.36.112.77]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C92A5C241; Fri, 15 May 2020 14:43:39 +0000 (UTC) From: Florian Weimer To: Kees Cook Cc: =?utf-8?Q?Micka=C3=ABl_Sala=C3=BCn?= , Al Viro , Aleksa Sarai , Andy Lutomirski , Mimi Zohar , Stephen Smalley , Christian Heimes , Deven Bowers , Tetsuo Handa , John Johansen , Kentaro Takeda , "Lev R. Oshvang ." , Alexei Starovoitov , Daniel Borkmann , Eric Chiang , James Morris , Jan Kara , Jann Horn , Jonathan Corbet , Lakshmi Ramasubramanian , Matthew Garrett , Matthew Wilcox , Michael Kerrisk , =?utf-8?Q?Micka=C3=ABl_Sala=C3=BCn?= , Philippe =?utf-8?Q?Tr=C3=A9buchet?= , Scott Shell , Sean Christopherson , Shuah Khan , Steve Dower , Steve Grubb , Thibaut Sautereau , Vincent Strubel , linux-kernel , kernel-hardening@lists.openwall.com, linux-api@vger.kernel.org, linux-integrity@vger.kernel.org, LSM List , Linux FS Devel Subject: Re: How about just O_EXEC? (was Re: [PATCH v5 3/6] fs: Enable to enforce noexec mounts or file exec through O_MAYEXEC) References: <20200505153156.925111-4-mic@digikod.net> <202005131525.D08BFB3@keescook> <202005132002.91B8B63@keescook> <202005140830.2475344F86@keescook> <202005142343.D580850@keescook> <87a729wpu1.fsf@oldenburg2.str.redhat.com> <202005150732.17C5EE0@keescook> Date: Fri, 15 May 2020 16:43:37 +0200 In-Reply-To: <202005150732.17C5EE0@keescook> (Kees Cook's message of "Fri, 15 May 2020 07:37:16 -0700") Message-ID: <87r1vluuli.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Kees Cook: > On Fri, May 15, 2020 at 10:43:34AM +0200, Florian Weimer wrote: >> * Kees Cook: >> >> > Maybe I've missed some earlier discussion that ruled this out, but I >> > couldn't find it: let's just add O_EXEC and be done with it. It actually >> > makes the execve() path more like openat2() and is much cleaner after >> > a little refactoring. Here are the results, though I haven't emailed it >> > yet since I still want to do some more testing: >> > https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/log/?h=kspp/o_exec/v1 >> >> I think POSIX specifies O_EXEC in such a way that it does not confer >> read permissions. This seems incompatible with what we are trying to >> achieve here. > > I was trying to retain this behavior, since we already make this > distinction between execve() and uselib() with the MAY_* flags: > > execve(): > struct open_flags open_exec_flags = { > .open_flag = O_LARGEFILE | O_RDONLY | __FMODE_EXEC, > .acc_mode = MAY_EXEC, > > uselib(): > static const struct open_flags uselib_flags = { > .open_flag = O_LARGEFILE | O_RDONLY | __FMODE_EXEC, > .acc_mode = MAY_READ | MAY_EXEC, > > I tried to retain this in my proposal, in the O_EXEC does not imply > MAY_READ: That doesn't quite parse for me, sorry. The point is that the script interpreter actually needs to *read* those files in order to execute them. Thanks, Florian