From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F5ECCCA47B for ; Mon, 11 Jul 2022 16:17:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 93E7F94000F; Mon, 11 Jul 2022 12:17:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C58A8E0002; Mon, 11 Jul 2022 12:17:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 78CDB94000F; Mon, 11 Jul 2022 12:17:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6A1F78E0002 for ; Mon, 11 Jul 2022 12:17:56 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3C32AD1A for ; Mon, 11 Jul 2022 16:17:56 +0000 (UTC) X-FDA: 79675325352.12.21504F3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 92E72C0074 for ; Mon, 11 Jul 2022 16:17:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657556275; 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=exNm1MPRJFQifAm8hvmwbwBtw6dy0ZDHw6uMbJ9GzpkcDpp9P4/VFVK3O4ilpuIpmi+KbG 2oF8Q4vNgiKerOEyOFxg1xL1YlM0CmuyjsipyQHrgYBOE55SLZSDkLv3k5/IJWIlf05qBS nZt03HOs5Z+FOWqgONulVhbWqx0b3gQ= Received: from mail-ua1-f72.google.com (mail-ua1-f72.google.com [209.85.222.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-623-Wqs9XhFYNlSKtBrznC4uvA-1; Mon, 11 Jul 2022 12:17:50 -0400 X-MC-Unique: Wqs9XhFYNlSKtBrznC4uvA-1 Received: by mail-ua1-f72.google.com with SMTP id r1-20020a9f2c01000000b00383196b2690so1083899uaj.18 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=CiPI8xnN6cdpuxErSm60bEZ6CNiQp3YJp1wVmeppnDfmZiP76f+h0nlhmSlDX1P744 7OhPrSUIvrDEOVzesZzZuCOU8etcXWh0dcHyxOxYu98dZLXS2q83k52IgftfDagzTfOi 4Qg/cMMubSBNSXNBEMU6+ZDdl/MawU5ojE+CeXZpfcikUADoE2ODPsD8wJ7BljjO5bIV OXTiF8icyhPgv9xxsr86QJFLdnH4Skd4AuSMocNFMZCOCldWDTa9q/khoHpRSMu9eMG6 I8W5dfwAvw3AmfuVGhbGiOTE5k62SGiUlIS0NrhWQq9T6IiOlzH2OBaWECek++KUpvlA W5Ew== X-Gm-Message-State: AJIora+mRqWwMGECIUBjWOdwqGSCpgsOTbXvm5KFNC2uC3WrRmGV750q e7eN/er0T12f0fCvsnC0sEiqjMEUXXmrExlqExamkvAADPMMAD1jIgaM5IZQlp0zzWz3RCGc6Gy nbJIUTi+4CrDJEKy/AqCf3Lpe42I= X-Received: by 2002:a67:e9c2:0:b0:357:547e:d541 with SMTP id q2-20020a67e9c2000000b00357547ed541mr2640138vso.68.1657556269855; Mon, 11 Jul 2022 09:17:49 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tcsrYRDtkH4eUNCid1rUG2+vczmpwYghbpC6RG7cGJFQGmWBSLROKXXH4pGLODJIZOU2JW5CpBt0iHf5vZvHw= 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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657556275; h=from:from:sender: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:dkim-signature; bh=NFy7tx4vuflJ9T67q4fsWyscGk3VBcpn9gI9HIE/8ZA=; b=OJBMwWCtsU6MV0d1ZlUTj770Z+7j9+D6Ryx9ds3cYDJnm4t/fb+jk3gCedxElKVlpk2Ws8 0f3feBb5KZzRG7hkNdOhr/FQK4u9kWrCAnPSgnOaVSTiCT7uwymRm8NMTcSFzMrfnbrk86 gFlAN4FiEY+1Vfs0wfXW9SL20gyR9hs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657556275; a=rsa-sha256; cv=none; b=K33UstkygbCM1Mtwroh99w4P+cxSYl/C45ZwWg6lQnCuke53BmRfxEoVdL+eE82CgjPONQ FUxGfOlypjoZw8zJMBYNlQWJH0F3JpvYTHV7ufkXkxvpVvG/RerqKkt/bnA/x2DKPVVAjn oY5M4AoZrf1eioOscNchGBgVdiW1BKQ= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=exNm1MPR; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf28.hostedemail.com: domain of mlombard@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=mlombard@redhat.com X-Stat-Signature: wo78er6hsyhfo6k46h5h1ah3gmksmctz X-Rspam-User: Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=exNm1MPR; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf28.hostedemail.com: domain of mlombard@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=mlombard@redhat.com X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 92E72C0074 X-HE-Tag: 1657556275-388677 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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