Message ID | 20211221150140.988298-1-pasha.tatashin@soleen.com (mailing list archive) |
---|---|
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 52C26C433EF for <linux-mm@archiver.kernel.org>; Tue, 21 Dec 2021 15:02:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC9966B007D; Tue, 21 Dec 2021 10:02:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A77F56B007E; Tue, 21 Dec 2021 10:02:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93EEC6B0082; Tue, 21 Dec 2021 10:02:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0139.hostedemail.com [216.40.44.139]) by kanga.kvack.org (Postfix) with ESMTP id 8578B6B007D for <linux-mm@kvack.org>; Tue, 21 Dec 2021 10:02:03 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 4A78F82499B9 for <linux-mm@kvack.org>; Tue, 21 Dec 2021 15:02:03 +0000 (UTC) X-FDA: 78942116526.18.FEFDAD7 Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) by imf23.hostedemail.com (Postfix) with ESMTP id 3C05F14008B for <linux-mm@kvack.org>; Tue, 21 Dec 2021 15:01:38 +0000 (UTC) Received: by mail-qk1-f174.google.com with SMTP id d21so12783582qkl.3 for <linux-mm@kvack.org>; Tue, 21 Dec 2021 07:01:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=Uk8YgK1Ly4Qp8Z1wtUyGc5Gd4Fa8htvQXqStGOTAFlg=; b=DLq9Zxo6bIG9zVg+QwTMol+8eThkinUwX4GPZO59PHXMZQ3sk4vS6ndJ7Swp52Hsry DlCho1ZYO222nKWdIkh83F1p2NckEPiOArtaQ1reK6PFJBA49twgQJizJbKgj2QAz7pY FYU+zt1uwWLqFMvRlY/gETnpAvME3/+BTpRXovIsUNlZljT3ZZi3/fO/AB1KeUVB9L+u 4npjN+zuWT2A4dX16mVZtYP3xbLkiFgGCEPyZbOxI15DuWAC7rYcBf0loNMe/P6X6F+W kqLc8sIQGvcQRDumPH+FSY2LJLVUCgz4Sg5zj1KkTCE3jOqH4X6G9PZkVNgmP5TS8Wy1 9Xkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=Uk8YgK1Ly4Qp8Z1wtUyGc5Gd4Fa8htvQXqStGOTAFlg=; b=JzXxQ+YLttC/Nxfc3ki0OHo3+Hr8KFzYWtMX8t06o3FNGzq4npKgoqMDkVgIblPPHA blRAwGGNVauIZ32O2nxKIS7zamgwLU3f4mMdYeZTLqw6gHMhgUc1jb2+JQa2GzvNJUOT t3iIfHTQIDm1+PyYaXRCC3gFvWCpem7u9YWe3k7LqefHRc+9YJg0IOFeaxinoeBnXPcp Y/PzKPh/KkSS7adzycGAf0hhMTDPzsG16FtJ+jiPcvLMK4+7ujxZa/kUNv34cY7PaNtC JuWp+GWZnob6gC8H1wYvWP2JOkaROypulL8hoaFiij6drGy6wiu3uvgPjXKAeO9dYS7Y Zvvw== X-Gm-Message-State: AOAM531nsn6YCyZi+aJqmaEzlB1fP1rXzgI6zqvh/zA2X/2uYwXGGTIw I+tFZ7ncyQIOvEkdV87LnSUflg== X-Google-Smtp-Source: ABdhPJxT5O7xvrWjkIpZNLBuskaJWMbsvAeuLNSHPXbH7hWO0KuVJ+/DELo8dgq+NUXlN2pM74Zgkg== X-Received: by 2002:a37:9a82:: with SMTP id c124mr2233404qke.707.1640098904210; Tue, 21 Dec 2021 07:01:44 -0800 (PST) Received: from soleen.c.googlers.com.com (189.216.85.34.bc.googleusercontent.com. [34.85.216.189]) by smtp.gmail.com with ESMTPSA id d4sm1991371qkn.79.2021.12.21.07.01.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 07:01:43 -0800 (PST) From: Pasha Tatashin <pasha.tatashin@soleen.com> To: pasha.tatashin@soleen.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-m68k@lists.linux-m68k.org, anshuman.khandual@arm.com, willy@infradead.org, akpm@linux-foundation.org, william.kucharski@oracle.com, mike.kravetz@oracle.com, vbabka@suse.cz, geert@linux-m68k.org, schmitzmic@gmail.com, rostedt@goodmis.org, mingo@redhat.com, hannes@cmpxchg.org, guro@fb.com, songmuchun@bytedance.com, weixugc@google.com, gthelen@google.com, rientjes@google.com, pjt@google.com Subject: [PATCH v2 0/9] Hardening page _refcount Date: Tue, 21 Dec 2021 15:01:31 +0000 Message-Id: <20211221150140.988298-1-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.34.1.307.g9b7440fafd-goog MIME-Version: 1.0 X-Rspamd-Queue-Id: 3C05F14008B X-Stat-Signature: g1x1api7c5atibe1n9yndn84unp8ehdt Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=DLq9Zxo6; dmarc=none; spf=pass (imf23.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.174 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com X-Rspamd-Server: rspam11 X-HE-Tag: 1640098898-695634 Content-Transfer-Encoding: quoted-printable 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: <linux-mm.kvack.org> |
Series |
Hardening page _refcount
|
expand
|
From: Pasha Tatashin <tatashin@google.com> Changelog: v2: - As suggested by Matthew Wilcox removed "mm: page_ref_add_unless() does not trace 'u' argument" patch as page_ref_add_unless is going away. v1: - sync with the latest linux-next RFCv2: - use the "fetch" variant instead of "return" of atomic instructions - allow negative values, as we are using all 32-bits of _refcount. It is hard to root cause _refcount problems, because they usually manifest after the damage has occurred. Yet, they can lead to catastrophic failures such memory corruptions. There were a number of refcount related issues discovered recently [1], [2], [3]. Improve debugability by adding more checks that ensure that page->_refcount never turns negative (i.e. double free does not happen, or free after freeze etc). - Check for overflow and underflow right from the functions that modify _refcount - Remove set_page_count(), so we do not unconditionally overwrite _refcount with an unrestrained value - Trace return values in all functions that modify _refcount Applies against next-20211221. Previous verions: v1: https://lore.kernel.org/all/20211208203544.2297121-1-pasha.tatashin@soleen.com RFCv2: https://lore.kernel.org/all/20211117012059.141450-1-pasha.tatashin@soleen.com RFCv1: https://lore.kernel.org/all/20211026173822.502506-1-pasha.tatashin@soleen.com [1] https://lore.kernel.org/all/xr9335nxwc5y.fsf@gthelen2.svl.corp.google.com [2] https://lore.kernel.org/all/1582661774-30925-2-git-send-email-akaher@vmware.com [3] https://lore.kernel.org/all/20210622021423.154662-3-mike.kravetz@oracle.com Pasha Tatashin (9): mm: add overflow and underflow checks for page->_refcount mm: Avoid using set_page_count() in set_page_recounted() mm: remove set_page_count() from page_frag_alloc_align mm: avoid using set_page_count() when pages are freed into allocator mm: rename init_page_count() -> page_ref_init() mm: remove set_page_count() mm: simplify page_ref_* functions mm: do not use atomic_set_release in page_ref_unfreeze() mm: use atomic_cmpxchg_acquire in page_ref_freeze(). arch/m68k/mm/motorola.c | 2 +- include/linux/mm.h | 2 +- include/linux/page_ref.h | 149 +++++++++++++++----------------- include/trace/events/page_ref.h | 58 ++++++++----- mm/debug_page_ref.c | 22 +---- mm/internal.h | 6 +- mm/page_alloc.c | 19 ++-- 7 files changed, 132 insertions(+), 126 deletions(-)