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 X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D69AC433F5 for ; Fri, 3 Sep 2021 22:28:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AA0606101A for ; Fri, 3 Sep 2021 22:28:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AA0606101A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 2CC8F6B0071; Fri, 3 Sep 2021 18:28:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 255406B0072; Fri, 3 Sep 2021 18:28:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11CC66B0073; Fri, 3 Sep 2021 18:28:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0037.hostedemail.com [216.40.44.37]) by kanga.kvack.org (Postfix) with ESMTP id F2F506B0071 for ; Fri, 3 Sep 2021 18:28:25 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 72868180F8B86 for ; Fri, 3 Sep 2021 22:28:25 +0000 (UTC) X-FDA: 78547702170.19.DB3FBE7 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by imf25.hostedemail.com (Postfix) with ESMTP id 2D172B000183 for ; Fri, 3 Sep 2021 22:28:25 +0000 (UTC) Received: by mail-pl1-f182.google.com with SMTP id q3so378190plx.4 for ; Fri, 03 Sep 2021 15:28:25 -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=BS6jWoL9pWSi0KXjHeej6vjUIclKhlV3mGFNGSvhg5w=; b=lvAfLsLnn/50KH5BhXOVM8yk6EQsU+CWCcB3ajHc68JoJFkEsFipc+RHheUz83Bfbt t+8Fh+FZC2ScHzSuqtnikr4XATusXLxd9ZaDi4YqJjYk9Vp/H1MwSsOXtB154B9cS2u5 gd4PrW561dBLiOjrX3i69lbR51p3vC5CyFNis= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=BS6jWoL9pWSi0KXjHeej6vjUIclKhlV3mGFNGSvhg5w=; b=co3lxXKdSKv3mYwPndm5lxe7ZsZWEgRmm/x1CJzmPiTxRnVNAwjqPsIlOReTxkG9w+ zLQljF3JXw7WtlarQjm3u9/QVVxE6GbQhLS3EqMeCy3j1JD7Ac1nXd29ETpn3jHYqnTj oMOMmtDj9u4yD2oVY1qCJ4x/tHiVyiDDJGg9iW8QfbaCnfqzkAosDgVh8sUi+ZgTRFmn DjC1hv7iGcOhwF2oZWgvwU34r6fcBh5w7WVd7JTJY0i0AY/vOLyLT2FRun3rJ/cv8AGj U1L5FOoM6mW0wmuuz3VmcBiVX1/xMdQXv13hCiM9qI3Pny8oI9J046g4XeVdZCu5M+// KJRA== X-Gm-Message-State: AOAM530YLGMpcssCi052oUAy4R6F7Nvdos4II+ODchNvHoG8CUgecIpS aX1Fvsafu4sHjYKYq7x6SvkoRg== X-Google-Smtp-Source: ABdhPJzuaBI1DIl35wZKJ43uYtU+X5MQjRpDOgfLtB5e93HgeqaaD+mSm3mJj0NaFzUqMvKInh7J3Q== X-Received: by 2002:a17:90a:194a:: with SMTP id 10mr1071828pjh.221.1630708104224; Fri, 03 Sep 2021 15:28:24 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id j11sm359051pfa.10.2021.09.03.15.28.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 15:28:23 -0700 (PDT) Date: Fri, 3 Sep 2021 15:28:22 -0700 From: Kees Cook To: Suren Baghdasaryan Cc: Andrew Morton , Colin Cross , Sumit Semwal , Michal Hocko , 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, 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, Rasmus Villemoes , LKML , linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm , kernel-team Subject: Re: [PATCH v9 2/3] mm: add a field to store names for private anonymous memory Message-ID: <202109031522.ACDF5BA8@keescook> References: <20210902231813.3597709-1-surenb@google.com> <20210902231813.3597709-2-surenb@google.com> <202109031439.B58932AF0@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=lvAfLsLn; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf25.hostedemail.com: domain of keescook@chromium.org designates 209.85.214.182 as permitted sender) smtp.mailfrom=keescook@chromium.org X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 2D172B000183 X-Stat-Signature: 75jsm7ubfxt6id35qtfk36w9d8jdismo X-HE-Tag: 1630708105-172421 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, Sep 03, 2021 at 02:56:21PM -0700, Suren Baghdasaryan wrote: > On Fri, Sep 3, 2021 at 2:47 PM Kees Cook wrote: > > > > (Sorry, a few more things jumped out at me when I looked again...) > > > > On Thu, Sep 02, 2021 at 04:18:12PM -0700, Suren Baghdasaryan wrote: > > > [...] > > > diff --git a/kernel/sys.c b/kernel/sys.c > > > index 72c7639e3c98..25118902a376 100644 > > > --- a/kernel/sys.c > > > +++ b/kernel/sys.c > > > @@ -2299,6 +2299,64 @@ int __weak arch_prctl_spec_ctrl_set(struct task_struct *t, unsigned long which, > > > > > > #define PR_IO_FLUSHER (PF_MEMALLOC_NOIO | PF_LOCAL_THROTTLE) > > > > > > +#ifdef CONFIG_MMU > > > + > > > +#define ANON_VMA_NAME_MAX_LEN 256 > > > + > > > +static inline bool is_valid_name_char(char ch) > > > +{ > > > + /* printable ascii characters, except [ \ ] */ > > > + return (ch > 0x1f && ch < 0x5b) || (ch > 0x5d && ch < 0x7f); > > > +} > > > > In the back of my mind, I feel like disallowing backtick would be nice, > > but then if $, (, and ) are allowed, it doesn't matter, and that seems > > too limiting. :) > > It's not used by the only current user (Android) and we can always > allow more chars later. However going the other direction and > disallowing some of them I think would be harder (need to make sure > nobody uses them). WDYT if we keep it stricter and relax if needed? I'd say, if we can also drop each of: ` $ ( ) then let's do it. Better to keep the obvious shell meta-characters out of this, although I don't feel strongly about it. Anything that might get confused by this would be similarly confused by binary names too: $ cat /proc/3407216/maps 560bdafd4000-560bdafd6000 r--p 00000000 fd:02 2621909 /tmp/yay`wat And it's probably easier to change a binary name than to call prctl. :P I'm good either way. What you have now is great, but if we wanted to be extra extra strict, we can add the other 4 above. -- Kees Cook