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=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no 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 E92AFC4320A for ; Tue, 31 Aug 2021 17:21:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 79AD6610E8 for ; Tue, 31 Aug 2021 17:21:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 79AD6610E8 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 E4608940007; Tue, 31 Aug 2021 13:21:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DF6258D0001; Tue, 31 Aug 2021 13:21:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9767940007; Tue, 31 Aug 2021 13:21:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0078.hostedemail.com [216.40.44.78]) by kanga.kvack.org (Postfix) with ESMTP id BC5278D0001 for ; Tue, 31 Aug 2021 13:21:51 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 4E0AC824999B for ; Tue, 31 Aug 2021 17:21:51 +0000 (UTC) X-FDA: 78536043222.09.634A5CE Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) by imf08.hostedemail.com (Postfix) with ESMTP id 1323430000A0 for ; Tue, 31 Aug 2021 17:21:50 +0000 (UTC) Received: by mail-yb1-f182.google.com with SMTP id k78so33348757ybf.10 for ; Tue, 31 Aug 2021 10:21:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WrEonas+JepcSOY1s7UkcRJkLLwq2Xbze1BTfCD2A34=; b=FUmATkIwZg5ZsdXIB4Beeo0WFBRLtX/xMW4hRtj8U9Wo67Z07U2YrBoqMyWD89anYc jsZEr/hMAxrvTFvMC8Z8Rep0v1FYAbDiZxWZvwtcd3E3rkJu/fEI9TdMwKHr1bbDR+uG HrstyAHrLttUKuChWSzh50+cnHbAvQTldLsIhAWnCQBRs8xuX9pTMDALn1e7AG1Tzrqv 9CTf/X/hTTE4PneuIB0GsckhUTCqGhd/28jqAa/6Z1Ghl1YlkghiTFTzQHBQ4qZadojQ QpfxNyuvbhGMfLmre6jfNGm/k46DQ96BSRhwvSufQ0V0iRfZBfjkohXmi+r4VNOa0Hou z5zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WrEonas+JepcSOY1s7UkcRJkLLwq2Xbze1BTfCD2A34=; b=l3eBEsbjq2ePr55pJB+wHs4ek/X2/k0xBaCox8ea4/ch3HiZXpgpZtk4a8le+D9etd vFSfFVQcT4g17qDxExcKqcy7mvcEUzFyDZ3tj7ualZ9op2M50lCxR2wIVpw08EZpQ04b W9Tc/rWGfAbzcY2gOT0Rx0mGRHGu54XaOeUT3Po6g5xq4SjvBxWJPx1x/v0+ZHBv1sGJ NCvZ4ix8uoN36mSJXvlmS/csEOSdJJSdgeimmBjzlCpuA5h8G9TM0WHnos3+LLURoWi7 KES4kKYuqEpy0NHVTyHjoyOfdoc4vdXQAO04I5l6VFwCmKKwf94KHjOYmdK1QbK8tc3J U4Ng== X-Gm-Message-State: AOAM530XYJ2e0ryrn165H2kyqb0iL+JqGuD9NB6Wh4Ft1W0aCBLSBpOt K7b0NBAo+NkFYllfLIVEBzfKk6RtL4SZQj0oIKPQYw== X-Google-Smtp-Source: ABdhPJyPBOY0YfeCm+axOI1GWL+mwhLsLVw2QaKm2MUud1FTTcYJfKTafsAGvTRvAVjyZR0pFmQLoHwTabaoQHWnias= X-Received: by 2002:a25:9ac6:: with SMTP id t6mr32228595ybo.190.1630430510051; Tue, 31 Aug 2021 10:21:50 -0700 (PDT) MIME-Version: 1.0 References: <20210827191858.2037087-1-surenb@google.com> <20210827191858.2037087-3-surenb@google.com> <202108272228.7D36F0373@keescook> In-Reply-To: From: Suren Baghdasaryan Date: Tue, 31 Aug 2021 10:21:38 -0700 Message-ID: Subject: Re: [PATCH v8 2/3] mm: add a field to store names for private anonymous memory To: Matthew Wilcox Cc: Rasmus Villemoes , Kees Cook , Andrew Morton , Colin Cross , Sumit Semwal , Michal Hocko , Dave Hansen , "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 , 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" Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=FUmATkIw; spf=pass (imf08.hostedemail.com: domain of surenb@google.com designates 209.85.219.182 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: hd7ch7yqpsp549jfffrfsrc3rdxck54i X-Rspamd-Queue-Id: 1323430000A0 X-Rspamd-Server: rspam04 X-HE-Tag: 1630430510-464124 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 Mon, Aug 30, 2021 at 9:59 AM Matthew Wilcox wrote: > > On Mon, Aug 30, 2021 at 09:16:14AM -0700, Suren Baghdasaryan wrote: > > On Mon, Aug 30, 2021 at 1:12 AM Rasmus Villemoes > > wrote: > > > > > > On 28/08/2021 23.47, Suren Baghdasaryan wrote: > > > > On Fri, Aug 27, 2021 at 10:52 PM Kees Cook wrote: > > > >> > > > >>>> + 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 > > > > > > Indeed. There's also the issue that the kernel's ctype actually > > > implements some almost-but-not-quite latin1, so (some) chars above 0x7f > > > would also pass isprint() - while everybody today expects utf-8, so the > > > ability to put almost arbitrary sequences of chars with the high bit set > > > could certainly confuse some parsers. IOW, don't use isprint() at all, > > > just explicitly check for the byte values that we and up agreeing to > > > allow/forbid. > > > > > > >>> 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? > > > > > > how about allowing [0x20, 0x7e] except [0x5b, 0x5d], i.e. all printable > > > (including space) ascii characters, except [ \ ] - the brackets as > > > already discussed, and backslash because then there's nobody who can get > > > confused about whether there's some (and then which?) escaping mechanism > > > in play - "\n" is simply never going to appear. Simple rules, easy to > > > implement, easy to explain in a man page. > > > > Thanks for the suggestion, Rasmus. I'm all for keeping it simple. > > Kees, Matthew, would that be acceptable? > > Yes, I think so. It permits all kinds of characters that might > be confusing if passed on to something else, but we can't prohibit > everything, and forbidding just these three should remove any confusion > for any parser of /proc. Little Bobby Tables thanks you. Thanks for all the feedback! I think I have enough change suggestions to resping the next revision. Will send an update later today.