Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AE81C07E9D for ; Mon, 26 Sep 2022 19:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229754AbiIZTPz (ORCPT ); Mon, 26 Sep 2022 15:15:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230031AbiIZTPp (ORCPT ); Mon, 26 Sep 2022 15:15:45 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B5BE97D53; Mon, 26 Sep 2022 12:15:42 -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 sin.source.kernel.org (Postfix) with ESMTPS id CB13CCE1340; Mon, 26 Sep 2022 19:15:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BB37C433D7; Mon, 26 Sep 2022 19:15:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1664219739; bh=AS7G+/KFqbGapngxfiDi8l6V5osUYJB1ZxCXpjPoh7k=; h=Date:To:From:Subject:From; b=rbD4sdNGbg7NriUINRFhO5ywoZ0YCfeVsCDdJ9/DQbJhj43+CgBGqeX+5WfNU0jjP jz8SF1dAugTXk0y5Al1bNhYiR3hRca6PjHlHWGpT8N1DQbdv0KpnLUPiJwey5OQceh 3/0PbWomFm2mVYsGJEScBfu8Gki+kGZWbZuBZxtk= Date: Mon, 26 Sep 2022 12:15:38 -0700 To: mm-commits@vger.kernel.org, stable@vger.kernel.org, kuba@kernel.org, chen45464546@163.com, alexanderduyck@fb.com, mlombard@redhat.com, akpm@linux-foundation.org From: Andrew Morton Subject: [merged mm-hotfixes-stable] mm-prevent-page_frag_alloc-from-corrupting-the-memory.patch removed from -mm tree Message-Id: <20220926191539.1BB37C433D7@smtp.kernel.org> Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The quilt patch titled Subject: mm: prevent page_frag_alloc() from corrupting the memory has been removed from the -mm tree. Its filename was mm-prevent-page_frag_alloc-from-corrupting-the-memory.patch This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm ------------------------------------------------------ From: Maurizio Lombardi Subject: mm: prevent page_frag_alloc() from corrupting the memory Date: Fri, 15 Jul 2022 14:50:13 +0200 A number of drivers call page_frag_alloc() with a fragment's size > PAGE_SIZE. In low memory conditions, __page_frag_cache_refill() may fail the order 3 cache allocation and fall back to order 0; In this case, the cache will be smaller than the fragment, causing memory corruptions. Prevent this from happening by checking if the newly allocated cache is large enough for the fragment; if not, the allocation will fail and page_frag_alloc() will return NULL. Link: https://lkml.kernel.org/r/20220715125013.247085-1-mlombard@redhat.com Fixes: b63ae8ca096d ("mm/net: Rename and move page fragment handling from net/ to mm/") Signed-off-by: Maurizio Lombardi Reviewed-by: Alexander Duyck Cc: Chen Lin Cc: Jakub Kicinski Cc: Signed-off-by: Andrew Morton --- mm/page_alloc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/mm/page_alloc.c~mm-prevent-page_frag_alloc-from-corrupting-the-memory +++ a/mm/page_alloc.c @@ -5740,6 +5740,18 @@ refill: /* reset page count bias and offset to start of new frag */ nc->pagecnt_bias = PAGE_FRAG_CACHE_MAX_SIZE + 1; offset = size - fragsz; + if (unlikely(offset < 0)) { + /* + * The caller is trying to allocate a fragment + * with fragsz > PAGE_SIZE but the cache isn't big + * enough to satisfy the request, this may + * happen in low memory conditions. + * We don't release the cache page because + * it could make memory pressure worse + * so we simply return NULL here. + */ + return NULL; + } } nc->pagecnt_bias--; _ Patches currently in -mm which might be from mlombard@redhat.com are