Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp687233pxb; Tue, 5 Apr 2022 18:48:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJys6nuc5H0w9dcCrXffh8rsZkWlSa5y/OvLlUmrwmoQCAZjGf0qdg1txjopMIKAReaop7SR X-Received: by 2002:a05:6402:5cb:b0:419:14d8:4106 with SMTP id n11-20020a05640205cb00b0041914d84106mr6462214edx.140.1649209733643; Tue, 05 Apr 2022 18:48:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649209733; cv=none; d=google.com; s=arc-20160816; b=adylQv07z/YOEV/Ztvy039f3SrYB/luV/FfL8fcRZfOnh8ftzJ468Fy17UqzteJAny jFcvY/dUOkuheqaX3t97lB49ybCuYl6aEeKq1bHl84jRZKD/YHfCc+B9QV8HCCQJN1tX iQMSLMoGaGJu9I274PBpRwCQvr/QjtoifHk6S8pZ2XMPSK3iwGky6v9N7a4Dl/Y/QQfa +qnZ/he0mH5+gGi/WR6d45B8lHymZlvdf71Hv4ThXuA18SfL7vDxW5v3a9h67rl2XYkr 87TDRtx6DLeqzWzRDF98k8xS2dFZwbaxIVzFGRtkPUblCbnqfJ2G2FiU4wpnYoQzEEjG JE5g== 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=Wgo+oRnrmgpW/uoyrjrmlKVX50qFKGEYjZL8qniDEuw=; b=iBuu7dW6uq0sF6VL5EBaECcfGK+r1ln6i1/VfvhOXRG68iwnukU8M2QCjbfQaVm+o4 7hjBZmtM98UxXa022bCOO2KS5qPUIWSfhX+j8NbHr5qraDaGQovjwYsUMy08SNAJb8nQ togoYmvEKKeGV68n18ey7412jB1p8NvKS/fYHS91Jju6ujLvsWPGCAAq5n6gMwzq9Pnb zKvv//7WPW839LBsGXe6Ex6PT6PLHctrAZokOWiurb6IGcNyV9r9IxTv0Ak3fC04HR4G ZiSOqx6QezZVdTORb+7+/GxCHgP1CopEka07io56RX9GIaEHbRgp+lKWoNYAXh1+U6wQ lylA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=I2bmuKKP; 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 w7-20020a509d87000000b00419014273b3si10348185ede.354.2022.04.05.18.48.27; Tue, 05 Apr 2022 18:48:53 -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=I2bmuKKP; 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 S245412AbiDEPKY (ORCPT + 99 others); Tue, 5 Apr 2022 11:10:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345620AbiDEJnk (ORCPT ); Tue, 5 Apr 2022 05:43:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99723C29; Tue, 5 Apr 2022 02:29:29 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 8B4F4616BD; Tue, 5 Apr 2022 09:29:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95817C385A0; Tue, 5 Apr 2022 09:29:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150960; bh=4lI4hnSkgIv5RGKjm3QIurZf7pNPW8XJsLWWlKGO3Bo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I2bmuKKPIJkhNIp4FcGghFj7RKZsX1QqIQJR4oZGL9U7YwxS/1Mj/mEEFMlAerbPA muxszx6KKKkum2KqsBXYw58CTJ4trKe82wOkljtHlJ3x6M9wGD+IkX11zWT4DVl5E/ POBECA0EQJWA31u+wQjptfwRSjNTtEIrUIifuhOQ= 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.15 242/913] io_uring: dont check unrelated req->open.how in accept request Date: Tue, 5 Apr 2022 09:21:44 +0200 Message-Id: <20220405070347.111537778@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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 156c54ebb62b..70e85f64dc38 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -5154,8 +5154,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