Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9106512pxu; Mon, 28 Dec 2020 06:48:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzYZntnMwufa5HxjNXwyHqdU53gOd6N5JRIJ3qt1Tkg9cJJOkJWy3Y51rsmnBmkjrizxNYB X-Received: by 2002:aa7:d75a:: with SMTP id a26mr41261040eds.230.1609166908063; Mon, 28 Dec 2020 06:48:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609166908; cv=none; d=google.com; s=arc-20160816; b=c0nZobtap/Y0aWt5tMRqccHD057+f2y74AszIPKrLM/p5SGIvvQLmvXsgPENbo6ze9 ncDO/UndVUNi6VfPxH3ozh9cNHZYLOsHUhrHmwmQ8SNTAMM1U9ryBNI4VimoBSGk3Wy7 BA01R70PeIO7+1RLwmSc0U4Tu/HqOVfByK1SiaKUjfQB8oY48hLZNl9MR8PjLVSmx6lh oFsyKQ+D06Z7IptZEc/pMrRen1umN3q654+/+2M8vx/9HHK7ymfN2/bxAwLN9C0AZzUw hNLW04Zmu2+ufDFqgr0HEw23afL9ZPDi+EluiCxe+JwRnjUCpbNwhoKTjitNen/+QBnh BeOA== 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=VrXdzcNndJ7IEz5MCsCsByb+ypsGMx3eEm2YBdjp8Y4=; b=AZvIi9xxl30hEpZDp8/mtcsvSQbQIY8EnAU3JpJo8B+lYHyufdu6Ug3n8DMYn1MqEq qfVlQ2cG6jDGuyhzNTskTSAwh0BlrCw+Kis8Pgg8MBZTZ0q0GTJgRqgKA0dBSeYZywZN uuDQG48u39IZZW7uljiIYKVQJctO9c7gSigbPbbCRTggVoPwX1cVNP4p9ivFddpQpV/g 1U3OdkEIssDvkcyeTKRpBhCXciUcbD3oUTiMv0+vn4C4pu7YzcAf3beCgcNEFO+GXtiB o3aagecwbKG+zfxxcmGjVx9g9gdwof4Yi/Dfh+BeaX4v/bDCXTugtbNKlfJead4tzHm1 vMGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HtrjKUKa; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q8si20030132edg.582.2020.12.28.06.48.05; Mon, 28 Dec 2020 06:48:28 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=HtrjKUKa; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2506485AbgL1OqZ (ORCPT + 99 others); Mon, 28 Dec 2020 09:46:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:60164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502963AbgL1OYB (ORCPT ); Mon, 28 Dec 2020 09:24:01 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 72EB720715; Mon, 28 Dec 2020 14:23:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165401; bh=bTQkqp/PABeLeaAi/Wx0IXUkq0ZhYGPMbxJITZfMGUM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HtrjKUKawmtuZnfyk/rEgGxbMDxM29FqxiO4K7BlvixPtDrMI0adcY4ySmvgky/g6 rqDHReoq4UsxxjX4MRA1o67+Tzu0QNPdFzMk6KY5y8JcLE9f4sqxkoOLUOZd+4Ax7p vC2J+u61KhrzTTMl58oxIGJeOCETqtT3nFGNa9yc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Begunkov , Jens Axboe Subject: [PATCH 5.10 519/717] io_uring: fix ignoring xa_store errors Date: Mon, 28 Dec 2020 13:48:37 +0100 Message-Id: <20201228125045.824895237@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Begunkov commit a528b04ea40690ff40501f50d618a62a02b19620 upstream. xa_store() may fail, check the result. Cc: stable@vger.kernel.org # 5.10 Fixes: 0f2122045b946 ("io_uring: don't rely on weak ->files references") Signed-off-by: Pavel Begunkov Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/io_uring.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -8708,10 +8708,9 @@ static void io_uring_cancel_task_request static int io_uring_add_task_file(struct io_ring_ctx *ctx, struct file *file) { struct io_uring_task *tctx = current->io_uring; + int ret; if (unlikely(!tctx)) { - int ret; - ret = io_uring_alloc_task_context(current); if (unlikely(ret)) return ret; @@ -8722,7 +8721,12 @@ static int io_uring_add_task_file(struct if (!old) { get_file(file); - xa_store(&tctx->xa, (unsigned long)file, file, GFP_KERNEL); + ret = xa_err(xa_store(&tctx->xa, (unsigned long)file, + file, GFP_KERNEL)); + if (ret) { + fput(file); + return ret; + } } tctx->last = file; }