Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1681409pxb; Thu, 7 Oct 2021 12:46:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5ndLE3Zpc+zoIZeW/RBBU0Q0Dj49Cc31j08Xwse6Uz5V3ycFQyLipIx3tMYIw+54ygOse X-Received: by 2002:a05:6a00:2311:b0:431:c19f:2a93 with SMTP id h17-20020a056a00231100b00431c19f2a93mr6284992pfh.11.1633635966994; Thu, 07 Oct 2021 12:46:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633635966; cv=none; d=google.com; s=arc-20160816; b=jsps1uMro5kiiVVol1ple9Ku0ZoGlqWC44/GYECyo/Ic2+Fp7dw6oqTko1LLkdw8zE naY1Py3TVtGPfEKLgYuWFADKugY9RuhYv5QJ+aM9X39AfGR0iB//sG7amLBerVvV4Nux of9jE3oOrVZ8tQyZV/qyZTo7XoUrgxSxotPLYV1wexoWk5C3iqOqxzBIL/UrBhhYrAWG bgn4nlTsnQbE51it7uwJypdKDYgXrzqD+USZODSdUbBC3iHIh832tLb9QBKTfNg3Mf8z fYNNP0VDABjla6/vVjY/B2mpiH025O8eCEG5FSzH9B87ZPCxsb8RxqTKREMYAnfVyD0O GsWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=o4WwfSdG/6KRIuI/J9zyZX24q26V4qiHr2+KV/sCerI=; b=YKaISqsI1UoYO0d6PNom5S7nUg60ST1lpRoHnE11RUFaeGZy7kr4HdRwpX0WoJKe2B 46pvMM7WEjLoyzIVtOMwC7kTqU+vPBVqTP8MTPh5hBRDBO8P4X9Oh08T9hq+N43o7Q2I eVJX0VnXI4hL9TDFysZxhMqfid+aUS/C7hC0VeYQoNPL9OsvzOpXx1FVL5YrIXbwUaeb 3LX8n3Y1CZ/K+GanbAFvz0A0zZ/r8K/D5teJ/p6+S2QJhFt/FkF2Eu6bGGknUIb37uqV XY1SpIwbAslzL6yzBz2PatkdNh7XzlRNH05jvwuX+V8rcc28Sd8vOpNoojEMe23Ivhe9 Iadg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=UFWObsTY; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i37si195905pgi.494.2021.10.07.12.45.53; Thu, 07 Oct 2021 12:46:06 -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=@chromium.org header.s=google header.b=UFWObsTY; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243541AbhJGSOz (ORCPT + 99 others); Thu, 7 Oct 2021 14:14:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243527AbhJGSOy (ORCPT ); Thu, 7 Oct 2021 14:14:54 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20406C061570 for ; Thu, 7 Oct 2021 11:13:00 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id g13-20020a17090a3c8d00b00196286963b9so7529694pjc.3 for ; Thu, 07 Oct 2021 11:13:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=o4WwfSdG/6KRIuI/J9zyZX24q26V4qiHr2+KV/sCerI=; b=UFWObsTY+6ez5xDu9StX0xHOEvb0Awqkv0IojxdYI+PxQZVMQnm1+78GXylVO7eQKc unCWRkoNBPz+dlTqyMSHkXjEyBSrxvIoYe8zqlUquJAovzzTTAutOaWA2u7XXWw+cqmI 8LjuIEZ3xAwyUSETK/5DPVjRVFkuDfq7sRi3w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=o4WwfSdG/6KRIuI/J9zyZX24q26V4qiHr2+KV/sCerI=; b=aK4ESUjHECuKSBEi0zIvpW7zfOWdsehBFW5NpNX9zsIplez3AlXIjKHaNrVxaT8BVx lqTVjmg7INi12j1QkKoiYvko5z4dPswTqsaTeELlyGBuotBxLegYJVPB7oHwwu3+zE78 gxrNREsYByC2SBDojtgh5VhtbURIb4Y/iEjGM7QjEY5o89jhLJ7di11hPa31pRjd6OF5 HMqucF6xGpp1ttyo29/ARjSwdOsuS4lLzeG+NnmIjElca218wFaOYvJxn5QxjZsbe9ig L9E/C1TNgfmaxL4EeZ348qnkDA0FL+mQ1kAhSysCWl+TBtLbbeqgyp2tJFdeYQAv3G9j 6G/w== X-Gm-Message-State: AOAM531xgXroj/zX9HItbxk4kM+DxEwPnJmeYvvpTBtFqnBkRN88DCAg jkK3X5GGgbA5UyVhpMIeUGZ/Ag== X-Received: by 2002:a17:902:c950:b0:13e:fbf9:7939 with SMTP id i16-20020a170902c95000b0013efbf97939mr5395214pla.65.1633630379611; Thu, 07 Oct 2021 11:12:59 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id g14sm6529008pjd.24.2021.10.07.11.12.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 11:12:59 -0700 (PDT) Date: Thu, 7 Oct 2021 11:12:58 -0700 From: Kees Cook To: Suren Baghdasaryan 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, Chinwen Chang =?utf-8?B?KOW8temMpuaWhyk=?= , 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 Subject: Re: [PATCH v10 3/3] mm: add anonymous vma name refcounting Message-ID: <202110071111.DF87B4EE3@keescook> References: <20211006175821.GA1941@duo.ucw.cz> <92cbfe3b-f3d1-a8e1-7eb9-bab735e782f6@rasmusvillemoes.dk> <20211007101527.GA26288@duo.ucw.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? -- Kees Cook