Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp591480pxb; Fri, 3 Sep 2021 08:48:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBGK6ufwRXUNUxh2IePoMtxX1J6Fl+0ieklLS6UB0nGURhlW8S4QEAa3Q3MD9l2zI18tff X-Received: by 2002:a02:3b22:: with SMTP id c34mr3152105jaa.140.1630684132798; Fri, 03 Sep 2021 08:48:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630684132; cv=none; d=google.com; s=arc-20160816; b=N805bIAVF9VvS+0jZxdRO4he1GFQOTpIys+SH5wArGRWio+EObdaQXe8OjmlQV+/aX NnGyKvmzNmElRaRtvC6djf2tyX1yl5C8iTx9SLpaHUOege0WqyTf+/MF+ppOLdUiMeu0 VVRvJJPtgH3VRT8ElXaB859A9w72wZFVUXdyUa7R7A6+0atpXSE+Cuhn8RRy1ULAZPrR BF82ntASvJzRa9lesXGjV+Q8BTSsUwnV4v4DqUff1VqwHgM4BeFyrpTUxX3MOJ8HIKoI TJpHToIVGUCN6ekEjI5DZb8Su+wyv3bPIxIt+GmcHoe+u4QvWY+ETZkmwa+yJ4FAbZ0I U1JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=tcsX+WQqGl9KNNQFgUorP3/DXavYbjwi6W8uES8Z6Yc=; b=pwOK/SrHoMmIO7egzJDW1qLF6B2tPXeZ/XneyOszVqgj+NSHo2rjkVxWL2Hl1CzgZ5 F1Qu8IfZY9ChviVCqSUGkEPOwsyYy0RVPRW8Grah3VI+/7z3JfGeq7lyxPIq12berIrG ANwO7HPY2KLXtzo287gm/pojBpGiPMSljv16Logd8zEiN/vuEfpv2/Ffz256v6dkMoYS j2XuTuSe2HVTWYs5NdsXbw/Uj3yhbWVEb1XlMxUCU2eH7VuZHdR8RibsiAkPQf91+FdX zpTixjNx9/oxQukQsi6yhTja7V3OLqp+dbLrVa3ljBN4DrtVluGxu0mEJVGkXdjdfusS T0hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=fh3aCGTg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j2si5593161ilr.113.2021.09.03.08.48.38; Fri, 03 Sep 2021 08:48:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=fh3aCGTg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349725AbhICPsP (ORCPT + 99 others); Fri, 3 Sep 2021 11:48:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235573AbhICPsO (ORCPT ); Fri, 3 Sep 2021 11:48:14 -0400 Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BDB7C061575 for ; Fri, 3 Sep 2021 08:47:14 -0700 (PDT) Received: by mail-yb1-xb29.google.com with SMTP id q70so10834623ybg.11 for ; Fri, 03 Sep 2021 08:47:14 -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=Q0dZqhxlb626hyHTdgfcSaVukCvAV0J4rgev3wqAewF8kSkeRe97JgOSolxzsg2zz3 W3yI/c8uQ3soqTEHQ2O8P4ZSrUoTrk40QRWs7aVEPAIw8QWPSFH9NLQ0+6qnD+0A1xxp CvyyhMnd3xbWb8CT/zsS9+kgBiSo8nnq91XEvpsE6erYDikCM/weAanPHPf98Aik/FlM om+EGLgFC9JLKJAjpoOTP7mXrGKO1OCU0OPFdV5ebBYhZohV3hM86eaI+ZbJ6QHdMU+l 4F8jrF+dA+VnGpKru87QO3FtnZGhERz6kcqe7ix35X84xP5R/R3QCm9Sb3X+3TzApcOY p4nA== X-Gm-Message-State: AOAM530PBGT8cEUL4wkI4UXOP5fE8jfHD25aEXas4H4eFjDC2joFQXoV TWeHftysz3p6UOKvsYhWsxO1JMmTjISeqOnZpx2DrA== 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. >