Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp785612pxb; Thu, 17 Feb 2022 14:55:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJyHTd+dveOP5ippv+D/sXxUg4bvrUuOkv1AbcQiX/dTQUxWwQ2+jKBUUkNSrceLUSTmH/qi X-Received: by 2002:a17:90a:9408:b0:1b5:3908:d3d1 with SMTP id r8-20020a17090a940800b001b53908d3d1mr5322336pjo.188.1645138519227; Thu, 17 Feb 2022 14:55:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645138519; cv=none; d=google.com; s=arc-20160816; b=pEiFqSXJB43sIF1rdk5+Wc4ho1iHvYEZ9cOZvtGNI6URri9tgrWaecQK5UyxLIhvBm LOIegmk5D2PRcTDNJTIWbMJRoSGCfX02MJAHC+Oze4gmWRqSJWswu2jL/1DR4gSvQv9m qxpE2ZXjq0u+uZnODJblxQluB5iTuJIuzGt9UqQ9Z6k7DzKF4Tg7630RhYB+AjYzDWl1 4tEXRQx2OGXiBuPJukqM2bQpnqgC620hxVUB7hRA4tVg6nuly3AUpTWRE0qLqSsntIeQ N/79Grbt9ZDHMyxaWPPVyNNPFKQKr59fQ5rP/NgoxExAIcHdSaloKHcktQRVKbjpctsV 5+Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=HEbMA+fF1TLeOfjjMyurlHpRnZiIoUteWbhZjOk9//o=; b=W0QT5A1ukrGic4st6pDJdBy14+DN/gDaTwDRvSZrNfWiUGTHZ8TmXt53StE0SXUVcD /yRxHMXb47mknrw8E29Mvx0/P8XKzRZPipOxQYdeKNcG3XDsbiqAEjc7mGbzwlbK/cMD ClfFmODSNM7hXVrHwsZmykiiOTq9B5mZtER/mgfBUZu1Xewn82Pt6gM44oRi0sqBF75E zUhIfYNk7AxCov5nLVRvya3BubS69Okk7AuweVBcEiGkL0vEqOyQ5xmjyyXz5X1aZjsQ K6rHBE/pW1Hh4pcGm0PZuQo8t6YG55qt+C8bN33sXKCSGh3n5bULu+E/WqDhSQOcuGJ8 m6cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=F7D2plqB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n14si24679076plf.136.2022.02.17.14.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 14:55:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=F7D2plqB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D0C2F265112; Thu, 17 Feb 2022 14:54:44 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240582AbiBQM5n (ORCPT + 99 others); Thu, 17 Feb 2022 07:57:43 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230462AbiBQM5k (ORCPT ); Thu, 17 Feb 2022 07:57:40 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C48C1C1ED8; Thu, 17 Feb 2022 04:57:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645102646; x=1676638646; h=date:from:to:cc:subject:message-id:reply-to:references: mime-version:in-reply-to; bh=muUyZFkT/XUwYXtZ4KuQ8w3WazrYqWNDm8XTjig5hYY=; b=F7D2plqBiebEWhtvkoEXTBnA3L6AYMfMXFNOK5/owrT7D0+8/8WarGyo thv5scP73eVRxho+FXBa+xcJZVkPPjfiumPk3YsuFbywYnKuGUAOMPEAH SqXGGd2tGSTHlUtRAufUMdwLpZjs39ocTCYhE/wlZUi1nyWrVQ45KccoH 2XLydaH5uvVa3bqqQMUD8fVgRnfkc/z0kwuY91RN/WBYFvhtL9jfqX/t6 w7OlcYSIlv5SJuJ+FVUnaGjwR4oGFYfPg0+0eAC4flZ9oztza57RXzA2Q +2Gx4b+2tW34XOvQfl5tESnm6Z7s30EtLnEGzbtKV/vV3Lq6zfYwr4yNT g==; X-IronPort-AV: E=McAfee;i="6200,9189,10260"; a="251064855" X-IronPort-AV: E=Sophos;i="5.88,375,1635231600"; d="scan'208";a="251064855" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 04:57:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,375,1635231600"; d="scan'208";a="704785987" Received: from chaop.bj.intel.com (HELO localhost) ([10.240.192.101]) by orsmga005.jf.intel.com with ESMTP; 17 Feb 2022 04:57:18 -0800 Date: Thu, 17 Feb 2022 20:56:57 +0800 From: Chao Peng To: Vlastimil Babka Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, qemu-devel@nongnu.org, Paolo Bonzini , Jonathan Corbet , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Yu Zhang , "Kirill A . Shutemov" , luto@kernel.org, jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com, david@redhat.com Subject: Re: [PATCH v4 01/12] mm/shmem: Introduce F_SEAL_INACCESSIBLE Message-ID: <20220217125656.GA32679@chaop.bj.intel.com> Reply-To: Chao Peng References: <20220118132121.31388-1-chao.p.peng@linux.intel.com> <20220118132121.31388-2-chao.p.peng@linux.intel.com> <64407833-1387-0c46-c569-8b6a3db8e88c@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <64407833-1387-0c46-c569-8b6a3db8e88c@suse.cz> User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 07, 2022 at 01:24:42PM +0100, Vlastimil Babka wrote: > On 1/18/22 14:21, Chao Peng wrote: > > From: "Kirill A. Shutemov" > > > > /* > > diff --git a/mm/shmem.c b/mm/shmem.c > > index 18f93c2d68f1..72185630e7c4 100644 > > --- a/mm/shmem.c > > +++ b/mm/shmem.c > > @@ -1098,6 +1098,13 @@ static int shmem_setattr(struct user_namespace *mnt_userns, > > (newsize > oldsize && (info->seals & F_SEAL_GROW))) > > return -EPERM; > > > > + if (info->seals & F_SEAL_INACCESSIBLE) { > > + if(i_size_read(inode)) > > Is this needed? The rest of the function seems to trust oldsize obtained by > plain reading inode->i_size well enough, so why be suddenly paranoid here? oldsize sounds enough here, unless kirill has different mind. > > > + return -EPERM; > > + if (newsize & ~PAGE_MASK) > > + return -EINVAL; > > + } > > + > > if (newsize != oldsize) { > > error = shmem_reacct_size(SHMEM_I(inode)->flags, > > + if ((info->seals & F_SEAL_INACCESSIBLE) && > > + (offset & ~PAGE_MASK || len & ~PAGE_MASK)) { > > Could we use PAGE_ALIGNED()? Yes, definitely, thanks. Chao > > > + error = -EINVAL; > > + goto out; > > + } > > + > > shmem_falloc.waitq = &shmem_falloc_waitq; > > shmem_falloc.start = (u64)unmap_start >> PAGE_SHIFT; > > shmem_falloc.next = (unmap_end + 1) >> PAGE_SHIFT;