Message ID | 20211117012059.141450-1-pasha.tatashin@soleen.com (mailing list archive) |
---|---|
Headers | show
Return-Path: <SRS0=rmuZ=QE=kvack.org=owner-linux-mm@kernel.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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EED76C43217 for <linux-mm@archiver.kernel.org>; Wed, 17 Nov 2021 01:21:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 839B463240 for <linux-mm@archiver.kernel.org>; Wed, 17 Nov 2021 01:21:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 839B463240 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=soleen.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 94FBA6B0072; Tue, 16 Nov 2021 20:21:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FE456B0073; Tue, 16 Nov 2021 20:21:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79F966B0074; Tue, 16 Nov 2021 20:21:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0174.hostedemail.com [216.40.44.174]) by kanga.kvack.org (Postfix) with ESMTP id 6B5966B0072 for <linux-mm@kvack.org>; Tue, 16 Nov 2021 20:21:13 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2A42F85D51 for <linux-mm@kvack.org>; Wed, 17 Nov 2021 01:21:03 +0000 (UTC) X-FDA: 78816668406.11.3AC3BF3 Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) by imf13.hostedemail.com (Postfix) with ESMTP id 68987105298A for <linux-mm@kvack.org>; Wed, 17 Nov 2021 01:21:02 +0000 (UTC) Received: by mail-qt1-f182.google.com with SMTP id p19so1057410qtw.12 for <linux-mm@kvack.org>; Tue, 16 Nov 2021 17:21:02 -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=Lsu/+Dlf6nvbIcwhCk1nDEAKiHRAiNEwHnNPLdpCCNI=; b=iz+DmZROy+IVt+Y2G2VVdSXUsjtZvtQQXfpLBlxzPuVNTlzOyebumq4rKHQfJDpZgV ARKt+eb+2VS2+7webHt82qH0TI7rGj8A5TircT+5CYVDrKoNoS9B2e82vJvpNx0lloIM cgTkUXDhfuNNt6JPZOLEViSNjpYPE0/MIipMAtiz9X7Fi5F12qas2D/mrGlse+nWV6g9 xUj6k1hzJlOHwkq7BBan+Pl3rhHTPhk67vztQefmwb+jhTZDJ4dkCE2PK0zb3PXr7ZZX r2//FirkOYJ3qQ7OrprxHNf7eSaCz4TpGAd3KmnTQDJDY9PggIeIiEpVjO0hhn1CVmdF 3UNw== 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=Lsu/+Dlf6nvbIcwhCk1nDEAKiHRAiNEwHnNPLdpCCNI=; b=5jscwmYzjyP8+FTcmhPd6t0mvEt8EsqOgD2Uldq80jDmzSQwimNS0DKWVAy+qFAcIu PbNdK8/e4uwCdxMsF9dNUzbbTgneHF1iqRghCpgGCKqDHgEgVp1OXmMMNcSPB2KH03sa jL/mUZfegZJq60spfmyK76cCttfDhByrEHlFLDbjderRdOnrfHoy9e//3LWb7Ud2lGyN 2gMhg9uOsOISIG/tPTAn4D3p1M6lfffluJip7wgEiuzKq3sU9C3JgqmB94yw8ZD7SnO5 t8XsfoWJULw+MIQHCsafWzfcWHmCpx/4CuZoAae6Vk8sxVzbMF5P9EdWYzbZl0H5eZPr 16fw== X-Gm-Message-State: AOAM533qRgzM2rhpczM+a3qbRPHgG29Wkudlb4YJvS2xszAmE2AeyZfL pkuV4UFNrX/zoaqazEHMnOvtNQ== X-Google-Smtp-Source: ABdhPJzEiXHAXrib5AI+jV3jGqeNMAXCg9XwRAA02iSxFrGPE6Xu/nJ4VSQHsPSEKxNgj5/ipkQAEA== X-Received: by 2002:ac8:57ca:: with SMTP id w10mr12661397qta.88.1637112062135; Tue, 16 Nov 2021 17:21:02 -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 i6sm3482289qti.40.2021.11.16.17.21.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 17:21:01 -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: [RFC v2 00/10] Hardening page _refcount Date: Wed, 17 Nov 2021 01:20:49 +0000 Message-Id: <20211117012059.141450-1-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 68987105298A X-Stat-Signature: 5giqpqky55sc7njzrxm4wzii8gm4fb9x Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=iz+DmZRO; spf=pass (imf13.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.182 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none X-HE-Tag: 1637112062-266078 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: - 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-20211116. Previous verions: 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 (10): mm: page_ref_add_unless() does not trace 'u' argument 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 | 159 +++++++++++++++----------------- include/trace/events/page_ref.h | 99 +++++++++++++++----- mm/debug_page_ref.c | 30 ++---- mm/internal.h | 6 +- mm/page_alloc.c | 19 ++-- 7 files changed, 180 insertions(+), 137 deletions(-)