[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJuCfpEWc+eTLYp_Xf9exMJCO_cFtvBUzi39+WbcSKZBXHe3SQ@mail.gmail.com>
Date: Sat, 28 Aug 2021 14:47:46 -0700
From: Suren Baghdasaryan <surenb@...gle.com>
To: Kees Cook <keescook@...omium.org>
Cc: Matthew Wilcox <willy@...radead.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Colin Cross <ccross@...gle.com>,
Sumit Semwal <sumit.semwal@...aro.org>,
Michal Hocko <mhocko@...e.com>,
Dave Hansen <dave.hansen@...el.com>,
"Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
Vlastimil Babka <vbabka@...e.cz>,
Johannes Weiner <hannes@...xchg.org>,
Jonathan Corbet <corbet@....net>,
Al Viro <viro@...iv.linux.org.uk>,
Randy Dunlap <rdunlap@...radead.org>,
Kalesh Singh <kaleshsingh@...gle.com>,
Peter Xu <peterx@...hat.com>, rppt@...nel.org,
Peter Zijlstra <peterz@...radead.org>,
Catalin Marinas <catalin.marinas@....com>,
vincenzo.frascino@....com,
Chinwen Chang (張錦文)
<chinwen.chang@...iatek.com>,
Axel Rasmussen <axelrasmussen@...gle.com>,
Andrea Arcangeli <aarcange@...hat.com>,
Jann Horn <jannh@...gle.com>, apopple@...dia.com,
John Hubbard <jhubbard@...dia.com>,
Yu Zhao <yuzhao@...gle.com>, Will Deacon <will@...nel.org>,
fenghua.yu@...el.com, thunder.leizhen@...wei.com,
Hugh Dickins <hughd@...gle.com>, feng.tang@...el.com,
Jason Gunthorpe <jgg@...pe.ca>, Roman Gushchin <guro@...com>,
Thomas Gleixner <tglx@...utronix.de>, krisman@...labora.com,
chris.hyser@...cle.com, Peter Collingbourne <pcc@...gle.com>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Jens Axboe <axboe@...nel.dk>, legion@...nel.org, eb@...ix.com,
Muchun Song <songmuchun@...edance.com>,
Viresh Kumar <viresh.kumar@...aro.org>,
thomascedeno@...gle.com, sashal@...nel.org, cxfcosmos@...il.com,
linux@...musvillemoes.dk, LKML <linux-kernel@...r.kernel.org>,
linux-fsdevel@...r.kernel.org, linux-doc@...r.kernel.org,
linux-mm <linux-mm@...ck.org>,
kernel-team <kernel-team@...roid.com>
Subject: Re: [PATCH v8 2/3] mm: add a field to store names for private
anonymous memory
On Fri, Aug 27, 2021 at 10:52 PM Kees Cook <keescook@...omium.org> wrote:
>
> On Sat, Aug 28, 2021 at 02:47:03AM +0100, Matthew Wilcox wrote:
> > On Fri, Aug 27, 2021 at 12:18:57PM -0700, Suren Baghdasaryan wrote:
> > > + anon_name = vma_anon_name(vma);
> > > + if (anon_name) {
> > > + seq_pad(m, ' ');
> > > + seq_puts(m, "[anon:");
> > > + seq_write(m, anon_name, strlen(anon_name));
> > > + seq_putc(m, ']');
> > > + }
>
> Maybe after seq_pad, use: seq_printf(m, "[anon:%s]", anon_name);
Good idea. Will change.
>
> >
> > ...
> >
> > > + case PR_SET_VMA_ANON_NAME:
> > > + name = strndup_user((const char __user *)arg,
> > > + ANON_VMA_NAME_MAX_LEN);
> > > +
> > > + if (IS_ERR(name))
> > > + return PTR_ERR(name);
> > > +
> > > + for (pch = name; *pch != '\0'; pch++) {
> > > + if (!isprint(*pch)) {
> > > + kfree(name);
> > > + return -EINVAL;
> >
> > I think isprint() is too weak a check. For example, I would suggest
> > forbidding the following characters: ':', ']', '[', ' '. Perhaps
> > isalnum() would be better? (permit a-zA-Z0-9) I wouldn't necessarily
> > be opposed to some punctuation characters, but let's avoid creating
> > confusion. Do you happen to know which characters are actually in use
> > today?
>
> There's some sense in refusing [, ], and :, but removing " " seems
> unhelpful for reasonable descriptors. As long as weird stuff is escaped,
> I think it's fine. Any parser can just extract with m|\[anon:(.*)\]$|
I see no issue in forbidding '[' and ']' but whitespace and ':' are
currently used by Android. Would forbidding or escaping '[' and ']' be
enough?
>
> For example, just escape it here instead of refusing to take it. Something
> like:
>
> name = strndup_user((const char __user *)arg,
> ANON_VMA_NAME_MAX_LEN);
> escaped = kasprintf(GFP_KERNEL, "%pE", name);
Did you mean "%*pE" as in
https://www.kernel.org/doc/html/latest/core-api/printk-formats.html#raw-buffer-as-an-escaped-string
?
> if (escaped) {
> kfree(name);
> return -ENOMEM;
> }
> kfree(name);
> name = escaped;
>
> --
> Kees Cook
Powered by blists - more mailing lists