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.2 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,URIBL_BLOCKED,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 29B24C433F5 for ; Fri, 3 Sep 2021 15:47:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AD9F46108E for ; Fri, 3 Sep 2021 15:47:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AD9F46108E 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 D3DE0940007; Fri, 3 Sep 2021 11:47:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CED08900002; Fri, 3 Sep 2021 11:47:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB4C6940007; Fri, 3 Sep 2021 11:47:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0244.hostedemail.com [216.40.44.244]) by kanga.kvack.org (Postfix) with ESMTP id ABEC6900002 for ; Fri, 3 Sep 2021 11:47:14 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 4AF6E82D4320 for ; Fri, 3 Sep 2021 15:47:14 +0000 (UTC) X-FDA: 78546691188.23.49B8A7C Received: from mail-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) by imf24.hostedemail.com (Postfix) with ESMTP id 09753B00009D for ; Fri, 3 Sep 2021 15:47:13 +0000 (UTC) Received: by mail-yb1-f175.google.com with SMTP id j195so2880525ybg.6 for ; Fri, 03 Sep 2021 08:47:13 -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=tcsX+WQqGl9KNNQFgUorP3/DXavYbjwi6W8uES8Z6Yc=; b=fh3aCGTgSa8/XdbS5LEG5NIXkO3KXwLBGTSz3uzN6DPy42JLMT4eRa3oKUdPc1rnha +nrhtZj/7HLMwfltItRvqCqdA794UMNpaDTxEO50v/5edYG7PwLIRBRwhr5J+BLcS4kU UCeQ1dBsEccaEsfiMltxByci6qP5et9koKMQiM/1pfqTiKclOuQpqI3on8ky+c+7a/zf kNcP0c1uCMmrMEvKq6F/tWFNGfJeXJvQ/vBVNmYOvMCyPZJAlhMMtnGtlUrjvYmDCQQK AQqoGGH3yY6kgyqApN2Odyj38lK1WckbyLOE1mY8Vqrk4TxhiA9CDIHKbg0SIdJ5bhgm o4bw== 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=tcsX+WQqGl9KNNQFgUorP3/DXavYbjwi6W8uES8Z6Yc=; b=bx9tmPoK/b52bj9IUAT5q5N1S1ENsx7p8+nHeld2xx6zbTGtsKJTuxb6YrLlaMi+Tj 1dG8GM+dSUzg4GLG41QZocdB1PkQecaJzB5wmOrluLyqAIcpb23Np1VqGh0kihx7iYFu TjaMi43KMdOgUlO3IZO7etrHdNL+7FinB8Grc64eKjg4WyiIEfmzy40BiDbjcVOOn7wT z+D13ShcqGpSXiNj+wA9RCIhpkidCPGAb9MAd8Q0D4lQp5EHSd4RouQRzm12wIxQv/yG vAGhSFFsZsvjyPuUPiZ72yJIxTS9XI4ALvbsN9wRmV934YG+v8Y1Rg7raVsVOIMbWst8 hkKg== X-Gm-Message-State: AOAM530OUeBHcfYBF1dRefdyHit5sJ/5Br5Mgg91HY2hQNepJUl5/Ib4 baNAqt6KbX3UZWXxv1fYxVfrYP4r9PClQFBgdOgMOg== X-Google-Smtp-Source: ABdhPJxTLm1wDIXmjlPSCgNPzJsS++bAZ0JdreBU5JSJan5+c2yQQY68ByO+9PDYJ8gHLxXb0SfoaueztDJCOwWAt/0= X-Received: by 2002:a25:b9c8:: with SMTP id y8mr5789752ybj.487.1630684032948; Fri, 03 Sep 2021 08:47:12 -0700 (PDT) MIME-Version: 1.0 References: <20210827191858.2037087-1-surenb@google.com> <20210827191858.2037087-3-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Fri, 3 Sep 2021 08:47:01 -0700 Message-ID: Subject: Re: [PATCH v8 2/3] mm: add a field to store names for private anonymous memory To: Michal Hocko Cc: Andrew Morton , Colin Cross , Sumit Semwal , 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 , 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-Queue-Id: 09753B00009D Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=fh3aCGTg; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of surenb@google.com designates 209.85.219.175 as permitted sender) smtp.mailfrom=surenb@google.com X-Rspamd-Server: rspam01 X-Stat-Signature: ji19jmisd3q87do6ur3baxk46bu7gffi X-HE-Tag: 1630684033-270456 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 4:49 AM 'Michal Hocko' via kernel-team wrote: > > On Wed 01-09-21 08:42:29, Suren Baghdasaryan wrote: > > On Wed, Sep 1, 2021 at 1:10 AM 'Michal Hocko' via kernel-team > > wrote: > > > > > > On Fri 27-08-21 12:18:57, Suren Baghdasaryan wrote: > > > [...] > > > > +static void replace_vma_anon_name(struct vm_area_struct *vma, const char *name) > > > > +{ > > > > + if (!name) { > > > > + free_vma_anon_name(vma); > > > > + return; > > > > + } > > > > + > > > > + if (vma->anon_name) { > > > > + /* Should never happen, to dup use dup_vma_anon_name() */ > > > > + WARN_ON(vma->anon_name == name); > > > > > > What is the point of this warning? > > > > I wanted to make sure replace_vma_anon_name() is not used from inside > > vm_area_dup() or some similar place (does not exist today but maybe in > > the future) where "new" vma is a copy of "orig" vma and > > new->anon_name==orig->anon_name. If someone by mistake calls > > replace_vma_anon_name(new, orig->anon_name) and > > new->anon_name==orig->anon_name then they will keep pointing to the > > same name pointer, which breaks an assumption that ->anon_name > > pointers are not shared among vmas even if the string is the same. > > That would eventually lead to use-after-free error. After the next > > patch implementing refcounting, the similar situation would lead to > > both new and orig vma pointing to the same anon_vma_name structure > > without raising the refcount, which would also lead to use-after-free > > error. That's why the above comment asks to use dup_vma_anon_name() if > > this warning ever happens. > > I can remove the warning but I thought the problem is subtle enough to > > put some safeguards. > > This to me sounds very much like a debugging code that shouldn't make it > to the final patch to be merged. I do see your point of an early > diagnostic but we are talking about an internal MM code and that is not > really designed to be robust against its own failures so I do not see > why this should be any special. Fair enough. I posted v9 yesterday but will respin another version in a couple days. Will remove the warning then. Thanks, Suren. > -- > Michal Hocko > SUSE Labs > > -- > To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com. >