Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp2101533pxu; Fri, 9 Oct 2020 08:02:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8xG14yH2NbQ6UR+aW06+UkAodztf1u7vVdFzvqeAGt/iCl9rhhQ1bRtgZpCYjiO2UWEmb X-Received: by 2002:a17:906:e0cb:: with SMTP id gl11mr14532358ejb.486.1602255722894; Fri, 09 Oct 2020 08:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602255722; cv=none; d=google.com; s=arc-20160816; b=kHf3EncShB8bSwUr5RYCnFwU3Low74DvBVFVK7xyaSD/t5YDRq8YUqGvRzEYgiWats 5xVsEeyExB4OfKi9Ud9DB+6+mymFdUk9Cmm9be2+oo6261eD7IWNbcT03/P6rndiLG1S AFt/84WgVFehwxpWgq+SI9n2o/f8yPfhVl5Ux0tSjgcsGovWbKQFJndjo60FUHx5GIKV y/RYcU3dIUkPHHgLezuI2w/nChNh3e4s7m90RoXgSd/Ghxw7JDfCP5Srxg0o1RbZXkzM ZmajIEzlN8H3LCd3cQxx+dQOJCQDETC65pxnqG1oRX5glbjjj8wuNYRPkeuyf0oF40vK Hlbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=naLP2X5I9g+bYi2NX0HGEbL0Y2mLcduh6jJ59cFCp50=; b=Z2R9DyxHL83I3Q9MUQQqo0R1bDlzk5WOzowpUKUmsCOmXMLLu3i+5SgQ3a+B40dLUz zdMfTNr5EnIGT1ARo7zZln9dpyU0I5CAHdRzzcBZzy6Vhs1HzLrppQWNAOHknqTqa7ci UbaKGhtogDz46OyPwmoYDXsfdIHw+ewePflV1N0C4Mkeo8ZZVYh1qByqqILRp/d7rdbi na2M8VpzRCn/dXlvVvvh+Xk41ndZOCMwNtX/T5nbFcmbkLi2zxymZb4MIJsWI5VZDf3R NWJU55ThKrqL3HVP2o8eA+JLe7wC3bIDNfG0K9gW7EEGCdx4bQMWjH0iXjE9y5XLaBuw bFgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=jJ287B22; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bu8si5920937ejb.76.2020.10.09.08.01.36; Fri, 09 Oct 2020 08:02:02 -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-dk.20150623.gappssmtp.com header.s=20150623 header.b=jJ287B22; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388811AbgJIO6E (ORCPT + 99 others); Fri, 9 Oct 2020 10:58:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389026AbgJIO56 (ORCPT ); Fri, 9 Oct 2020 10:57:58 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96851C0613D6 for ; Fri, 9 Oct 2020 07:57:58 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id 34so7345436pgo.13 for ; Fri, 09 Oct 2020 07:57:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=naLP2X5I9g+bYi2NX0HGEbL0Y2mLcduh6jJ59cFCp50=; b=jJ287B22+BBCohsKfzN1eBMlh7TPMTxSHpjlZTV7jIwxxKi1czatfwzCNMHdrl9K8W K4lbiOPZ23zEwDtxUfAICrZu4zAgwqGZOREmt61Cgk4VXVwZy1fv1Hy4wfujEbrou5LG Nz9vNYgktAzzzagV0qE0ByB6LTEh0YmbUfgl/77vbClVm+oTFxbLjneOGHZMWP1ZmdnP oa1vsg08TFe1c2c9gUSkzHkuFBH0iU2mkKBVGm+okVTz2pYExYZwGGQbeEnyZQs/V9Sl SVDvf7DQY37wKAV4hKL02UJ5HLJXeZ8fMcMhBjQtkvDvKLTA3Dp3vOaSJ4SGMwpRH+oO xCow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=naLP2X5I9g+bYi2NX0HGEbL0Y2mLcduh6jJ59cFCp50=; b=Dt44zks75EkttRYK1izZ/Nkl7iXVKyIlOUBxOxwY/5UiXnUbZaKnF6sR+Ei6NFtkOB eRyceeUSeZJeg2J2+I9/82bSpearFrbVC7voOWg/ZF0uqt1PDnkGZtQ3U0hG8IZtgPyi j6KGrGg15bMFSmMNxNsgUZokE6ihHRgEClx3wlUTosWE5mJi9KdRX4twJ1o35yB1YG6q gqaim9BqsYDk82cJEABq/gOOvgBQViblC7lf8xZSJkky62vC2HZp/xiIbPBDJ08pS3vw Io88u/eujhVXkE+7h8YtXgEZD3iAbjoR4uMsnn6Ha+3rQ2U1z27h6/1Pi/kXO+6aLMWV Lznw== X-Gm-Message-State: AOAM5327385Ft9aQvv23WNjyIdPCKofQVVlrl/KsWT39mZsjjY+0tUpL hB9y8h/sx/X9VNWMmy3gPXwQ1w== X-Received: by 2002:a17:90a:14a4:: with SMTP id k33mr5016963pja.236.1602255477936; Fri, 09 Oct 2020 07:57:57 -0700 (PDT) Received: from [192.168.1.134] ([66.219.217.173]) by smtp.gmail.com with ESMTPSA id i2sm11893818pjk.12.2020.10.09.07.57.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Oct 2020 07:57:57 -0700 (PDT) Subject: Re: [PATCH 2/3] io_uring: Fix XArray usage in io_uring_add_task_file To: "Matthew Wilcox (Oracle)" Cc: linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, Pavel Begunkov References: <20201009124954.31830-1-willy@infradead.org> <20201009124954.31830-2-willy@infradead.org> From: Jens Axboe Message-ID: <0746e0aa-cb81-0fde-5405-acb1e61b6854@kernel.dk> Date: Fri, 9 Oct 2020 08:57:55 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201009124954.31830-2-willy@infradead.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/9/20 6:49 AM, Matthew Wilcox (Oracle) wrote: > The xas_store() wasn't paired with an xas_nomem() loop, so if it couldn't > allocate memory using GFP_NOWAIT, it would leak the reference to the file > descriptor. Also the node pointed to by the xas could be freed between > the call to xas_load() under the rcu_read_lock() and the acquisition of > the xa_lock. > > It's easier to just use the normal xa_load/xa_store interface here. > > Signed-off-by: Matthew Wilcox (Oracle) > --- > fs/io_uring.c | 21 +++++++++------------ > 1 file changed, 9 insertions(+), 12 deletions(-) > > diff --git a/fs/io_uring.c b/fs/io_uring.c > index 2978cc78538a..bcef6210bf67 100644 > --- a/fs/io_uring.c > +++ b/fs/io_uring.c > @@ -8586,27 +8586,24 @@ static void io_uring_cancel_task_requests(struct io_ring_ctx *ctx, > */ > static int io_uring_add_task_file(struct file *file) > { > - if (unlikely(!current->io_uring)) { > + struct io_uring_task *cur_uring = current->io_uring; > + > + if (unlikely(!cur_uring)) { > int ret; > > ret = io_uring_alloc_task_context(current); > if (unlikely(ret)) > return ret; > } I think this is missing a: cur_uring = current->io_uring; after the successful io_uring_alloc_task(). I'll also rename it to tctx like what is used in other spots. Apart from that, series looks good to me, thanks Matthew! -- Jens Axboe