Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp665983pxb; Tue, 5 Apr 2022 17:57:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyd3VmuVNsVlo57V5MZX9Y/JQZfwkMUk2DxFO5dzjfMrtrYoXjCzkbS9IsCZB/iJWEsl44o X-Received: by 2002:a17:90b:1b52:b0:1c6:b689:813d with SMTP id nv18-20020a17090b1b5200b001c6b689813dmr6958462pjb.186.1649206652719; Tue, 05 Apr 2022 17:57:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649206652; cv=none; d=google.com; s=arc-20160816; b=w+nmrTCJMJe4xtF4e8ZmU1bviKGhUpUki/i/+WwOC/PQVX7kHfKaavwpxHMuaF5aa+ 5+o0HfAFzoH5jcY6PP19sdNdztxCzHGgbzUkrYXT9XRZkp+ZbyrfR2IRXFy3gwjuln5a lgv3MVVeo2xiE5jRCvbp+1V2hfyiH9Eb2YUkuCzIThHddbifp4Q9rr4SD0LWQeC+UU4i Y4A9L/9nfg1dpfEAfHpvGBVChy3ivn9m8GAGOwmqaHHPRzYWHT4otmqu1EF21Y0yENXs 2OiFkzGDJzTH6hA2YUr95Z3jMuSit4ZWXWk8/W3wMGDsIBOVa5x/KnfV6aal9NAYUfN8 tA1Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kZgK/wvytXPZadJXMjqvsYWba2ZXuQYPIc/3Ks1crCY=; b=vj/JL46yFlQLUMb55CiHvk2afu8HCIBfT1rMHo0UP16Pt1dAHiVemDpt+jMUvHX1dM 7UY2tmRiqTrNPHrsSPQHKzS0UdftYvzSpWKwongUFs4BW9reKqQca5qQepai71cR/slz W3D+X+gqKt3ohyRRgy3MZr2Tydv50kU0gblXgXAWnKCLpKfIJwFIVLIpQwZCB0QlEoEc c3tg7jMXU8+7JOATVaNId+86vYkzrq76tsUGFemVc3BC+dlfp5JLsH1Jbs6IFblKW9RF ul5PSrapUdKvHm+FtNrF6xVn7b9qX2A7DvBFp0uP7C1n/RPiFafTat1BBQR/JmzRYo7X wtbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=L8DV7l6Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b16-20020a056a000a9000b004fade889fd0si14944930pfl.15.2022.04.05.17.57.15; Tue, 05 Apr 2022 17:57:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=L8DV7l6Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238429AbiDEIag (ORCPT + 99 others); Tue, 5 Apr 2022 04:30:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234474AbiDEH6g (ORCPT ); Tue, 5 Apr 2022 03:58:36 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C05C7A205D; Tue, 5 Apr 2022 00:52:31 -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 47940B81B90; Tue, 5 Apr 2022 07:52:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFB7FC340EE; Tue, 5 Apr 2022 07:52:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649145149; bh=jnkCMnl/4rUMdPzGe48qoPlC/WeFENB7x3XyNchNE/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L8DV7l6YsIwSw2HMVO53vDnWu9Z0VBtVxCDKUXRgszn9yLKw8tzhK96umcreyhXU2 e12hP+16ImrXefm+3a28mPXGuU3UTAnXy5fxpveCwUsvKt7DxgreV9SONjn1b8cYSj 6vdBQW7dsHTcPNC+FcIhg/060BG62ubKlPQdTius= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jens Axboe , Sasha Levin Subject: [PATCH 5.17 0264/1126] io_uring: dont check unrelated req->open.how in accept request Date: Tue, 5 Apr 2022 09:16:51 +0200 Message-Id: <20220405070415.360010671@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: Jens Axboe [ Upstream commit adf3a9e9f556613197583a1884f0de40a8bb6fb9 ] Looks like a victim of too much copy/paste, we should not be looking at req->open.how in accept. The point is to check CLOEXEC and error out, which we don't invalid direct descriptors on exec. Hence any attempt to get a direct descriptor with CLOEXEC is invalid. No harm is done here, as req->open.how.flags overlaps with req->accept.flags, but it's very confusing and might change if either of those command structs are modified. Fixes: aaa4db12ef7b ("io_uring: accept directly into fixed file table") Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- fs/io_uring.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 1d79e5548de2..5ea7650b74eb 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -5264,8 +5264,7 @@ static int io_accept_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) accept->nofile = rlimit(RLIMIT_NOFILE); accept->file_slot = READ_ONCE(sqe->file_index); - if (accept->file_slot && ((req->open.how.flags & O_CLOEXEC) || - (accept->flags & SOCK_CLOEXEC))) + if (accept->file_slot && (accept->flags & SOCK_CLOEXEC)) return -EINVAL; if (accept->flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK)) return -EINVAL; -- 2.34.1