Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2887044rwb; Mon, 15 Aug 2022 13:19:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Pw1lgIN0ig5RFT57g97dXEB6/QbfhJNcrm4XMwFf3yWopo4ENhnWszZ7OcZx53Pzl5EUB X-Received: by 2002:a17:902:f211:b0:16e:f6c2:3742 with SMTP id m17-20020a170902f21100b0016ef6c23742mr18255213plc.58.1660594786417; Mon, 15 Aug 2022 13:19:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660594786; cv=none; d=google.com; s=arc-20160816; b=ZCu3RTp2HpTs75r/GF/3KrrszF06/22A3Cd1AARYNDEzNdPIrQ7j0DzhLU1CPUdZpa w/NYpFB+vGg9EDISEWd1/ilHHkeJgikzEpxY7KCRsJ3ztWMLuJrCyo7Xw4nyG3d7XyQO dZEGm6kVjVghGiY7xsaqKuKTXy/Y0iXGhcBSBKNzR5EqZPNdsZ1uQLYh3MevYmFC4QNv cggIg7A+63fuEjMRB4gX66Jl4NT+jryQX96CDM66usyW1JAKUHbJnlwW+pKpKxA2dZy1 7yRhOGj2OLyrHN2ioXo20O1Lpy/YpNzJ2nBNDg7j8vcK6MbM2jmgyzOLzd6Zx96Z9ZxC 1zjw== 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=1BdcxRh/TUfoKZgFtUX1omo9cx4mozsiJ8+Ikecn4wk=; b=IenrNUlee/c8lXmufegtI/CZkXjHPRvfp6vTmP0RDLfbK9aFdVGHwMXOA57O835/94 96ZVSU1ZBh4QApodUwl3iewnsQC3mC3rdEF5IFE+CzeYdsuhn+Xw8VaeRaWHZye7DRQZ KoGW1fE1jPcHJkcoedviWBwdWKShX5Gn0ZqZ/om1QJO+xU8sOgvXtSitjGJK4CimZ/Wn 0evJb43PpmVzvmV7GYMmMnIM9laXS3dEu0MCEeXqeDKQUbph3VpYtZKaRKr5PGCVbLXr slKTvw83NXOlm54J+kfZamJlrm84uFacbWTpbTf02KRg3VsbxAkAQEL0iBRgWSOwhtXQ 87iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=X4mdesZS; 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 l6-20020a170903120600b001727963f93esi754429plh.68.2022.08.15.13.19.34; Mon, 15 Aug 2022 13:19:46 -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=X4mdesZS; 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 S243410AbiHOUCp (ORCPT + 99 others); Mon, 15 Aug 2022 16:02:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345919AbiHOUA7 (ORCPT ); Mon, 15 Aug 2022 16:00:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D15217B1E3; Mon, 15 Aug 2022 11:53:33 -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 ams.source.kernel.org (Postfix) with ESMTPS id F22E8B8105D; Mon, 15 Aug 2022 18:53:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44177C433D6; Mon, 15 Aug 2022 18:53:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589610; bh=6lz2YdPTiZjJvSA/4Pbq2dAES/xNXwk3Yc/pcvU3EkA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X4mdesZSS+tdyfZ/qJb2wX5d0gdM2maZQkqQvAjp3ug3B5yzvOaCMG0KVccVB1vfJ nL+OhTWYAL4y66rUpUInfd81Qc0xdFCzTjYz0inhPmMUI4jWCIbNcJ4c4gcMjPRxjW XW/t4Np5SWg48mgdSpHnqPyETQZjP3FH65nTGWTY= 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.15 773/779] io_uring: mem-account pbuf buckets Date: Mon, 15 Aug 2022 20:06:57 +0200 Message-Id: <20220815180410.444136632@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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 commit cc18cc5e82033d406f54144ad6f8092206004684 upstream. Potentially, someone may create as many pbuf bucket as there are indexes in an xarray without any other restrictions bounding our memory usage, put memory needed for the buckets under memory accounting. Cc: Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/d34c452e45793e978d26e2606211ec9070d329ea.1659622312.git.asml.silence@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/io_uring.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4477,7 +4477,8 @@ static int io_provide_buffers(struct io_ ret = io_add_buffers(p, &head); if (ret >= 0 && !list) { - ret = xa_insert(&ctx->io_buffers, p->bgid, head, GFP_KERNEL); + ret = xa_insert(&ctx->io_buffers, p->bgid, head, + GFP_KERNEL_ACCOUNT); if (ret < 0) __io_remove_buffers(ctx, head, p->bgid, -1U); }