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 1CB9AC433EF for ; Sat, 5 Mar 2022 19:04:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 23E356B00B3; Sat, 5 Mar 2022 14:04:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C7546B00B4; Sat, 5 Mar 2022 14:04:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 067846B00B5; Sat, 5 Mar 2022 14:04:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0092.hostedemail.com [216.40.44.92]) by kanga.kvack.org (Postfix) with ESMTP id E48056B00B3 for ; Sat, 5 Mar 2022 14:04:05 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 97046181CB179 for ; Sat, 5 Mar 2022 19:04:05 +0000 (UTC) X-FDA: 79211257650.22.8F340E6 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) by imf16.hostedemail.com (Postfix) with ESMTP id 2A4FB180002 for ; Sat, 5 Mar 2022 19:04:04 +0000 (UTC) Received: by mail-ej1-f42.google.com with SMTP id yy13so15097339ejb.2 for ; Sat, 05 Mar 2022 11:04:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yDPu/xaKJbdDPmhQDpmRjEgFy5bmctUIRCD39EGUvLg=; b=eBnI1VXfagds1G8DpzAeYzz4CY4BK/8v2hq67nTYqGT9gPw7UZ0YhXCKsxxFFmiCnJ HuiUq3PyNtTeGgJNiQKW98ebwpbEBHjtfP1gPB8u20pb/9TJF3wyNv5210M+3JWigKxf tOo2KOEdtXC6DrYqfWWcdFb/dYiIDFG+Npb9Q= 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; bh=yDPu/xaKJbdDPmhQDpmRjEgFy5bmctUIRCD39EGUvLg=; b=cw2zXxmr8qO+vMsVa/r2bX+r1J/WuS4pTIQzQshb17aiilGl9rJEGG8T6SURcrMd8U 2OqqWoXGAksN3c19wJLiQUPAezs1xdeB2E6jKvrjUYjzLjyEXekqmyKu3p2GU1D3urOv LpePJyKXQL7vlG93y+kioW5ZG6Aebo8o2W7rILo3tyZD6vOe0lZdud8J4L6IGhEOZWCg Q0Vfa2H0SGX8cJ+pLrnrOrKAmfDxRGSo8hSB8AEbbQZZ7jTS1dE9WPgZcq0QkqBYX+pS UEnMcH9h7EZmkDLMZ7LI3GMNI3z85Ys8ahGsJo//QRy1X5KLf5X4XybmXvnS3GU6aeNH R1uQ== X-Gm-Message-State: AOAM532qy3uID+kK22lqPkkALcq4gQK7FnQUOBFUcociOO6rE/SBmShS 21pkiSwQk6Xvywcpbj+rsmLUZMilYIcbGqh5qwI= X-Google-Smtp-Source: ABdhPJzUtPPpzeZChp7DPebGqFV12kl4sy/KR0KcKHEnvG6qVSkgIxKuiuRcVgz+CEa9C9Z3z6rCbQ== X-Received: by 2002:a17:906:688e:b0:6db:20f:30a5 with SMTP id n14-20020a170906688e00b006db020f30a5mr2957657ejr.243.1646507043298; Sat, 05 Mar 2022 11:04:03 -0800 (PST) Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com. [209.85.221.42]) by smtp.gmail.com with ESMTPSA id u5-20020aa7d985000000b004024027e7dasm3758615eds.28.2022.03.05.11.04.02 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 05 Mar 2022 11:04:02 -0800 (PST) Received: by mail-wr1-f42.google.com with SMTP id j17so17409852wrc.0 for ; Sat, 05 Mar 2022 11:04:02 -0800 (PST) X-Received: by 2002:a05:6512:3042:b0:437:96f5:e68a with SMTP id b2-20020a056512304200b0043796f5e68amr3018649lfb.449.1646507032344; Sat, 05 Mar 2022 11:03:52 -0800 (PST) MIME-Version: 1.0 References: <20220304202822.d47f8084928321c83070d7d7@linux-foundation.org> <20220305042855.BFBB9C004E1@smtp.kernel.org> In-Reply-To: <20220305042855.BFBB9C004E1@smtp.kernel.org> From: Linus Torvalds Date: Sat, 5 Mar 2022 11:03:36 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [patch 3/8] mm: prevent vm_area_struct::anon_name refcount saturation To: Andrew Morton Cc: Matthew Wilcox , Vlastimil Babka , sumit.semwal@linaro.org, Sasha Levin , Peter Collingbourne , Michal Hocko , Alexey Gladkov , "Kirill A . Shutemov" , Kees Cook , Johannes Weiner , Cyrill Gorcunov , "Eric W. Biederman" , David Hildenbrand , Davidlohr Bueso , Dave Hansen , chris.hyser@oracle.com, Colin Cross , caoxiaofeng@yulong.com, Christian Brauner , Suren Baghdasaryan , patches@lists.linux.dev, Linux-MM , mm-commits@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 2A4FB180002 X-Stat-Signature: dtesp75i7ft4m79fxdxe5jcztyxfh8d5 X-Rspam-User: Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=eBnI1VXf; spf=pass (imf16.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.218.42 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=none X-Rspamd-Server: rspam07 X-HE-Tag: 1646507044-602867 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: On Fri, Mar 4, 2022 at 8:28 PM Andrew Morton wrote: > > To ensure anon_vma_name refcount does not overflow, stop anon_vma_name > sharing when the refcount reaches REFCOUNT_MAX (2147483647), which still > leaves INT_MAX/2 (1073741823) values before the counter reaches > REFCOUNT_SATURATED. This should provide enough headroom for raising the > refcounts temporarily. This is a classic case of kref simply being the wrong type for this. We sh ould move away from that idiotic "saturate with a warning" type, and just codify that what the page refs do is the RightThing(tm) to do. I've ranted against kref for years, I hate that damn thing. It's literally broken by design with the known leaking behavior. Oh well. I'm taking this patch as a "fix up refcount problems", and I guess I need to some day just extract the page_ref code into a nice type of its own so that it's usable outside of pages. (Others have copied the page_ref code manually, but there's no "helper type with functions to use it", which is why people then use that mis-designed refcount stuff). Linus