From patchwork Tue Jan 30 02:35:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuxuan Luo X-Patchwork-Id: 1892625 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TP8Rb21rcz1yQ0 for ; Tue, 30 Jan 2024 13:35:54 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1rUdyT-0004wk-7A; Tue, 30 Jan 2024 02:35:45 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1rUdyA-0004vK-Ln for kernel-team@lists.ubuntu.com; Tue, 30 Jan 2024 02:35:26 +0000 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 05D783F184 for ; Tue, 30 Jan 2024 02:35:26 +0000 (UTC) Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a357c92f241so103486966b.0 for ; Mon, 29 Jan 2024 18:35:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706582123; x=1707186923; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zzORRiNejAyvkS/pseKJaeI+zryy40j7Uytz/tlgY4U=; b=qHISYSQWCV9ZlYyUzpwg2KYm2vzPaW0F90L+SFTbprkIjn87uPuBr99w9pAQktk7Oz hz5oD2c0zcSuOfnNu08Fnq7kgO4jvZ9sPgiBbZ4z0JyBMwLxHsYd6r7OgqIVcgEpYMn1 6gljK8AetlvaqKhpQnXnU1vOpZVlh7ulZve7r77RZTn0lv2/vjCMmleO6kODSjW/QK8c Oij+0MP7d1Sb0HDklQwnMq5fRPyIZx29T7myqe8UElPrVQBwwTbUNdofcxcvfJ5VbOOs RgM3y7XyeRhU6C6FLCl+WhW/+VsjPXwKBkprAK8wzncXcfSA74NtCy5wHwj64U4mU9U1 w8Ug== X-Gm-Message-State: AOJu0YxYbsD7rDoPIiaqohhSLzyGqAy0Vz5h/LGAx8easEEs8ehDLUy5 /D4S7iec8JPSjqo8x2TNQOXup4NGjh1yM+nh1H33K/5jXvf7DvrTKtpIf4xDVbYFLuScWmnMmZ/ 3K7JRSbF1fXk9kpaRVoXlcwbqL2ZCZnZEJG59FU2Aq4aqQhYf4NOnGpE4/m2CorQPskp7TO//RC V60Vc1C1AhHq8B X-Received: by 2002:a17:906:e53:b0:a31:1b72:9efd with SMTP id q19-20020a1709060e5300b00a311b729efdmr5491016eji.66.1706582123789; Mon, 29 Jan 2024 18:35:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IFShVC2Vf8qsby1rukTw6sSaAF4a1ztYPvZ1qtV/cMK+Yus9qhx4o0AojByOVDQ/SoqOI9iQg== X-Received: by 2002:a17:906:e53:b0:a31:1b72:9efd with SMTP id q19-20020a1709060e5300b00a311b729efdmr5491009eji.66.1706582123539; Mon, 29 Jan 2024 18:35:23 -0800 (PST) Received: from cache-ubuntu.hsd1.nj.comcast.net ([2001:67c:1562:8007::aac:4795]) by smtp.gmail.com with ESMTPSA id vu2-20020a170907a64200b00a35a9745910sm2017165ejc.137.2024.01.29.18.35.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 18:35:22 -0800 (PST) From: Yuxuan Luo To: kernel-team@lists.ubuntu.com Subject: [SRU][Mantic][PATCH 1/2] io_uring: enable io_mem_alloc/free to be used in other parts Date: Mon, 29 Jan 2024 21:35:18 -0500 Message-Id: <20240130023519.94667-2-yuxuan.luo@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240130023519.94667-1-yuxuan.luo@canonical.com> References: <20240130023519.94667-1-yuxuan.luo@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jens Axboe In preparation for using these helpers, make them non-static and add them to our internal header. Signed-off-by: Jens Axboe (cherry picked from commit edecf1689768452ba1a64b7aaf3a47a817da651a) CVE-2024-0582 Signed-off-by: Yuxuan Luo --- io_uring/io_uring.c | 4 ++-- io_uring/io_uring.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 43d192dcc934d..1b0a27fe41eef 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -2659,7 +2659,7 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, return READ_ONCE(rings->cq.head) == READ_ONCE(rings->cq.tail) ? ret : 0; } -static void io_mem_free(void *ptr) +void io_mem_free(void *ptr) { if (!ptr) return; @@ -2771,7 +2771,7 @@ static void io_rings_free(struct io_ring_ctx *ctx) } } -static void *io_mem_alloc(size_t size) +void *io_mem_alloc(size_t size) { gfp_t gfp = GFP_KERNEL_ACCOUNT | __GFP_ZERO | __GFP_NOWARN | __GFP_COMP; void *ret; diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h index 0bc145614a6e6..d2bad1df347da 100644 --- a/io_uring/io_uring.h +++ b/io_uring/io_uring.h @@ -86,6 +86,9 @@ bool __io_alloc_req_refill(struct io_ring_ctx *ctx); bool io_match_task_safe(struct io_kiocb *head, struct task_struct *task, bool cancel_all); +void *io_mem_alloc(size_t size); +void io_mem_free(void *ptr); + #if defined(CONFIG_PROVE_LOCKING) static inline void io_lockdep_assert_cq_locked(struct io_ring_ctx *ctx) {