From patchwork Sat Oct 22 07:18:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7136 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1087355wrr; Sat, 22 Oct 2022 00:36:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4SwQbl9D+G3qA5bGJGPDjzMb++BRBVRo9ih81P+Px8/0GYhDoIqBkZgB2N/6lRaZXw2nAe X-Received: by 2002:a17:907:2c4a:b0:78d:f5c2:70d1 with SMTP id hf10-20020a1709072c4a00b0078df5c270d1mr19270653ejc.198.1666424164576; Sat, 22 Oct 2022 00:36:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424164; cv=none; d=google.com; s=arc-20160816; b=yEvuqwu5hJRdpqcez4+AubGi+E2cpDG814hTOqU/hIwT44WQ8nEx1TPNeu+82jkvCT l+drlrjfpb+nf+wbUwPu7d1d83WM1HwNB2gsd9b42yswGgXhBJgszlqD3bk06Hy2nWiG OW638bJJFkwwQBstAYciwgo9dIguRPVzYHLR5AZJkbuIeztL93RnkRhxYQ+3avpIZgH1 ISAbpa8haOlr0FkZiPK/PtzGjP50tAyjopn1Wl7IG5Gr92rnwBdy5R8u3GtKcddKLFoZ GOsdyrf6f3ouBjvuZvCXyL+HAbiWngp32UhQekU0msV6rmq6+FzYbbYa/3wlc/uYrM8D BZAA== 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=vWlGNTYUuZgGynLNezk0uYxRzVHvMAtJHwZMGykD+2A=; b=R54giWO9u1+Y5xop2L+GWUEHhoKalNVfTO9Xnv44Wh8jg3QBIFsjQbGOYcpnAh0/mI ltk9Lh/9jTz2LssDuCOHSvi1FgpxSpyGEyg77imO5YeQP1BUgliw45F4c8so6t+2+tOL AOrFmEX69AFhXBUL4reh2L3cSkhHQAD/lGlWD9yCeS+/wd0v/uhno/0wxKDSkyqMNKOi aBRXwJi7PMW0Y77kzFGCTds9c+3HK3VatUcZeGg+YyNm+oj5dhV8SwJ3HSg4+snLslbz jFhuzyVjNPeX1MriKnpG8bNU+93Tq17UsjMw7c97j9RC0idg/rBY83Dm8iPUo+8r3UAU Eozg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uvjQKuNI; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020a056402240800b004608020a52esi6226849eda.466.2022.10.22.00.35.40; Sat, 22 Oct 2022 00:36:04 -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=uvjQKuNI; 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 S230168AbiJVHes (ORCPT + 99 others); Sat, 22 Oct 2022 03:34:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230176AbiJVHe2 (ORCPT ); Sat, 22 Oct 2022 03:34:28 -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 04D3610B9; Sat, 22 Oct 2022 00:34:20 -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 4CBC260ADA; Sat, 22 Oct 2022 07:34:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EFB4C433C1; Sat, 22 Oct 2022 07:34:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424058; bh=4JYcccYrPbaiYI/ym+uHOnTSOSvp7iMYJl+Av0/3swQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uvjQKuNIorfqgjF9dwDBeyQzd86t5UaIsybI5vFqQzxD36c1mPwwgTc3I9YyyjQg8 t7+1cA9v68/soja/gPR3UIQoni/0sMZUOndz0qVewxomW9Vcpbdgtmi/qcjDnp7xVJ CoiTDb/7CywSlg93Lwx7CjpqEJlQ+NZmsve8Q3Xo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stable@vger.kernel.org, Pavel Begunkov , Jens Axboe Subject: [PATCH 5.19 015/717] io_uring: correct pinned_vm accounting Date: Sat, 22 Oct 2022 09:18:14 +0200 Message-Id: <20221022072417.741102098@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747372384694558324?= X-GMAIL-MSGID: =?utf-8?q?1747372384694558324?= From: Pavel Begunkov commit 42b6419d0aba47c5d8644cdc0b68502254671de5 upstream. ->mm_account should be released only after we free all registered buffers, otherwise __io_sqe_buffers_unregister() will see a NULL ->mm_account and skip locked_vm accounting. Cc: Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/6d798f65ed4ab8db3664c4d3397d4af16ca98846.1664849932.git.asml.silence@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- io_uring/io_uring.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -10711,12 +10711,6 @@ static void io_flush_apoll_cache(struct static __cold void io_ring_ctx_free(struct io_ring_ctx *ctx) { io_sq_thread_finish(ctx); - - if (ctx->mm_account) { - mmdrop(ctx->mm_account); - ctx->mm_account = NULL; - } - io_rsrc_refs_drop(ctx); /* __io_rsrc_put_work() may need uring_lock to progress, wait w/o it */ io_wait_rsrc_data(ctx->buf_data); @@ -10755,6 +10749,10 @@ static __cold void io_ring_ctx_free(stru #endif WARN_ON_ONCE(!list_empty(&ctx->ltimeout_list)); + if (ctx->mm_account) { + mmdrop(ctx->mm_account); + ctx->mm_account = NULL; + } io_mem_free(ctx->rings); io_mem_free(ctx->sq_sqes);