From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C5DD3ED3C9 for ; Thu, 23 Jul 2026 07:50:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793028; cv=none; b=POiheJh6PrUTfUW0sUMHspQe1Pu/8BewAdrvd+vnGCdSfu1sYzrX8wLBq6et3I3yoc4Wmi7FK0gILZs8gQkTyVyudmxdxZorjNFx64YF5BIGDdL2oqkiZ+Rg32RJ0T3wABd3fn/4NORRvNmA9Ok5uZg1FgOVAOCcf/sYHVyxd20= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793028; c=relaxed/simple; bh=N89dStHSM2Saw21HtEnRMuDg0qbt0KxaJqo9WgClq5g=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ZGjcF9UkfPGXLTw0sT0mE/puFyYDf3AV+B0QMJZAtd4kXxZe9OwSu2py0oBxs4z8vNcOWLMp2XH0mFxwXYzNfAx16YztXtqD/Pen459OrfyaSq7znO8WCYe2B/vfpJ3C20VUEutlGzAFzg9Qz6WJLm7tXbGIaAknAvvrJXYLVMo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jyescas.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=B+SSKiqf; arc=none smtp.client-ip=209.85.215.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jyescas.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="B+SSKiqf" Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-cb5bdd8450dso349361a12.0 for ; Thu, 23 Jul 2026 00:50:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784793027; x=1785397827; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=C7CBNiHk+pogzDyhH1M3QCDP6vdmZRlAwIqSJkV+BV0=; b=B+SSKiqfmGTiWr/A2j34ZyS0NVTrC8zuYh6NXtTrgi0GPwiDGHYkGbxWl7lnUkLB3f 6YI6AAxa7DqBPukWgM8mKJJAbM5QbJXMTdLHZpXhJgpRM0zHunqfhHm+/bMOR11BvLvz jfonWwO5UXrXO3OHHjfJ+FYt1cPcC8nO//22wXam1AGjDmq5gwrJ2CELPqAveLDAEMTg NbKCnaj/GmVpB/UgkTT5zwngrqO8o9gRt3n29a2ygzQs2sqb4ADHGv0ny/tDq0FcQbmg Dn+16akXctRn93RAoN5E+xEpLeqlfAOiymOO5ud9Dm+39vaVGcV928d2lAVL9Z4MEfHF mOkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784793027; x=1785397827; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=C7CBNiHk+pogzDyhH1M3QCDP6vdmZRlAwIqSJkV+BV0=; b=cTsPnZWaNXQ5KA3oi6lNly3RRIY93zrcP1OlzLumIznSYOUtNJ2KqEY+gcxdMX2fB0 HKkGDXP3wZPaOkOVJKZCuua/Dms91vFf3XSekAx0F/RAgFZe5GHYB/pfFBMZYpLDU5pg P3iW8vkaj5EEUlY/bUHbkPUes+4lbwN5qPl5X5IG/mGg8+eR1lT0aRmX2t/vVNFxdnDY 5AsDODppp5+YiOFeP8Fcivx2AhRxXCwQIcss0w7tFYGP5h+7wTHlN9VJyDN5Km58hmTt pf73xDzjSm1kAozOAfNaihT+1AMAr3RymDy/7dhdG9R6Jsz1v4PpWmR+UYKJhRf3UI7Y 2uxw== X-Forwarded-Encrypted: i=1; AHgh+RpN5oR+0D9hEDHoymUb/p5FkaBY3jcqE5GBtBijR7JiP+o5ssBILX7pIJ74u1f2E5gjXpfSeuMDpyxBJY4=@vger.kernel.org X-Gm-Message-State: AOJu0YzO9ISjmqcZVRj2vUhoxLHKiAczl+18+edChwFa03wJkS6zU8k+ yNLcAaj+KiDh/JsVRGpDIntASDzROw/slEOjrV9S72JkeBulKas/jl9+fcRJcyARFS1nEIpchDp VokJH+AVz1A== X-Received: from dyng25.prod.google.com ([2002:a05:7300:7f19:b0:30c:2bdd:dcdf]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:9f09:b0:3c0:9c19:b275 with SMTP id adf61e73a8af0-3c44b2ae3c9mr2165420637.67.1784793026464; Thu, 23 Jul 2026 00:50:26 -0700 (PDT) Date: Thu, 23 Jul 2026 00:47:13 -0700 In-Reply-To: <20260723074854.1013941-1-jyescas@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260723074854.1013941-1-jyescas@google.com> X-Mailer: git-send-email 2.55.0.229.g6434b31f56-goog Message-ID: <20260723074854.1013941-10-jyescas@google.com> Subject: [RFC PATCH 09/16] mm: Read the nr_pages_allocs value given by user From: Juan Yescas To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , open list , "open list:MEMORY MANAGEMENT - CORE" Cc: jyescas@google.com, android-mm@google.com, fvdl@google.com, tkjos@google.com, minchan@google.com, dskiba@google.com, open list , "open list:MEMORY MANAGEMENT - CORE" Content-Type: text/plain; charset="UTF-8" This change reads the nr_page_allocs value given by the user and validates that is an unsigned long. If the input is valid, it will allocate an array of nr_page_allocs size. This array will store the allocation ids. These allocation ids will be used to free the allocations. Signed-off-by: Juan Yescas --- mm/page_alloc_hogger.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index 3ffad74a0bdf..60dfddf6b441 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -136,6 +136,19 @@ struct kmem_cache *page_alloc_cache; static ssize_t req_page_alloc_write(struct file *file, const char __user *ubuf, size_t cnt, loff_t *ppos) { + unsigned long nr_pages_allocs; + unsigned long *allocs_ids; + int ret; + + ret = kstrtoul_from_user(ubuf, cnt, 10, &nr_pages_allocs); + if (ret) + return ret; + + allocs_ids = kmalloc_array(nr_pages_allocs, sizeof(unsigned long), + GFP_KERNEL); + if (!allocs_ids) + return -ENOMEM; + return cnt; } -- 2.55.0.229.g6434b31f56-goog