Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1686052pxb; Thu, 7 Oct 2021 12:53:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnszMxda/fAOt32og/x6IK/k0rgLuGkOD8iZ/h4Ghl8ocYfGXNAslD9L815eiaJJAdye7Q X-Received: by 2002:a50:d88b:: with SMTP id p11mr8766625edj.287.1633636405449; Thu, 07 Oct 2021 12:53:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633636405; cv=none; d=google.com; s=arc-20160816; b=C4xR1/25YzVQ6zSrq7O/QKDyj395rqg8X5LBT5uRF1pg5ptiM4+xUVHW5N16HMRzg/ ccYrSyZk4EuilmfCBEtOr7PuCmFg5jhX9e4W9SsdiWUUHOJuiy1l70ASjGLgS2ScCrGp Ro4rnyt9FMw7dakAeaf4i72ac0hVgxQ/Ukc7ubb/z9fl+eTjEAnFxZ2V5ioYKqJpUy+F g8H36g/sOOufLoI39457wTbeUgcCJKMwh+4VHAChuctC+0V4/2+PTZpCUNlNZ7CcdWix DDicQhqTVd8r2B2GsbG3kpL0h1A0qbjDXpkw0zhGLZncTx3iqY3+azvt8b588ueiG8pd ziNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=E0+5wT+wrdMqcXbNJTk/9zibrUNlQPSrWQVNSFGRH0Q=; b=JAtFLLnx3P1q0H8ac2YAzqH4parQ4GtHHJ0iq+9GnyPlPC7Y4d8ca1564yfwKQ9R75 eR5VaUXWyJZ7qFU02jr9B8SJT2Lb1aX8Mg1f4iYkEbchR9mwLIJ7csjsGB9r3iBX0SIW WuXZLA50aHaxbHdTAyIdY2kUxb9F+U4dPHTgzYVXhoycGNuqlAunzG5q6DHaaClLm7AV zdsxlqSWpBzJihyjBr/ppQf+DPs2dCPeFfxFosq83zorytjLwIWBGL/yeWARie7NWcWA fCbohf9NcM1xOQhgD5ewJmYODuxml/vOckddfAiSOngskmjQ/JApgTZrBic+tk4PSjb6 C8rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=f+jqxJIJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g23si273162ejw.249.2021.10.07.12.53.01; Thu, 07 Oct 2021 12:53:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=f+jqxJIJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233854AbhJGSwQ (ORCPT + 99 others); Thu, 7 Oct 2021 14:52:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233860AbhJGSwQ (ORCPT ); Thu, 7 Oct 2021 14:52:16 -0400 Received: from mail-yb1-xb2c.google.com (mail-yb1-xb2c.google.com [IPv6:2607:f8b0:4864:20::b2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7603C061760 for ; Thu, 7 Oct 2021 11:50:21 -0700 (PDT) Received: by mail-yb1-xb2c.google.com with SMTP id s64so15526566yba.11 for ; Thu, 07 Oct 2021 11:50:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=E0+5wT+wrdMqcXbNJTk/9zibrUNlQPSrWQVNSFGRH0Q=; b=f+jqxJIJSLt5FZwMq8HxqaGUYxnqZd2XHM9BdnYqSOU2kuqNgIW8wdNJ+eIspkoDj7 Y9gcKeC/pYYgB7yyLLyYx+RB+VVGInIY8fY+l7ByRtsBh75EzVZLLHUx0s/JgAaUxjSx hGIwnJa6ufRLm2694PKbR8PkW8ggrSVSF19tXiQkNxjdPHqzGQENgGZtovh4JP3nyBmm km/ahg3AYuRK3xJ3BxULxSYwkGBP+AaFviZfQCvWKnwo6U4m7pnW6dL83ihp8vhP+OEn KjczJIjrhAJYXJHrPGk4lt9lhphV4v8E1sVoy0rsM5C4FRJOlgdvGR8HGAR7WauUTcVs gaxQ== 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=E0+5wT+wrdMqcXbNJTk/9zibrUNlQPSrWQVNSFGRH0Q=; b=4rdWr7ZtORb7NtW/woCHkJQBp8yv4PqYlDmUHYtx6Lz33JXksgMIQaMxXyRXbXlJWP elZpeOBMQqwG1CYoKaItDcbhTKukFoezNqkwj3CA0EyNSzfyTpCdNhqQWm5W6tiP2WVr sEBFnCwmeK/FZSuDNQKQ6EFexOwpCFn1drVQydTGd4hWA0R5d60SaNE812ndg7z9ciJb +T17er3bfxDNhMQarre8ZVWzytPFprkMKiD2dN/u9vJsrBTf3TdJAUY2BzFkHMoxLVS1 W57y7ChV6VB06nC5oK8NF4iN+9vig3J13a+inuVdeXoit0wU7hDzwF71EcnxSUmVXyEq slAw== X-Gm-Message-State: AOAM531fnw0P1ZkGYWGPOFUzsc61/0jbc7zJ2Bz0rY6c1unC3CLZwR2j WqCRk+gTd/MhTAnjjAJThjelhNprp852pCcMGcjqUA== X-Received: by 2002:a25:5b04:: with SMTP id p4mr6402702ybb.34.1633632620440; Thu, 07 Oct 2021 11:50:20 -0700 (PDT) MIME-Version: 1.0 References: <20211006175821.GA1941@duo.ucw.cz> <92cbfe3b-f3d1-a8e1-7eb9-bab735e782f6@rasmusvillemoes.dk> <20211007101527.GA26288@duo.ucw.cz> <202110071111.DF87B4EE3@keescook> In-Reply-To: <202110071111.DF87B4EE3@keescook> From: Suren Baghdasaryan Date: Thu, 7 Oct 2021 11:50:09 -0700 Message-ID: Subject: Re: [PATCH v10 3/3] mm: add anonymous vma name refcounting To: Kees Cook Cc: Michal Hocko , Pavel Machek , Rasmus Villemoes , David Hildenbrand , John Hubbard , Andrew Morton , Colin Cross , Sumit Semwal , Dave Hansen , Matthew Wilcox , "Kirill A . Shutemov" , Vlastimil Babka , Johannes Weiner , Jonathan Corbet , Al Viro , Randy Dunlap , Kalesh Singh , Peter Xu , rppt@kernel.org, Peter Zijlstra , Catalin Marinas , vincenzo.frascino@arm.com, =?UTF-8?B?Q2hpbndlbiBDaGFuZyAo5by16Yym5paHKQ==?= , Axel Rasmussen , Andrea Arcangeli , Jann Horn , apopple@nvidia.com, Yu Zhao , Will Deacon , fenghua.yu@intel.com, thunder.leizhen@huawei.com, Hugh Dickins , feng.tang@intel.com, Jason Gunthorpe , Roman Gushchin , Thomas Gleixner , krisman@collabora.com, Chris Hyser , Peter Collingbourne , "Eric W. Biederman" , Jens Axboe , legion@kernel.org, Rolf Eike Beer , Cyrill Gorcunov , Muchun Song , Viresh Kumar , Thomas Cedeno , sashal@kernel.org, cxfcosmos@gmail.com, LKML , linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm , kernel-team Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 7, 2021 at 11:13 AM Kees Cook wrote: > > On Thu, Oct 07, 2021 at 10:50:24AM -0700, Suren Baghdasaryan wrote: > > On Thu, Oct 7, 2021 at 10:31 AM Michal Hocko wrote: > > > > > > On Thu 07-10-21 09:58:02, Suren Baghdasaryan wrote: > > > > On Thu, Oct 7, 2021 at 9:40 AM Michal Hocko wrote: > > > > > > > > > > On Thu 07-10-21 09:04:09, Suren Baghdasaryan wrote: > > > > > > On Thu, Oct 7, 2021 at 3:15 AM Pavel Machek wrote: > > > > > > > > > > > > > > Hi! > > > > > > > > > > > > > > > >> Hmm, so the suggestion is to have some directory which contains files > > > > > > > > >> representing IDs, each containing the string name of the associated > > > > > > > > >> vma? Then let's say we are creating a new VMA and want to name it. We > > > > > > > > >> would have to scan that directory, check all files and see if any of > > > > > > > > >> them contain the name we want to reuse the same ID. > > > > > > > > > > > > > > > > > > I believe Pavel meant something as simple as > > > > > > > > > $ YOUR_FILE=$YOUR_IDS_DIR/my_string_name > > > > > > > > > $ touch $YOUR_FILE > > > > > > > > > $ stat -c %i $YOUR_FILE > > > > > > > > > > > > Ah, ok, now I understand the proposal. Thanks for the clarification! > > > > > > So, this would use filesystem as a directory for inode->name mappings. > > > > > > One rough edge for me is that the consumer would still need to parse > > > > > > /proc/$pid/maps and convert [anon:inode] into [anon:name] instead of > > > > > > just dumping the content for the user. Would it be acceptable if we > > > > > > require the ID provided by prctl() to always be a valid inode and > > > > > > show_map_vma() would do the inode-to-filename conversion when > > > > > > generating maps/smaps files? I know that inode->dentry is not > > > > > > one-to-one mapping but we can simply output the first dentry name. > > > > > > WDYT? > > > > > > > > > > No. You do not want to dictate any particular way of the mapping. The > > > > > above is just one way to do that without developing any actual mapping > > > > > yourself. You just use a filesystem for that. Kernel doesn't and > > > > > shouldn't understand the meaning of those numbers. It has no business in > > > > > that. > > > > > > > > > > In a way this would be pushing policy into the kernel. > > > > > > > > I can see your point. Any other ideas on how to prevent tools from > > > > doing this id-to-name conversion themselves? > > > > > > I really fail to understand why you really want to prevent them from that. > > > Really, the whole thing is just a cookie that kernel maintains for memory > > > mappings so that two parties can understand what the meaning of that > > > mapping is from a higher level. They both have to agree on the naming > > > but the kernel shouldn't dictate any specific convention because the > > > kernel _doesn't_ _care_. These things are not really anything actionable > > > for the kernel. It is just a metadata. > > > > The desire is for one of these two parties to be a human who can get > > the data and use it as is without additional conversions. > > /proc/$pid/maps could report FD numbers instead of pathnames, which > > could be converted to pathnames in userspace. However we do not do > > that because pathnames are more convenient for humans to identify a > > specific resource. Same logic applies here IMHO. > > Yes, please. It really seems like the folks that are interested in this > feature want strings. (I certainly do.) For those not interested in the > feature, it sounds like a CONFIG to keep it away would be sufficient. > Can we just move forward with that? Would love to if others are ok with this. > > -- > Kees Cook