Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3167714pxb; Mon, 18 Apr 2022 17:54:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypfvrYZt34q1fg6MQ2ZT+oGYUdKu9p58ibSapvB+qrdlnNRVscEv7yy+0Ui5FjxPo4jNqR X-Received: by 2002:a17:907:c25:b0:6e8:9e29:2322 with SMTP id ga37-20020a1709070c2500b006e89e292322mr10983066ejc.66.1650329693566; Mon, 18 Apr 2022 17:54:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650329693; cv=none; d=google.com; s=arc-20160816; b=S9sEgelVOzRhn9oR9+0lZsSpzn6yGEPiXPadFvJvl9vhfx6J9U/8la5qr68zriZ9us 9SMA6TGtmqwLu2xjUX350qMXVAMWBRhaoZomqNlxhdRelufKM4ezyToKYeElnmvvRuPG SFEzAIFsMP/kWukQ7mt4lxLtwWwKAFA1YeEKPobJFSZOjt2C1bfvWd3LewakpnPnOS4l YuBGTqf9ei+Y7pFq/oz2i6gIfX1zWQce2R2ZJ4Be5EVWM2AZH3Wux9RTN9PuRfNYiAhs bB+c1vNlyMW1Cip/xrCKWI1O2m2LZUJw2y9n2Pu2KoLbSuQLXHn5cwS0fDbBJcBTpxT5 G2RQ== 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=0Eb6Y7B5/3tHxlRq445qaAf+iaGNlbulZTsbfF2qBQ4=; b=WKjUi2wDrG9hg+p0RVGUcACrUn13LZ18Wb3xQ7Ejh6phEh+0Fmtp9L5k/X8Drbihk9 KMqMNOyC6nEXXKjWFR8S6xquFxiBeaDw5bwAKAXVofCT6LcWkJiZIHHF0eyhuUFR7efB XGuYGi+2iTrC9Rcj9xNaET03KMKmHd0O2yGi0U1hCOrJQ7OdY85l9zksrWnaHrbs2GnZ y7/F63YxxhPD+86oFLIdNGBrAiFBbGuyeWiRt7R3Mck1whLeEtItUfqNjAMVQ3VgMZ1A h1/ycwenXHICLt2cJrFQWUyot9WYILCOBNEbJ3wR6mzrBByrK4aRDd6pIlSTnwMrAROv lbqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UJjt9ybm; 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 js1-20020a170906ca8100b006e6f361280fsi7120896ejb.724.2022.04.18.17.54.30; Mon, 18 Apr 2022 17:54: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=UJjt9ybm; 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 S237513AbiDRMhY (ORCPT + 99 others); Mon, 18 Apr 2022 08:37:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239027AbiDRMbi (ORCPT ); Mon, 18 Apr 2022 08:31:38 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EBD7252AB; Mon, 18 Apr 2022 05:24:03 -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 sin.source.kernel.org (Postfix) with ESMTPS id DA664CE1099; Mon, 18 Apr 2022 12:24:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDF49C385A8; Mon, 18 Apr 2022 12:23:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650284640; bh=saIBfUiOO9oi8JxUXD5UmunFw+zU/h9YE0bVKwbuzVI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UJjt9ybm6uIqFWWHCsodVV6FJkCNVyOezB1A+DoJtImZEMu11qgZ1Vt5IlsVCPYlM xVTL4hNJJ0+YGxUg+m/EgnNp9VyHBHcPGL9kNjIxxeM+2P0yYY6lt9KdlKRc9lU4vO +8ZTETrROtFBG1ExG8GBrjpSbgfU8K/paKQTotGs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Begunkov , Jens Axboe , Sasha Levin Subject: [PATCH 5.17 173/219] io_uring: use nospec annotation for more indexes Date: Mon, 18 Apr 2022 14:12:22 +0200 Message-Id: <20220418121211.721539889@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121203.462784814@linuxfoundation.org> References: <20220418121203.462784814@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.7 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: Pavel Begunkov [ Upstream commit 4cdd158be9d09223737df83136a1fb65269d809a ] There are still several places that using pre array_index_nospec() indexes, fix them up. Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/b01ef5ee83f72ed35ad525912370b729f5d145f4.1649336342.git.asml.silence@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- fs/io_uring.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 53b20d8b1129..f0febb2cb016 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -8613,7 +8613,7 @@ static int io_close_fixed(struct io_kiocb *req, unsigned int issue_flags) bool needs_lock = issue_flags & IO_URING_F_UNLOCKED; struct io_fixed_file *file_slot; struct file *file; - int ret, i; + int ret; io_ring_submit_lock(ctx, needs_lock); ret = -ENXIO; @@ -8626,8 +8626,8 @@ static int io_close_fixed(struct io_kiocb *req, unsigned int issue_flags) if (ret) goto out; - i = array_index_nospec(offset, ctx->nr_user_files); - file_slot = io_fixed_file_slot(&ctx->file_table, i); + offset = array_index_nospec(offset, ctx->nr_user_files); + file_slot = io_fixed_file_slot(&ctx->file_table, offset); ret = -EBADF; if (!file_slot->file_ptr) goto out; @@ -8683,8 +8683,7 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx, if (file_slot->file_ptr) { file = (struct file *)(file_slot->file_ptr & FFS_MASK); - err = io_queue_rsrc_removal(data, up->offset + done, - ctx->rsrc_node, file); + err = io_queue_rsrc_removal(data, i, ctx->rsrc_node, file); if (err) break; file_slot->file_ptr = 0; @@ -9357,7 +9356,7 @@ static int __io_sqe_buffers_update(struct io_ring_ctx *ctx, i = array_index_nospec(offset, ctx->nr_user_bufs); if (ctx->user_bufs[i] != ctx->dummy_ubuf) { - err = io_queue_rsrc_removal(ctx->buf_data, offset, + err = io_queue_rsrc_removal(ctx->buf_data, i, ctx->rsrc_node, ctx->user_bufs[i]); if (unlikely(err)) { io_buffer_unmap(ctx, &imu); -- 2.35.1