Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3502835imw; Mon, 11 Jul 2022 09:50:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tAIsYXzhupKhXkUrA+BiysrDM1dZNXoQWND5OGZk4Sb7Y8u4mceDTcEvn3WPpZEsx9sNBf X-Received: by 2002:a17:907:1c8d:b0:6f2:eb2:1cd6 with SMTP id nb13-20020a1709071c8d00b006f20eb21cd6mr18701243ejc.568.1657558237657; Mon, 11 Jul 2022 09:50:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657558237; cv=none; d=google.com; s=arc-20160816; b=dqdFrD9ynqcl3ICTXxB7aSBP7HQhF0aq5uJMy9UKdEiM8VypdSO8ANGICLRKam7yzF GhKloDoXXQpwtmEy8VfE5QZHs20Ss2A73rUJ5QYgm5nJ4NUZxZln+0V+p6XFCFjaKo56 Z0CgImo3SZzBdRUc7ROMIxBBy4bMvNrWXM+IzsXJmY63p1jm6dnMOUUgAhvwdTwn1OCU lsFPYYM+i98quMYpVdSX3U7JdvGLYV7yAr3mYJYVMQunXlaRut8bxF5BAFRqjXgY6oWE NxULL0LIxeYyBN/nOAxGoSEuSfmqjF+eQ1MNEc4BCZEj1mR3B4gtgjBzCmpUzmaAfsHv KW+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=NFy7tx4vuflJ9T67q4fsWyscGk3VBcpn9gI9HIE/8ZA=; b=sCEiwSTRH0bJwJWlNshbnUDaWlPeK6pk+TFXw7edBeRZJDAmOcTS8C3C0e1lMDNx6s +RP/0So9eTRD8C/kF6nraB3HdqKbKOhUGsERkgO48jKQbiVMZdgYEv3JU5nDT5jklDRk AWbSG+uSINxun+o6A2wAnPZnfnqrMBIfUd8FbuAmsM/W1Ul4ick7bhNrGdrMBwXKjI01 pZxHc637oM1MeQBf93M73MrZf5s3u0VfXVlmhQnxJy/Lbd1gHluvUB1EmEgAM00//KWV M5pT9BNHGGy11pSgxyQnOpUvkVwLPMxWVpqsP5DnzqaYFB32v3LotSaMcLGPO8DUX5qd yrgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dcBdbSa+; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f24-20020aa7d858000000b0043a71f2ffc1si10013166eds.49.2022.07.11.09.50.11; Mon, 11 Jul 2022 09:50:37 -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=@redhat.com header.s=mimecast20190719 header.b=dcBdbSa+; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231789AbiGKQRy (ORCPT + 99 others); Mon, 11 Jul 2022 12:17:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229948AbiGKQRx (ORCPT ); Mon, 11 Jul 2022 12:17:53 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 98C1A7A530 for ; Mon, 11 Jul 2022 09:17:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657556271; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NFy7tx4vuflJ9T67q4fsWyscGk3VBcpn9gI9HIE/8ZA=; b=dcBdbSa+U6dmDLaTIPYSsUKUWbEy2paoLMcS05UMmAX/pnrXTPve+HT2UBsbeFpLJK245B t18e+lgLjBC5N4OFkQtuWSQx8d0+Xj4nPnKjCdU4mLcjxyRpTBtRFb/oUGZWeThdGyKk9v 8Xi6rS6be5BN7iAsyF7PTtl507XRZfM= Received: from mail-ua1-f71.google.com (mail-ua1-f71.google.com [209.85.222.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-467-_XPTBpIMMs6U-vF69Sn_OQ-1; Mon, 11 Jul 2022 12:17:50 -0400 X-MC-Unique: _XPTBpIMMs6U-vF69Sn_OQ-1 Received: by mail-ua1-f71.google.com with SMTP id l7-20020ab053c7000000b003791afd560cso1073826uaa.21 for ; Mon, 11 Jul 2022 09:17:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=NFy7tx4vuflJ9T67q4fsWyscGk3VBcpn9gI9HIE/8ZA=; b=KRZY6gCoT7lAQNc/S8cOBvGOl6WxBDUywFGoigXnzHJpe80xvv5nH2zCTgNPbw9LJ3 VG+n4ZNqcuXvgj+VVXu1l8f4gz6xOo7R5wl45195iV8EhYaLdcfcwAChNaxf18RGmFcH vivZLT+lNt1Swyf+o6FkyJhoL8qbX5uL5N0OkOpnj0+MdNSUi5guIFjN5JFRatm/hB+b 38jvP4SUT3hxLKzUrXIsYDbZaXO5NV9+WdizYYBV16wA2zKD9d6CKk3xgI1qAgBtZufI 6ttk5pPSBDi5FqhJH99Y+7jhqlt+O18dM+inK2SGTNbz+gnR/ykiU8/3boUXL4j66Pc2 rUXQ== X-Gm-Message-State: AJIora9xtnKckjnzc6djy1FgtbjW/3oQ+AD5JWEwuMLy8hC351qDT33v DXzT2FR2n4iOkBMKfPueEgJFZWU1949BqT4mPsu2urO3LQdSV92jJNFglMwpZUGK5yOcm705d7+ lAYN45LZrmpMZF0LU4hr44aR8Qt6LuD3Jg3gPbDwu X-Received: by 2002:a67:e9c2:0:b0:357:547e:d541 with SMTP id q2-20020a67e9c2000000b00357547ed541mr2640135vso.68.1657556269854; Mon, 11 Jul 2022 09:17:49 -0700 (PDT) X-Received: by 2002:a67:e9c2:0:b0:357:547e:d541 with SMTP id q2-20020a67e9c2000000b00357547ed541mr2640130vso.68.1657556269612; Mon, 11 Jul 2022 09:17:49 -0700 (PDT) MIME-Version: 1.0 References: <20220711075225.15687-1-mlombard@redhat.com> In-Reply-To: From: Maurizio Lombardi Date: Mon, 11 Jul 2022 18:17:38 +0200 Message-ID: Subject: Re: [PATCH] mm: prevent page_frag_alloc() from corrupting the memory To: Alexander Duyck Cc: Jakub Kicinski , Andrew Morton , linux-mm , LKML , Netdev , Chen Lin Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 po 11. 7. 2022 v 17:34 odes=C3=ADlatel Alexander Duyck napsal: > > Rather than forcing us to free the page it might be better to move the > lines getting the size and computing the offset to the top of the "if > (unlikely(offset < 0)) {" block. Then instead of freeing the page we > could just return NULL and don't have to change the value of any > fields in the page_frag_cache. > > That way a driver performing bad requests can't force us to start > allocating and freeing pages like mad by repeatedly flushing the > cache. > I understand. On the other hand, if we free the cache page then the next time __page_frag_cache_refill() runs it may be successful at allocating the order=3D3 cache, the normal page_frag_alloc() behaviour w= ill therefore be restored. Maurizio