Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2904977pxb; Tue, 24 Aug 2021 10:16:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7oSfWUl4SH2lt5PcujIK3e6yBozbcExnkdM9Kjhlicffb4TAKNLcRZPS5AgEo+PdfCPvK X-Received: by 2002:a05:6602:2597:: with SMTP id p23mr32324388ioo.195.1629825403505; Tue, 24 Aug 2021 10:16:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629825403; cv=none; d=google.com; s=arc-20160816; b=WSRMZhhPhMZtJ4dE9e5g5T1h+oD7reSpb4MQICWRBbC6sUelgHy3oasK/qj9CKBo+p X0fcTGKyWAg90CgU+lLwV7jgBG7hN0vIfg6sSpI2I52tMwvcHVADMdZXXzVEOFWp54Uo tE+EYbHaplXwGJALUAucnIBIagm+BK5Nve/Nxz+le0y996ElC9rsA4+3tJj8M4yT8p6o Ydfkgl5zwxVwzbN9Y5S6Fw67Xj36+R9dTgGEpkDsAdXkGVRAGYj5nDGt/bvCkhjE1t7a a1bfCs7n+P9BDDa30+Tyy10OhHUfjO+5iS7/a7/rzyo6gcrRu8SWxfwjF88M8pHaU0Bg IKGA== 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:date:subject:cc:to:from :dkim-signature; bh=qolu0uEAte/XHqLf/Yz3yV8LqDi6xTtWJV0LOPC+7vE=; b=Cd65kzERsvMkGTsbPhFM5P5BRVaV/g8s6kkdbX2K1wU0vK5OMbo0IPTTFp+R+bY+1G K4udozUMTHli4yHhdelEbU929/K3zvlskdfwnN3TdJS1EvpKRxLCeNjdLP9ax9eDAFvl LEjGaPsOmz3l0kChKmI6Os3M/VxYGN2FT5CLMYDoCgTrm/xHm9jrSqi/ic37Fl4OiC7q yEjE5J1iUaM4nbm/sC2CQDClgs6G3J1K/rZ16qXP10BtMxR9zyxS+MPM2ocX55p9pac6 HNsWLpLRDrc1y6UxtqMTazWiRb13n6BADPlY6DSZ5eMCeVkkCiXSENTx/dBKMc7tQT7E aCLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VrBCm20i; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 20si17429261ioz.25.2021.08.24.10.16.27; Tue, 24 Aug 2021 10:16:43 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VrBCm20i; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239576AbhHXRPA (ORCPT + 99 others); Tue, 24 Aug 2021 13:15:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:51262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240299AbhHXRLF (ORCPT ); Tue, 24 Aug 2021 13:11:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5ACEB61A0B; Tue, 24 Aug 2021 17:00:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824445; bh=7e49G3toGPZPMhvrxxtODANFvIKMmozXSQzKa+JsLSE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VrBCm20ijQqcDeq+2M+HOkpuBUefH6E4grjizKKAgqTWZlUWxSwP/rt4+WHgabDUY TYFBJm04HtWEx6Tk+j+heWayjQMOUd6HQSPTK3rcZDZDrlUPIX0ZwH66gOGFm1Xsho su494TyuDvYV9vcLffY0YVyTxyFTzbUTGIizQdFXAzL55gE7kPz4At9kyHuE1PdtnZ 40w9AzJO89OKoPTQj5dXcb/EQ4lKDEhz4SrF92tMtUDgviQOajmPbBUtW3ZmXkN9Mo u81ZLuhGnIKVP4imGxzbhMmBQ7oC7bjxI27FUC17gVDZ2Eg6mXYqVcHUAxo3Lh1A0I 4sn2ds9o9yeKw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jens Axboe , Pavel Begunkov , Sasha Levin Subject: [PATCH 5.10 96/98] io_uring: fix xa_alloc_cycle() error return value check Date: Tue, 24 Aug 2021 12:59:06 -0400 Message-Id: <20210824165908.709932-97-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210824165908.709932-1-sashal@kernel.org> References: <20210824165908.709932-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.61-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.10.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.10.61-rc1 X-KernelTest-Deadline: 2021-08-26T16:58+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jens Axboe [ upstream commit a30f895ad3239f45012e860d4f94c1a388b36d14 ] We currently check for ret != 0 to indicate error, but '1' is a valid return and just indicates that the allocation succeeded with a wrap. Correct the check to be for < 0, like it was before the xarray conversion. Cc: stable@vger.kernel.org Fixes: 61cf93700fe6 ("io_uring: Convert personality_idr to XArray") Signed-off-by: Jens Axboe Signed-off-by: Pavel Begunkov Signed-off-by: Sasha Levin --- fs/io_uring.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index ed641dca7957..762eae2440b5 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -9601,11 +9601,12 @@ static int io_register_personality(struct io_ring_ctx *ctx) ret = xa_alloc_cyclic(&ctx->personalities, &id, (void *)iod, XA_LIMIT(0, USHRT_MAX), &ctx->pers_next, GFP_KERNEL); - if (!ret) - return id; - put_cred(iod->creds); - kfree(iod); - return ret; + if (ret < 0) { + put_cred(iod->creds); + kfree(iod); + return ret; + } + return id; } static int io_register_restrictions(struct io_ring_ctx *ctx, void __user *arg, -- 2.30.2