Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2463484ybk; Sun, 17 May 2020 22:56:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyieH0QdMgs237CnCVyrpjf0PTPPR2KuY7XyAo9Dg00km63Ep/y/8p2TdUztuzkSPgqj2Ed X-Received: by 2002:a05:6402:2213:: with SMTP id cq19mr8080377edb.337.1589781417376; Sun, 17 May 2020 22:56:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589781417; cv=none; d=google.com; s=arc-20160816; b=rPbpz6hED5uSlmc0LfPzJRxMAuZ3EekJy2xH7nYr+401HBvPizjO8sYUMdQPyXvZg1 aXA0yY3pxTI9SIujDdNQ7JBJWCkOBqgqdSpjB3bqN0T/8HPuXRrNXFOoISlwmOz19UFB r5yyzTwOwcHvJ2YPj+jwby8+bB5TPHtPboAccMNLys7Lj8BRuu3qRXG9d6PRL2GRQuh1 2Wtfdw/lhX8mMEoSk/QqESfhiWbQarS1BAf9qBjroVyhnerzzCDO8OYS+YVimdxjLDaW kH2ZtBDe0hthR33y72gJ7Ar1CSpJur61AhFs2hcTa8QSh66Q60KSw7OiEZAXY2rh3WNg hJQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=APDZcTihvmp7cHgWc/okOQoKAjV6ESC0p6FoG4/I2RA=; b=K1syfvdLgaYXaI6nG+gIfKjizlSTCxNBN5vMMYfkFaxTXQpGRBnvINVRXtbSB743b0 vsdtqftv2y3OeXR6939K89330bL58JGOCULqYTCj+bTcdficOW0UmMkhsH1FZJHZfL5I 3WNTV9QaHbOjc6ak+m38wu0VAAlXe24N7QjPxBXENWF8KUoxMi7tyBLDp8XIFErYqbyL Wgzl8k8pRtprp3o7BthOqpY7u11RanTcL2W7Z3ZJBLGhbdoYm+PT0yW5Oiag0xat+faF +czYIAATj1Win79Bo/IAbYqGrCDfgJv+HlAdbqapjjwm4B09qEMyVWD1/WgCeGVh2lie b3lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=B9zQ4JN8; 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 f22si4842785edx.79.2020.05.17.22.56.34; Sun, 17 May 2020 22:56:57 -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=B9zQ4JN8; 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 S1726946AbgERFzJ (ORCPT + 99 others); Mon, 18 May 2020 01:55:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726813AbgERFzH (ORCPT ); Mon, 18 May 2020 01:55:07 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C5C2C05BD0D for ; Sun, 17 May 2020 22:55:06 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id q24so4515936pjd.1 for ; Sun, 17 May 2020 22:55:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=APDZcTihvmp7cHgWc/okOQoKAjV6ESC0p6FoG4/I2RA=; b=B9zQ4JN8AYIxyezeNdzE6GbwPImYuyTUTkgaOcnyMLt8drlkAFBp16GCi7zqrrzQLS 8cfO9dxZUQ1n2upwY50jdxeXPLHMYTEgyOk5KPR1DbyAlCJGW0UAcLW7PB3jp/iRXGsT B9XN9hHhnUnR6ItW4QHqc4AmFpJzkGeqGudHQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=APDZcTihvmp7cHgWc/okOQoKAjV6ESC0p6FoG4/I2RA=; b=j1bsj+F7y85Om8RBkC+SINSndIcQxVqw0TiQVg49L1mRa74VV9aqRlKFlrfk95tX6R 5O9UCvHLjGSz2Vlt7MleexMGINaQpmYz0O9IKM0aKGMNwNZCmGKH3AmAK1Rxz7BBTgQs nSK0RR+wypBkIG82sJ1Go4jFcSZJWPTRFwzmkOIN3pvsXPWzlGPkUVG9v2uw4Li/Y/A1 R0x8rz0E2m1AIpvSr5N97ASIkofefAhu8GVbdhn6SpPiu+THTVejkQ1s9bVVs0qd1aSi CHobTv3//jRNiVDzl/Us+djumeY9kqhUNuMkK26udj7HKnkwzmZiL79yhB+1O+HLj/VS 2ODQ== X-Gm-Message-State: AOAM533UeFBmhxtxAgHQu4KzLPpV2agfp2vsIisiGzwpGNGQoBdabuIj IESI6oyNRZDnKfVIllQP+ofIuw== X-Received: by 2002:a17:90b:3650:: with SMTP id nh16mr16068611pjb.135.1589781305588; Sun, 17 May 2020 22:55:05 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id g14sm6734674pfk.174.2020.05.17.22.55.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 May 2020 22:55:03 -0700 (PDT) From: Kees Cook To: Al Viro Cc: Kees Cook , 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: [PATCH 0/4] Relocate execve() sanity checks Date: Sun, 17 May 2020 22:54:53 -0700 Message-Id: <20200518055457.12302-1-keescook@chromium.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, While looking at the code paths for the proposed O_MAYEXEC flag, I saw some things that looked like they should be fixed up. exec: Change uselib(2) IS_SREG() failure to EACCES This just regularizes the return code on uselib(2). exec: Relocate S_ISREG() check This moves the S_ISREG() check even earlier than it was already. exec: Relocate path_noexec() check This adds the path_noexec() check to the same place as the S_ISREG() check. fs: Include FMODE_EXEC when converting flags to f_mode This seemed like an oversight, but I suspect there is some reason I couldn't find for why FMODE_EXEC doesn't get set in f_mode and just stays in f_flags. Thanks! -Kees Kees Cook (4): exec: Change uselib(2) IS_SREG() failure to EACCES exec: Relocate S_ISREG() check exec: Relocate path_noexec() check fs: Include FMODE_EXEC when converting flags to f_mode fs/exec.c | 13 +++++++++---- fs/namei.c | 5 +++++ fs/open.c | 6 ------ include/linux/fs.h | 3 ++- include/linux/fsnotify.h | 4 ++-- 5 files changed, 18 insertions(+), 13 deletions(-) -- 2.20.1