From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0475EC433E0 for ; Tue, 19 May 2020 17:56:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA86F20823 for ; Tue, 19 May 2020 17:56:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Hky+N80H" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729267AbgESR4L (ORCPT ); Tue, 19 May 2020 13:56:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726862AbgESR4K (ORCPT ); Tue, 19 May 2020 13:56:10 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAAC9C08C5C1 for ; Tue, 19 May 2020 10:56:10 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id t11so198671pgg.2 for ; Tue, 19 May 2020 10:56:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=bvPQ8PG+BL5wX2TZOP1m7rPVaLoET/IH7Hd3kojoQ1E=; b=Hky+N80HoOFgfGKHD5Eup/gUyJFTK88WweMFonjdT9tSUPmNG72SgnOZF3mV6VetX+ kpJJGqHfyMQcwxAGOa3cXhLR1cEB0br0jZFXk0GhvwW+yBElVfXnEvEV4ogPkfSMFY1L YXu3Xu0EQhc4J3CHqb2xuMenLGSQGnocx3VdM= 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:in-reply-to; bh=bvPQ8PG+BL5wX2TZOP1m7rPVaLoET/IH7Hd3kojoQ1E=; b=n8iDJLQlmduLif8scnfecJsw2v4QEYqSMq47EW1hlPMiVmPZ34VGPTDQZjbIsVsb4k umLm4iAiEeTjHe3exfZoycRRqA4095EdErQRHvAIwpKW/44yYtVamh6z7pzc0ZbIoywC YMQMccldmGF9xrUN6nARKhppOSwYXLVcGCbh/6VtnetYR5PSE095Uj//DTZB2CdYykCZ +0uHh4GqlhON9jdoc5eAZGNeIBdfib5ui4MykPFdf5QYW7a2qCwxdeXeUth+E+Vep1oR ve8jMfyLOVfabDEiiblcJtdEqZv8qq7oVZd29jE+FMiCKfTXzZjn6SDC07HRTnSL+H9k jSog== X-Gm-Message-State: AOAM530yvKr7Uo3uQih5TVSmpASU8eaB/QlN63aJJ0PO1RA5zO4AuI/b mDidDpPgbkqvN7nP09ab6oatJMMK164bzg== X-Google-Smtp-Source: ABdhPJw8wB1OuO4CBC5eeyAgZiGGsmQzCblUtTfTF7mycU6U4/dgYRE0e9vM9WK6gUSzh8ALn6RwzQ== X-Received: by 2002:a05:6a00:d2:: with SMTP id e18mr288632pfj.252.1589910970277; Tue, 19 May 2020 10:56:10 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id x132sm113693pfd.214.2020.05.19.10.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 10:56:09 -0700 (PDT) Date: Tue, 19 May 2020 10:56:08 -0700 From: Kees Cook To: "Eric W. Biederman" Cc: Al Viro , Andrew Morton , Tetsuo Handa , Eric Biggers , Dmitry Vyukov , linux-fsdevel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/4] Relocate execve() sanity checks Message-ID: <202005191052.0A6B1D5843@keescook> References: <20200518055457.12302-1-keescook@chromium.org> <87a724t153.fsf@x220.int.ebiederm.org> <202005190918.D2BD83F7C@keescook> <87o8qjstyw.fsf@x220.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87o8qjstyw.fsf@x220.int.ebiederm.org> Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: On Tue, May 19, 2020 at 12:41:27PM -0500, Eric W. Biederman wrote: > Kees Cook writes: > > and given the LSM hooks, I think the noexec check is too late as well. > > (This is especially true for the coming O_MAYEXEC series, which will > > absolutely need those tests earlier as well[1] -- the permission checking > > is then in the correct place: during open, not exec.) I think the only > > question is about leaving the redundant checks in fs/exec.c, which I > > think are a cheap way to retain a sense of robustness. > > The trouble is when someone passes through changes one of the permission > checks for whatever reason (misses that they are duplicated in another > location) and things then fail in some very unexpected way. Do you think this series should drop the "late" checks in fs/exec.c? Honestly, the largest motivation for me to move the checks earlier as I've done is so that other things besides execve() can use FMODE_EXEC during open() and receive the same sanity-checking as execve() (i.e the O_MAYEXEC series -- the details are still under discussion but this cleanup will be needed regardless). -- Kees Cook