Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp5349940rwb; Mon, 8 Aug 2022 17:36:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR77N2oYRApS8TjTT8pYrBVJp2PJWkz8jE8e3vgseQN8D2d7j/eJ8G6qRPWu7KGzuXVu8mtv X-Received: by 2002:a05:6a00:1941:b0:50d:807d:530b with SMTP id s1-20020a056a00194100b0050d807d530bmr20299781pfk.17.1660005387022; Mon, 08 Aug 2022 17:36:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660005387; cv=none; d=google.com; s=arc-20160816; b=jNdaXexvvzNWuFo3ffIAWhqrsJ2axAxoFe7m1/F01yzb/qfAmUsHPcuoshs1Nb6JRc b0Kk6NrBbu9gaG/9VO5YoheET6/xwp8EY+s2W6dHBM9tLfbI1T/EbizoPHLkBq+Y0gxy KK+YaPXrJuNMpT+CG+oqrQpp0BgGMDY2b+5Hwgjqju5H+lIeR7KthY7qPN6zhi7xAafN vEJi6RqYOHep1Z76JA0GkAD6x9Eyo3FbXlZNIKHVHIzuVStBDr4O1MDKAwCePlLGC0Xx V/5u8t/O+WsKx492J/Xc/es86t2mLwd/B4zSAfH5RCePJgWL1190MP/sn98x/9gYTKNv aTNA== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=rA3RnJotnB5RgE87/eV0/S8tWytmdX1+DrSj+NTX/7A=; b=hwRsqtY/BoiZ2yGs2PeUkE9Al4WbR/jcUkBMZllAHlW3uYLltRF75bR8oBPILtjAeU NgRMRKH+PO0GbkBEcahLK3ttzf1yZVcDb5C68So/6nyGwpMEmi+PqylMk/5fi3cA3wMi 5zMPgpgzFYxvcozFH6akBzeF9UprtN1F4407BO/vJpIgdgEzeY8ssDAfK6JwLUqg6nVS juuILJg6B91Gy5pF57KHINIi+4oWoJOXGvO3/wmqCIMxqWGHTzJmLYjzx3+1DcMyIJkW FstQjA69DchjeEaiyWVgGI2W6p8hdnQjY6ekrdlXcRw4AUDca9lShUFRH70aSK23wLou J1mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=B5JH0OqR; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nv4-20020a17090b1b4400b001f1ae614214si15233594pjb.110.2022.08.08.17.36.10; Mon, 08 Aug 2022 17:36:27 -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=@linux-foundation.org header.s=korg header.b=B5JH0OqR; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244547AbiHIAO4 (ORCPT + 99 others); Mon, 8 Aug 2022 20:14:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234033AbiHIAOz (ORCPT ); Mon, 8 Aug 2022 20:14:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BA27F7; Mon, 8 Aug 2022 17:14:54 -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 EEA9461118; Tue, 9 Aug 2022 00:14:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BB9AC433C1; Tue, 9 Aug 2022 00:14:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1660004093; bh=s9p6n77wda0CikqJB7ybhXozw+JkQMq2Pby2cddT+uw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=B5JH0OqRDDRpkCD8xpBt/M1yyosH8jx8oAfeBOhuZrxbtP1Qf+qGQQXIDF7UvuBkd TAbwA1M621+alqShaa2kZ/WYzNdQ/iIwHPmomhM2X1bIh4E0u1YBC2wmeBKs9/1PkL s5s3m6++ktPT7RFR6KskMWssDCf8sGfVwPNnEdzs= Date: Mon, 8 Aug 2022 17:14:52 -0700 From: Andrew Morton To: Maurizio Lombardi Cc: alexander.duyck@gmail.com, kuba@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, chen45464546@163.com Subject: Re: [PATCH V3] mm: prevent page_frag_alloc() from corrupting the memory Message-Id: <20220808171452.d870753e1494b92ba2142116@linux-foundation.org> In-Reply-To: <20220715125013.247085-1-mlombard@redhat.com> References: <20220715125013.247085-1-mlombard@redhat.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 On Fri, 15 Jul 2022 14:50:13 +0200 Maurizio Lombardi wrote: > 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. Can we come up with a Fixes: for this? Should this fix be backported into -stable kernels?