Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3704369ybk; Tue, 19 May 2020 10:58:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUV1apW/twJRFw/Y/JBRWtwuwf4nG/zg6k2sDMkPI4QPZWeLKY9rFS6xSJ1dIUiKIf/ryn X-Received: by 2002:a50:81e6:: with SMTP id 93mr127157ede.45.1589911099705; Tue, 19 May 2020 10:58:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589911099; cv=none; d=google.com; s=arc-20160816; b=mGG2NaoRonOHcBki9Lpuxdd4QFiKLYR+2sjdv80f1hmUu/c4dXcSKZH5GKyRH8DTdP gRvnFmzbqQg8bCxOjVutL7dzhYsgJqBiQ/kmWJ7aGyJyjKfzIkk0h8eYvzBfNAvhlRmZ 2LG0sDCn5UjM6n6aennzWITUIhq9KYLln/4kWt8jXAAxuwl2VZBgYl4bzbIQSsRjL5tU fFRr9jOeJP2LrUoSFJKtVcl6vev3VdnrbcOyCZGWT+vTSastIFyyXUWWD4hxXortxhkg HVI+HBVy72z1yCi2ULHI3rtlVukwcC18Z4ZZ4AXHaYkX54nx3rQz7InNvcJDDZ0IWOjv w5yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=bvPQ8PG+BL5wX2TZOP1m7rPVaLoET/IH7Hd3kojoQ1E=; b=mhGR8QIBY+jDf1W2CsCZl9bmOX/ixZFm4ncG42cZjc2eE88PznA1CC9SjSe+mkRTMc fUj7cUSSgW3Fd8FgMxAPKFN3BKuUolaSoFgAwyER7Yv4CIpRpEPKpPl+bjyKDNbX2xm3 Mouk3RzY5F4D2Ow/EED9QxrxfwnWf/JK6lfiXWUCyXBMiqy8bZ3SNtxdnN8heK9P5Mp6 QpOEy9jItrT/EzYqO9qEPQabGwF8Z2UH6UvP8ZnOADfacspKxfXTh1UHgaIm9IlOG92P qgDICYy8pM4mCoOBdJ+DgjfLSgIuK4oaLlW9kSwr5vFBEjJNpJePPCttfb5I12QVobkg aNlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Hky+N80H; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x14si350018ejb.0.2020.05.19.10.57.55; Tue, 19 May 2020 10:58:19 -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=@chromium.org header.s=google header.b=Hky+N80H; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729365AbgESR4L (ORCPT + 99 others); Tue, 19 May 2020 13:56:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727045AbgESR4L (ORCPT ); Tue, 19 May 2020 13:56:11 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DECADC08C5C3 for ; Tue, 19 May 2020 10:56:10 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id y18so249764pfl.9 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=HCjHkwXIKUQ0V8l2k7HyaqVOBvHYMpM3cJ/6FLQYdlcjAklQDoFFYYfLnplZBMfO0i uCJIHxZWo5RaUONvFPfxWNucCWsMOzE/f+XlqHUIT2Nlmk4viovfc4hU/FPdG/fcoHMz 6lTaAkAetmpwRPXcaAbIwTPXUeAn3hPymbW2be7SK/du3I+Onuyb3E7u1GJoJucffAPC HJhYRCV5uNF1346j38PSCmXvvjupOuQVklgJ8lR5yJIL+hLdFnrlQ06L2GjCNL40d3tC 7nVWBBK7k6IBln+l8YmcBLwqjoaorKXmf04BffUr54rn6PApf7v/ZJSixo8fxp/kftGm DM8g== X-Gm-Message-State: AOAM53031tBhjRQrAW3l8GNVQQ1QOu+359+syeGLnMJep7cQO5LkZtwQ K1j1j2Zq0oXcnlrp3f43xzxjCg== 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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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