Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1390321pxb; Fri, 1 Oct 2021 09:36:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhjRjS9CQOADweGyWkqkRK9bUVlO/cNdRYDFT27bsq50LYZ1usJMUV9AKSnWJxEz0tNTyq X-Received: by 2002:a17:906:8295:: with SMTP id h21mr7124777ejx.101.1633106201745; Fri, 01 Oct 2021 09:36:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633106201; cv=none; d=google.com; s=arc-20160816; b=Q3T4w4qcgaxSDegSQBr8ouZMJ+lMPHYr1WckhGlJLuARiXay00qTjTdYFFP6pA/6LC 3MHV9w6yfEWedrhBEnTrt4o9owoW9Sl2ZBDZbnwRvyMWT1gDcH7k8ZnuQ+yC5pPGBy3g FPMKkx/ww7fEqOHdAbJw0F4udvrahOcuX7dz9U6k8hvOq/lSaEuPU23eM/4FX3Kj/pFu VLopxP00zfs8g51mEuE8KroHlVpFIP5U0M+K4AWfDzc7dtk49ihr5xgGB0hxaYz7mnLO oJ4plgTyGFUnmxjnONIthtL6rnvueC9Si31t82paSo6ixcdmjq4ZJaehvr/ZN/G6CZJU 5sPw== 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=Ng6JDVwxCaQ8Od84ybUMD2tq3euaLTCb3M9qHCPLiRk=; b=Jj0w5badFn6K/WgW1LUhMpj4D/wjFK0DiYKJX2SaFWbWzA0goAW/r/0fJa7yFrNz7z 57cIb+kXu/I3mBEWeNL5toRThBoqUJr++ijH5/MMOEsWs+2/cfyYQzP+b6VG2+/k6nzb iB/4JDjJN3g08Cf1TcwPuTjKPE75DhwWl7Qrfgc+W6edRpKtPOPX2hfuJW9CyG5sZwwk M1fDssc8qQSbhSJZ4JlqPkDHkE7iVeYdYIZUK5Zm8RDOp6fuajOi6fNt3iG7TpxBQ4JW H8b2fPsqxEQ+QmauFwM1hNJehZIR2npZWM6CNGrGDyY3GnK5FolTYEegjyDTNX0KHXa4 383g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=pWMrJuJh; 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 b12si10013146edd.196.2021.10.01.09.35.57; Fri, 01 Oct 2021 09:36:41 -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=pWMrJuJh; 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 S1354915AbhJAQgF (ORCPT + 99 others); Fri, 1 Oct 2021 12:36:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232072AbhJAQgE (ORCPT ); Fri, 1 Oct 2021 12:36:04 -0400 Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EA24C061775 for ; Fri, 1 Oct 2021 09:34:20 -0700 (PDT) Received: by mail-yb1-xb31.google.com with SMTP id v10so21747663ybq.7 for ; Fri, 01 Oct 2021 09:34:20 -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=Ng6JDVwxCaQ8Od84ybUMD2tq3euaLTCb3M9qHCPLiRk=; b=pWMrJuJhvcJ8kr7fX2piDmdGOeTPIu6T7Ho6tdDljq/6BkXtPtkfuXNxbt+VAqT0yx qxH/KnQhNeeeJUh0T0GkC6QwHIxhqylRWcgJyXMU+D6CEa1A2xn3JkoGhw6s1Gc+6MsL ldOkQXXl1f/J28Sh7R0D3OzTkx/zoHPdUWAcXgmv7vIlZJmvWyWWLCtMASYrqv0cHOIu xCiqq/L6s1VtjDKAFFZ4nN/n1H5YNknX/iIT7eaOoy5vqUnPIkcIofbg2CwaVcWRlIgh eIrXGyMuXaA4shxX3MN9QTuMdzpFe/4ddYSukhdrsyyKn3FJSo2U9wi3edKON9VPPnaw zZog== 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=Ng6JDVwxCaQ8Od84ybUMD2tq3euaLTCb3M9qHCPLiRk=; b=xxfmmgNFOF30TNf8O9/7OxvYg9waeU5qn55y0J/6kL79ttbnQiK2C7JoTMkufpUH7X K9PWRdM8kU2l3dj4crGYW0yJ3OFasSqaMhiKoQdtaNtcQu3T+YvqUkFo4t9k+BDzuoQG 1I/OAQVZscmXjPYrevBKuZTNEGshs5HzatF+Cm4CK7KPTqzJEmC+aH5cjlZgcOrLKUn+ mG4ljs4bNaiRPhXijH4xiGNRi0k+U0lT34RXXopDh9qUdJqLk2D2P0ts6vOtM0zJNw90 j0SOvaZ1KJDS3ZJEDulAdqaFBHC7npYBNyQUmc4b5X68M3PsJkCGKfyLHbwQ0QauNchM hbUA== X-Gm-Message-State: AOAM533Nat5npoGo/yhXEpuWtbdU2uYqFE3A+cC+G2iXNxiW/EaCoQsm 9zn7czUeqqft0jvDRpG1rPsHhYeMl82U/QGqYcA7Ig== X-Received: by 2002:a05:6902:124f:: with SMTP id t15mr8144006ybu.161.1633106059244; Fri, 01 Oct 2021 09:34:19 -0700 (PDT) MIME-Version: 1.0 References: <20210902231813.3597709-1-surenb@google.com> <20210902231813.3597709-2-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Fri, 1 Oct 2021 09:34:08 -0700 Message-ID: Subject: Re: [PATCH v9 2/3] mm: add a field to store names for private anonymous memory To: Rasmus Villemoes Cc: Andrew Morton , Colin Cross , Sumit Semwal , Michal Hocko , Dave Hansen , Kees Cook , 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, John Hubbard , 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@oracle.com, 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 Fri, Oct 1, 2021 at 12:01 AM Rasmus Villemoes wrote: > > On 03/09/2021 01.18, Suren Baghdasaryan wrote: > > From: Colin Cross > > > > > > changes in v9 > > - Changed max anon vma name length from 64 to 256 (as in the original patch) > > because I found one case of the name length being 139 bytes. If anyone is > > curious, here it is: > > dalvik-/data/dalvik-cache/arm64/apex@com.android.permission@priv-app@GooglePermissionController@GooglePermissionController.apk@classes.art > > I'm not sure that's a very convincing argument. We don't add code > arbitrarily just because some userspace code running on some custom > kernel (ab)uses something in that kernel. Surely that user can come up > with a name that doesn't contain GooglePermissionController twice. > > The argument for using strings and not just a 128 bit uuid was that it > should (also) be human readable, and 250-byte strings are not that. > Also, there's no natural law forcing this to be some power-of-two, and > in fact the implementation means that it's actually somewhat harmful > (give it a 256 char name, and we'll do a 260 byte alloc, which becomes a > 512 byte alloc). So just make the limit 80, the kernel's definition of a > sane line length. Sounds reasonable. I'll set the limit to 80 and will look into the userspace part if we can trim the names to abide by this limit. > As for the allowed chars, it can be relaxed later if convincing arguments can be made. For the disallowed chars, I would like to go with "\\`$[]" set because of the example I presented in my last reply. Since we disallow $, the parsers should be able to process parentheses with no issues I think. > > > > +/* mmap_lock should be read-locked */ > > +static inline bool is_same_vma_anon_name(struct vm_area_struct *vma, > > + const char *name) > > +{ > > + const char *vma_name = vma_anon_name(vma); > > + > > + if (likely(!vma_name)) > > + return name == NULL; > > + > > + return name && !strcmp(name, vma_name); > > It's probably preferable to spell this > > /* either both NULL, or pointers to same refcounted string */ > if (vma_name == name) > return true; > > return name && vma_name && !strcmp(name, vma_name); > > so you have one less conditional in the common case. Ack. > > Rasmus Thanks for the review! Suren.