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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3039EC4332F for ; Fri, 1 Oct 2021 16:34:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E80D619F5 for ; Fri, 1 Oct 2021 16:34:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354998AbhJAQgG (ORCPT ); Fri, 1 Oct 2021 12:36:06 -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-Google-Smtp-Source: ABdhPJy4E0vJOJpFn2dtFuJvIo31XqxsO2A2l/zIgkxN2EgX2oY+90UDMspe6mET/djpD5FLURGDgJHVOkdXu1D6ku4= 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.