Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp767095iob; Wed, 18 May 2022 12:29:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3ratv8F9P1p6HRdTDUg0a/sH07894q2EBkm27kBIhCIsYOQWA0T1DbIVGZj356d2Q0bkZ X-Received: by 2002:a17:902:9887:b0:151:6e1c:7082 with SMTP id s7-20020a170902988700b001516e1c7082mr1166011plp.162.1652902171257; Wed, 18 May 2022 12:29:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652902171; cv=none; d=google.com; s=arc-20160816; b=Wy4hlZcG6xhI7m16hiYAt4Krc5p+srsio2Pl+Wx2U1m8njTbhVkTeM+/Mvtdzab240 7aUauPDvQa/jVY6JQb8UVYQZfjBMRxgKEh1EB0cm543XjcMgPY3xUcZuKRWGWxMFIyZL bswruxLE5QvRAsn5uF101lN32uxszWUOflKhKhLwbqGzdNsaOIrk+25veoO+JBZCxDjM CSS7/BTLGgTteTZfRGSytyGrMWi22TKNcCv4nkkSVGA23jSXvA7XJmVL5632Tmbii9Aa hJml35hZBSOzal9l3+EiVIaWCqjxWVykeETnQfoZZrK1mkR/614xSIkva4t/mU8jWESd QR0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=cghNmhKNoKvwCW2TjFdjOBN9YXrFIpY21SlEKnCOwuk=; b=Lx34yMj5JSTig0cFnlWPFtKcAVAZgxLYPco1u1lJgCAgu5h0wNWszEKYVU0pw/t0QF xrOJme7UJe+Z889IoYnJUoweLbKtll3sCb51XbiOgcHfqw2RC/VDahJ7jlpXvqKiQeQU NEY8AxGlTkXnK87C/kEh2iW7CX7b0i75lRGNKNxEvlJiud6Vq6kixcoPsCDOoAU8XzfV 3gh7Qok/SZiARjm/c5+PzALWNztM+mwptuxV6CDiIIBLkvb/jq+p3Un3QjM/mW+cQRFC Rwe2sjxEMpUBU4f+AW9hiZkDvc+BjHTsilHbtpX4WCMLSEV/1aordRXScebWmy+mucJu +tEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="rHjG0g/e"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k6-20020a170902d58600b001590118e14dsi3591357plh.108.2022.05.18.12.29.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 12:29:31 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="rHjG0g/e"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AB5226128E; Wed, 18 May 2022 12:27:25 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241980AbiERT1P (ORCPT + 99 others); Wed, 18 May 2022 15:27:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241962AbiERT1O (ORCPT ); Wed, 18 May 2022 15:27:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C1BA5AEE5; Wed, 18 May 2022 12:27:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E8F75B821A6; Wed, 18 May 2022 19:27:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68640C385A9; Wed, 18 May 2022 19:27:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1652902030; bh=lmUg0JefmHdOdMZIz8mwoSC0s8SSSv+qaPcEDU25+Mo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=rHjG0g/e43nPj6fRg3NPpB8iajmZa0UDhf7m2CKsB260KAX9zav9wA5OXgAWAh0eP Nsr25+VbQh4yxYdueRXagZyR5i8ra1bh7olbnnTgmpzyTd5EWZg7BAyUDQCAwmZsFO covqEzrK+gPjFBXVWNJ2vivUTv/d9/qVrBnZT4iM= Date: Wed, 18 May 2022 12:27:09 -0700 From: Andrew Morton To: Kees Cook Cc: Zhihao Cheng , viro@zeniv.linux.org.uk, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai3@huawei.com Subject: Re: [PATCH -next] exec: Remove redundant check in do_open_execat/uselib Message-Id: <20220518122709.7fb5176967fb69324c260853@linux-foundation.org> In-Reply-To: <202205181215.D448675BEA@keescook> References: <20220518081227.1278192-1-chengzhihao1@huawei.com> <20220518104601.fc21907008231b60a0e54a8e@linux-foundation.org> <202205181215.D448675BEA@keescook> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 18 May 2022 12:17:45 -0700 Kees Cook wrote: > > > - /* > > > - * may_open() has already checked for this, so it should be > > > - * impossible to trip now. But we need to be extra cautious > > > - * and check again at the very end too. > > > - */ > > > - error = -EACCES; > > > - if (WARN_ON_ONCE(!S_ISREG(file_inode(file)->i_mode) || > > > - path_noexec(&file->f_path))) > > > - goto exit; > > > - > > > > Maybe we should retain the `goto exit'. The remount has now occurred, > > so the execution attempt should be denied. If so, the comment should > > be updated to better explain what's happening. > > > > I guess we'd still be racy against `mount -o exec', but accidentally > > denying something seems less serious than accidentally permitting it. > > I'd like to leave this as-is, since we _do_ want to find the cases where > we're about to allow an exec and a very important security check was NOT > handled. In which case we don't want the "_ONCE". If some app is hammering away at this trying to hit a race window then the operator wants that log flood. Or,umm, fix the dang race?