Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2463739ybk; Sun, 17 May 2020 22:57:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6cTLXNIzpFA/3KIzwOmJCRNF5geAvv0VmfbXIDlUBWETG2sQh5GfAl6MVGBbpk85DSTMy X-Received: by 2002:a50:d65c:: with SMTP id c28mr11561896edj.21.1589781451812; Sun, 17 May 2020 22:57:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589781451; cv=none; d=google.com; s=arc-20160816; b=wf86oxRWK1mDx6iv46X48mbQsNb2GZMDQGcxLBjhMm59XX3Y0neW6/bwffei/qN3Xo CR2NwSHvoYeH3ZWd0X7avqBaV6MY5fOU6J0dVfpxh5yB5rhXl0jnJNdyMTrFZg9HEz27 z5R3qF/ZGhjbISXZWb4trhNocNkUmOUjPRcX5CnjzulPu0DBS73VpGv/Aamr/yoChD/K RF7H+Oyvg0Kp3dSi+3xmMlr8y0KCHa3THamuPb9d4VTwC95DMNItITkv3QjkxfgNYiYN mU6p09/7QgVDwoYX1R+ZQTDhe9DNoQGcQzRt92BWSh6y3f+KbeE+uqtMlP80a7m4VG1f EioA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rPKPZdLWYhVxpx5jrV/H8h0jtqWmPX7wH6A62qnOkus=; b=Z74arvyupEISoXlH9siOtVxKPmYRbKAfx3x2DzLkSuB8z1O4wjduguE2Bsj0m9D/7c loxTHexcVLHQwJgiGeNjoaPzJeJandfjW67oPRkzZe4wsoC6mcF/7mxlAQMfaxeGQKjA TpYH9lK2aXizldMQXuT1AJAOdPhI7U/Eu1v/KDU5IwB2ek6ANdwh2Oxs24VqMfz78OKN QlpfNGylDLFcDz4yk6bVm3j1NIvL/jpGBB5OScnOrSdV0DQ84qyDhG+y7T00ICNIeA+V QxI/gYnRChoLkAmmYiQF1Rw6U0Sf2+3pW4Jmown4rT/uQPxsRF4XBBldmwwN66a/uqKc rSCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Kdpre7Ex; 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 f19si5217863eje.519.2020.05.17.22.57.09; Sun, 17 May 2020 22:57:31 -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=Kdpre7Ex; 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 S1727003AbgERFzS (ORCPT + 99 others); Mon, 18 May 2020 01:55:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726907AbgERFzH (ORCPT ); Mon, 18 May 2020 01:55:07 -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 94802C061A0C for ; Sun, 17 May 2020 22:55:06 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id v63so4450692pfb.10 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:in-reply-to:references :mime-version:content-transfer-encoding; bh=rPKPZdLWYhVxpx5jrV/H8h0jtqWmPX7wH6A62qnOkus=; b=Kdpre7Exr/pMZGU8QiObZ4ZYPthvQzzf5UzH9ShzOMaqB7qV271cLqRWRlDhna2jMb DVm/UT04r0HB83+/3jJJjOf0vEXktU3iLJWXT+ixvegZsUIA5oFmKv2L6Qos/AG5/Kr4 NUb7howiZnwR14Y8/i+ox9g0yzgIzizw7d/L0= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=rPKPZdLWYhVxpx5jrV/H8h0jtqWmPX7wH6A62qnOkus=; b=Q87ba5NihBW/vAAmVnsIkmckiCLjhy98yyVtzKYq8Cr2pB6toqiPfprYnZcxLCjNLh WTbc+zuV9klDncRKZh8UHpdcUtPX+zaUE2LU7QrjgZDy+56jonxzCq1UWX3xKjXjw3pf A648F82ntC8CfIZYMvYqvO6IsWQui3z/InPJrLnxVymxnfEUCt9kdNRxmJtH87bulJ5a 7A7YwDJeIyvATUBfiMTi5k8Q6WCI0ZF2VO6FnL8P99CnVNEb5cLZ4HD4clCMnME0UrvQ 0vXeOjyaMgkZIkCVe9/bhPhCyPmvoVC+x1EqZ1EhjFqOHOygvy1jvTYQmp2/DCAitEcA weLA== X-Gm-Message-State: AOAM531J21YQsoh9LHvx0AMygExb5QjY/mD8p09nfj6bK5ysDq/P2Jwt 6rLEug0b473Ma9QvqVc/xmuiOw== X-Received: by 2002:a63:2bd3:: with SMTP id r202mr13454738pgr.130.1589781306161; Sun, 17 May 2020 22:55:06 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id k5sm7490235pjl.32.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 1/4] exec: Change uselib(2) IS_SREG() failure to EACCES Date: Sun, 17 May 2020 22:54:54 -0700 Message-Id: <20200518055457.12302-2-keescook@chromium.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200518055457.12302-1-keescook@chromium.org> References: <20200518055457.12302-1-keescook@chromium.org> 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 Change uselib(2)' S_ISREG() error return to EACCES instead of EINVAL so the behavior matches execve(2), and the seemingly documented value. The "not a regular file" failure mode of execve(2) is explicitly documented[1], but it is not mentioned in uselib(2)[2] which does, however, say that open(2) and mmap(2) errors may apply. The documentation for open(2) does not include a "not a regular file" error[3], but mmap(2) does[4], and it is EACCES. [1] http://man7.org/linux/man-pages/man2/execve.2.html#ERRORS [2] http://man7.org/linux/man-pages/man2/uselib.2.html#ERRORS [3] http://man7.org/linux/man-pages/man2/open.2.html#ERRORS [4] http://man7.org/linux/man-pages/man2/mmap.2.html#ERRORS Signed-off-by: Kees Cook --- fs/exec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 06b4c550af5d..30735ce1dc0e 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -139,11 +139,10 @@ SYSCALL_DEFINE1(uselib, const char __user *, library) if (IS_ERR(file)) goto out; - error = -EINVAL; + error = -EACCES; if (!S_ISREG(file_inode(file)->i_mode)) goto exit; - error = -EACCES; if (path_noexec(&file->f_path)) goto exit; -- 2.20.1