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 EF3E8C433FE for ; Fri, 1 Oct 2021 03:44:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 68ADE613A7 for ; Fri, 1 Oct 2021 03:44:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 68ADE613A7 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 6A2EE9400F1; Thu, 30 Sep 2021 23:44:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6782E9400E4; Thu, 30 Sep 2021 23:44:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5401B9400F1; Thu, 30 Sep 2021 23:44:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0190.hostedemail.com [216.40.44.190]) by kanga.kvack.org (Postfix) with ESMTP id 42AD69400E4 for ; Thu, 30 Sep 2021 23:44:38 -0400 (EDT) Received: from smtpin40.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id EB0EF3CC67 for ; Fri, 1 Oct 2021 03:44:37 +0000 (UTC) X-FDA: 78646476594.40.C69F97A Received: from mail-yb1-f170.google.com (mail-yb1-f170.google.com [209.85.219.170]) by imf13.hostedemail.com (Postfix) with ESMTP id 95BBB103673E for ; Fri, 1 Oct 2021 03:44:37 +0000 (UTC) Received: by mail-yb1-f170.google.com with SMTP id s64so14657116yba.11 for ; Thu, 30 Sep 2021 20:44:37 -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=nUyg5XpqEcjYRAILgiFJJzvxtqym2vAvVPMoISCLLDM=; b=WSQqQNNaNU6sKZN/vcVig76MwzWnqgyH3Y4g0q3bhSkAt+RLn8RiLo9wYfPmdxHEwj Ng8YvHClCtVSVSAlLJD7bFcHsn+Mw6Qh5uOBvYc84llJZCKuAdCRumGL9aV7ROzSVNoX zirkUMQUH0UsWfjfwIIuFEvQ5VJvlPVKeUYG791Ing+efx25wLB+Id73SD2iHg2OvmTz Du7tMGJLrwlhyzbwCZxrUiHX+uGM3N+Uq+mX6x8CcaSZaSQ/9ckaZzVNWy7/m5xwlPfO Ji+FZCzzvSsOgww9JvFT2qwCaP3NlgC1vAVpZ1vnahhCM7JpRWh6MSStXgxBI+Rfb4u7 /awA== 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=nUyg5XpqEcjYRAILgiFJJzvxtqym2vAvVPMoISCLLDM=; b=OuvKVo/Dk4RiUY7IvBa7LXM2knrjVlCsaR4eitHBrWmKACNTBLDFnuky3Trv0erv/z oMWh5BWoPJYt++JqeHM7EYkKqdUWYvdhNYx0cTNDrD5I/lTVj7KxevA9JSsCxqFg8XdC 5dtYNC0+mVUmO0WqoLh3B7yPv0lvUaLcCZtnY1tEyrsbnAfnFRMtdHc/vdY3pqx/XgHM k4yCCrZrHKFSEhzawMdCYMxGOfnb8GrtcYNj9DV9esdNH3vhNzvQTZJUTM9eWixBKYzD 6SdRgdTU/VU2chUVeVkT6x6fVC4wYeioV7cwHZt+dSElq00nXMbJGRavRdmH/hvuFpxZ xvgQ== X-Gm-Message-State: AOAM532eZNvjEdkjsHUDT7psf5xJtDOmKVX3DBaKveUiVla+b35cpdqH fHvxVyHcRKUuV0E5v1bFheByrvDMqkRQW6nG1uwoyg== X-Google-Smtp-Source: ABdhPJwc5YLWIpcCTp3KGzbsilLzZduRPuL3k5mA3LZsQk/Ms1ALPyxgKMWk6t/kOh+hE/j2nM/pGCogCW7YMRK3JKs= X-Received: by 2002:a25:8411:: with SMTP id u17mr3282073ybk.376.1633059876528; Thu, 30 Sep 2021 20:44:36 -0700 (PDT) MIME-Version: 1.0 References: <20210902231813.3597709-1-surenb@google.com> <20210902231813.3597709-2-surenb@google.com> <202109031439.B58932AF0@keescook> <202109031522.ACDF5BA8@keescook> In-Reply-To: <202109031522.ACDF5BA8@keescook> From: Suren Baghdasaryan Date: Thu, 30 Sep 2021 20:44:25 -0700 Message-ID: Subject: Re: [PATCH v9 2/3] mm: add a field to store names for private anonymous memory To: Kees Cook 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, =?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, Rasmus Villemoes , LKML , linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm , kernel-team Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 95BBB103673E X-Stat-Signature: dticywxyfm5ptqq1zyh9urffikahq6hh Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=WSQqQNNa; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf13.hostedemail.com: domain of surenb@google.com designates 209.85.219.170 as permitted sender) smtp.mailfrom=surenb@google.com X-HE-Tag: 1633059877-126577 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 3, 2021 at 3:28 PM Kees Cook wrote: > > 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. While testing v10 I found one case when () are used in the name "dalvik-main space (region space)". So I can add ` and $ to the restricted set but not ( and ). Kees, would you be happy with: static inline bool is_valid_name_char(char ch) { return ch > 0x1f && ch < 0x7f && !strchr("\\`$[]", ch); } ? > > -- > Kees Cook