Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1497823ybh; Thu, 23 Jul 2020 10:16:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXw5dio3X3tQ++XgTr3RO0qh+V7jteUQ8A9kHpx1CpZ7IAOg1Zk0Lni+zZpFGMCTYgLMLI X-Received: by 2002:a50:e385:: with SMTP id b5mr5062975edm.130.1595524615362; Thu, 23 Jul 2020 10:16:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595524615; cv=none; d=google.com; s=arc-20160816; b=vr5o5UDNtDD0rcOzPZ5xXATdwtl5Te4OAOE+bz9AIbCu3q3tZLTu0BEeAbKmjbcCRs o5X4KNufrLOkJ4x2Zo3avvflST6c+rUOSQaf5Vpes9Xi4/KjqWMENzivGBmiwkUweUP8 JE60ZC5TPgD2eg0wJnh2CN2QrNsxsB5pejBDWpu3Wu/zlsBo+31uY4dh09MGRwo2OIzd WYkB85x2mOwt8qTs9TBtyVr4wOBh/YnVI7553fdwiPQfijH/9Humz9+pZZGCTtUUXmz9 cF0vSx0S6yrLwtEOeYOkI/0I81Wq0f/NmZ702YJHkR4xRMKXVUWwwg99jbgVozyTNk1e x8qg== 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; bh=+TADohyr4YHsshdwtDayZb3ipZECkoSqFf4G0fgfdKQ=; b=YeagzM+tEZAVPgnOPR8kMg4fhgFdie4luFwvqfA55gdOAe+owu0fs0g9VuWpoLJqkT TtFS9nSON7ZHr5pKVLjZRU+Gg8qdUAFB1QS0HQx7o+lJjAY/bNjBCBiUypyfB5iwt7nG Lq62irlITWV6ASVUjxy6cKtexqhrW00mfWmbNPLm38S6FHBQKnXhPwDX95o0bmvjlRnA Ug0ito0gF1DiwsxTftF4rGokb+ZaNc4lKR4ylw0E6DdJgqrBgfpvJzcSWHLvJUUCEJhP JUts7wbGagVyknRtbF2UYWGeqGp2e0eheoEJSLcL3CqMVy7PrrjqKZfTZHgTtlNpRQp3 AoPg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qp24si2660625ejb.270.2020.07.23.10.16.32; Thu, 23 Jul 2020 10:16:55 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730204AbgGWRMk (ORCPT + 99 others); Thu, 23 Jul 2020 13:12:40 -0400 Received: from smtp-8fab.mail.infomaniak.ch ([83.166.143.171]:50159 "EHLO smtp-8fab.mail.infomaniak.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730186AbgGWRMj (ORCPT ); Thu, 23 Jul 2020 13:12:39 -0400 Received: from smtp-2-0001.mail.infomaniak.ch (unknown [10.5.36.108]) by smtp-2-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4BCJmg4x5YzlhBbP; Thu, 23 Jul 2020 19:12:35 +0200 (CEST) Received: from localhost (unknown [94.23.54.103]) by smtp-2-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4BCJmc3sj3zlh8TY; Thu, 23 Jul 2020 19:12:32 +0200 (CEST) From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Aleksa Sarai , Alexei Starovoitov , Al Viro , Andrew Morton , Andy Lutomirski , Christian Brauner , Christian Heimes , Daniel Borkmann , Deven Bowers , Dmitry Vyukov , Eric Biggers , Eric Chiang , Florian Weimer , James Morris , Jan Kara , Jann Horn , Jonathan Corbet , Kees Cook , Lakshmi Ramasubramanian , Matthew Garrett , Matthew Wilcox , Michael Kerrisk , Mimi Zohar , =?UTF-8?q?Philippe=20Tr=C3=A9buchet?= , Scott Shell , Sean Christopherson , Shuah Khan , Steve Dower , Steve Grubb , Tetsuo Handa , Thibaut Sautereau , Vincent Strubel , kernel-hardening@lists.openwall.com, linux-api@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v7 1/7] exec: Change uselib(2) IS_SREG() failure to EACCES Date: Thu, 23 Jul 2020 19:12:21 +0200 Message-Id: <20200723171227.446711-2-mic@digikod.net> X-Mailer: git-send-email 2.28.0.rc1 In-Reply-To: <20200723171227.446711-1-mic@digikod.net> References: <20200723171227.446711-1-mic@digikod.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Antivirus: Dr.Web (R) for Unix mail servers drweb plugin ver.6.0.2.8 X-Antivirus-Code: 0x100000 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kees Cook 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: Mickaël Salaün Signed-off-by: Kees Cook Acked-by: Christian Brauner Link: https://lore.kernel.org/r/20200605160013.3954297-2-keescook@chromium.org --- fs/exec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index e6e8a9a70327..d7c937044d10 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -141,11 +141,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.27.0