Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp85682lqm; Tue, 30 Apr 2024 13:41:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVnt7VVF33UyilK7RL5Q9YLdlLuJdIZC1hVom6IeKTkm1SqdO0ZtETu1ujzvIkvsBWgify5RXQPSf8XQjRAe1AAQG2V6oDCM/o/0QkVig== X-Google-Smtp-Source: AGHT+IFaS3H3Gt8rddktiNuARcQ2bwL/djZoNLX9E0uVaL5w7a0qG6CWn2+fxpaaNAwhS8pwkMN9 X-Received: by 2002:a19:7709:0:b0:51a:f342:d3ef with SMTP id s9-20020a197709000000b0051af342d3efmr388074lfc.5.1714509684903; Tue, 30 Apr 2024 13:41:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714509684; cv=pass; d=google.com; s=arc-20160816; b=fCMexPgSw3/7f/i0dNRs8WZgLblaicBleCfXnPrX83PMOBgYbcntY+SIJTWNPYHWgK PdFEUmtcqNGwIMnF9ExiIu07zSQ7km17hKsAButdsV8g2e2V5S9F7DP1SOgz7wXONCWt gP40EwD0DCim1jIS9Cdyq4+eHtMgmxPdqYf3UJK1WCpWc/6LTTybBWvekUf25RbkpuPt 5IlGpEf4aVFcFPqAfYK0T1nzQrdTC33E2UNOqhbUNQ+WIkRV/7uthaGJVA9m0VFAXYNs 7wv0pL7NeGfgK4ck9Rjk6xp6ZxVLFHpzCLHD7EvHs0MQ9Q8AGt6GONAsLQGvNlmd/0Ns vVig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=M+xMysOaTLOUYcuh4ijK9OYwvDDRj3hF0BT7ZxHVSLo=; fh=Fwb2oUXuDeDvZJGHn0wIaOPi60cuosViVSI+x3pjv5s=; b=kVfoX3+kR6Sfa1CSRB/d9I6TUmsFnB+lO/s7lPS1LlOw85CIjjTyZSMyk1FqcfmDkK F9+BnhfA2CTuFquZLVB4zEHudH9zgDDpX5fq+VJ4f69gsnSYxNOq24/RGxPq/LQHXwEr 7UazOelzriYeP5VwrZ4+JXld7QdA+VMZGBjR9V4djxHDOTithglsdTRmDkYsg+L4Mh9i Y/wsOirTe3cgUKmI3Ak8myT+JaxMKiro8cIeLgOLvDTtaKwDzUONwDEYJo/v/Mkdx7pU n7zbV5IJuIhQteOw6XIrkiK5dhP0TKT3N/BAgvAv5Ed++qPxfSYPczGnZMzfDJRAbq9t VI4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="I/kP6YaG"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-164718-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164718-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id t20-20020a170906269400b00a5229999852si15219512ejc.174.2024.04.30.13.41.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 13:41:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-164718-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="I/kP6YaG"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-164718-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164718-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9D9471F238B6 for ; Tue, 30 Apr 2024 20:41:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 41B541BED73; Tue, 30 Apr 2024 20:41:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="I/kP6YaG" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10E6C1A38E5 for ; Tue, 30 Apr 2024 20:40:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714509659; cv=none; b=lBrfQSf5ELeY4lO06OBZOoGbZIZTgR9gv8bwzTHvuPwndDS66NvsADjuTStDlyfXFQauisPcqih5CRGaZ9+QVFMscP+U37IJqs6do4x55yRzFzIv1w6uDkijFnWtPp/N75ywvnvvAr64vMftKRi4+p3JC/zFWqhyk7MaWXU0yvk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714509659; c=relaxed/simple; bh=hUPGLZZdKc8svvazAhagE3csCx3nW1eQdg89W1BMfQk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M+oZdzdvr6mtIgB9ZJ4STAwoAlGdodJo4nnIK87ZCnDuIQsSpeb2VgTDAiyitYuXMvogyvBByNUL4sCD0KnTpcINa5Ggk0l9bGs1OxMLK8mmj0XJ+GGiHJvYfZ5Vcnrw1kDlDnHAf7cwIO/YNrPkmg4CH+iE9RbSJQ1nthhiodo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=I/kP6YaG; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714509657; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M+xMysOaTLOUYcuh4ijK9OYwvDDRj3hF0BT7ZxHVSLo=; b=I/kP6YaGSh2+VzWxmdGxvrwfy3VGPmFArNZgEkEBum+5IuxxOEmGknGY09mH4/8R/+RYLb YZWN1xu7osBDqzURnwaVuGxPFXst/ZedpdC7pz2xGzkmy+btu7Xr7cBGPWlyMmppCOYWl3 FKycmh52jyAS/rCo8cDEKV4rUBJRgZc= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-529-YnVIUqY2MHGA4ILpxZDr4A-1; Tue, 30 Apr 2024 16:40:55 -0400 X-MC-Unique: YnVIUqY2MHGA4ILpxZDr4A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 093CA3C000AA; Tue, 30 Apr 2024 20:40:55 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.192.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 288E9C13FA1; Tue, 30 Apr 2024 20:40:52 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Vincent Donnefort , Dan Williams Subject: [PATCH v1 2/2] mm/rmap: sanity check that zeropages are not passed to RMAP Date: Tue, 30 Apr 2024 22:40:44 +0200 Message-ID: <20240430204044.52755-3-david@redhat.com> In-Reply-To: <20240430204044.52755-1-david@redhat.com> References: <20240430204044.52755-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 Using insert_page() we might have previously ended up passing the zeropage into rmap code. Make sure that won't happen again. Note that we won't check the huge zeropage for now, which might still end up in RMAP code. Signed-off-by: David Hildenbrand --- include/linux/rmap.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 7229b9baf20d8..5cb0d419a1d75 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -200,6 +200,9 @@ static inline void __folio_rmap_sanity_checks(struct folio *folio, /* hugetlb folios are handled separately. */ VM_WARN_ON_FOLIO(folio_test_hugetlb(folio), folio); + /* When (un)mapping zeropages, we should never touch ref+mapcount. */ + VM_WARN_ON_FOLIO(is_zero_folio(folio), folio); + /* * TODO: we get driver-allocated folios that have nothing to do with * the rmap using vm_insert_page(); therefore, we cannot assume that -- 2.44.0