Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1739859rwd; Tue, 13 Jun 2023 13:31:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7S6LCES/WYWfoSdkiMri+iFd/OrpzMS+cfxzX+ALLPKWIJegqrT2fxPGrP74Mp4KyoRrLs X-Received: by 2002:a17:907:70a:b0:974:20bd:6e15 with SMTP id xb10-20020a170907070a00b0097420bd6e15mr13251908ejb.4.1686688282671; Tue, 13 Jun 2023 13:31:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686688282; cv=none; d=google.com; s=arc-20160816; b=zxFYgJ8tu3ejwWIGlVLCcxJzwvveGgXR0tdyhH8+88wqhzHgmpmtalGRLme7bsH8up R7vv3Zh8flKLidoh75jGziDmpOhIahwSGp9JT0MRbBwiCT9agNrbPlUQ2SfrqGCWv3fP r2ZI19So2gPMbL9tRbWrSMc9NW4hEyZg3LSe3ult71gs9B+eI9HrDeC0vjOgi5DmnJxE CVVHRTxTWqT5FvqLUshRqsU6Y/sbZiu9CI+JJupcohBLYB/Oxu6VJfEj3dj9R1qXmTwk mwK4dSipDr2CdnyGD80AE9mh31QD9PNYlBBXlqxr3iYtUh2guZZiKtKXwVJ//cfxQJFj G6gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=6gY01Tx4BIc89rInz9irLDAvinQyYun0b+aEdVCR03A=; b=s9UQvxixa0MsdWcqWrpIFs94AxM0KII9C2naC8JNyVm/pY4vsafsTcJ/uHb+nDby6F jvMvPvmV6rCnQEfCU9xKLA7iShmNZdLw4xjMzDuQtgIyTbuMFO3pgutvAtdAX6wWWAob k7t70pPIuiW4R/efQsFBs+N3X6fWdUS/+ENu/J7hjWIrJfWdUR14QwrynlmgvgIa8KVZ 4UC5KxqBk/fQ3FeFsV/9NlPnOXU9PToN+HUBX2RoSAM1EB/f835zFqQ+7KgQd3Xwcoir /z37OAlBEIxUn4DoJLWkjN8g39XoYqPVJvzwTD+84oIAnZ5LPWPuwTrDsxNss2XRTjHc FKaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ONgYaSA6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u8-20020a17090657c800b00977da4a034bsi4125639ejr.59.2023.06.13.13.30.52; Tue, 13 Jun 2023 13:31:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ONgYaSA6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231941AbjFMURQ (ORCPT + 99 others); Tue, 13 Jun 2023 16:17:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232055AbjFMURJ (ORCPT ); Tue, 13 Jun 2023 16:17:09 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26281E6 for ; Tue, 13 Jun 2023 13:16:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686687388; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6gY01Tx4BIc89rInz9irLDAvinQyYun0b+aEdVCR03A=; b=ONgYaSA6lZ3FdyWgEDuOGQ82EKGFzPv1ESzzVuzwp7Gs7vvO7T6lfteQklsvo8CX6l/1Hl mW+gZuqqSE49rACX1G6uJM2LBHw34rh+79b0AWWxESicnvOYJRvWOf4C1yr+t3qpHldiUA v+xto4ShAsrcLJ65wZPVbcFwJqEBbhw= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-222-JvvnfbYRM1S6syPIu4-mNA-1; Tue, 13 Jun 2023 16:16:26 -0400 X-MC-Unique: JvvnfbYRM1S6syPIu4-mNA-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-7606a134623so42883885a.1 for ; Tue, 13 Jun 2023 13:16:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686687383; x=1689279383; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6gY01Tx4BIc89rInz9irLDAvinQyYun0b+aEdVCR03A=; b=JQY0ic5pfLhHzkFEcehqQLqO9NIMhQMs0KMQVIJp+gFf1mBhuua92RcSg27SD1gpvS omZ8aA102ZdaUzISRTYxvOuPo5vsO01+QWN2JNJStBuyFEUHgojHMNhIboXLkFVlopSM 2h4hSY3BktvyBfnS9ViL5zdRvLGZ1syl41dmOQrCdcc1LTUZFalqKd+pN3CuoRgCK8R/ vzxyjfVZ1OksR71x2oq4JCNu00QZgIv2noz8zznX3+gmfckYC/bdQYtqZJVPWYWL9LBj b87LWW30gMNUFkmJOUd+gaNxkjxU+1kYq4NEAP+Xp1QZkIZ7kPPsVVfe90SuzJOYkBKf kVHA== X-Gm-Message-State: AC+VfDwIsTrAiI0rcW0DWbqaeT7X759B//WxMOKQYBAqqmhsFAUktJUq vQSKtw8aL+V6lZXSr7ZpXc4YpgGNmSycN2bLmqgE7LtuoT2FM7p7ClLcU/4Sqx0b7tD7XZeLh/W XebfassR4TN86yvew+XkngaRt X-Received: by 2002:a05:620a:d96:b0:75e:da20:a10e with SMTP id q22-20020a05620a0d9600b0075eda20a10emr14985496qkl.3.1686687383548; Tue, 13 Jun 2023 13:16:23 -0700 (PDT) X-Received: by 2002:a05:620a:d96:b0:75e:da20:a10e with SMTP id q22-20020a05620a0d9600b0075eda20a10emr14985483qkl.3.1686687383204; Tue, 13 Jun 2023 13:16:23 -0700 (PDT) Received: from x1n (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id c2-20020a05620a164200b00759322a6089sm3843860qko.14.2023.06.13.13.16.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 13:16:22 -0700 (PDT) Date: Tue, 13 Jun 2023 16:16:21 -0400 From: Peter Xu To: Jeff Xu Cc: linux-mm@kvack.org, linux-hardening@vger.kernel.org, Liam.Howlett@oracle.com, zhangpeng.00@bytedance.com, akpm@linux-foundation.org, koct9i@gmail.com, david@redhat.com, ak@linux.intel.com, hughd@google.com, emunson@akamai.com, rppt@linux.ibm.com, aarcange@redhat.com, linux-kernel@vger.kernel.org, Lorenzo Stoakes Subject: Re: inconsistence in mprotect_fixup mlock_fixup madvise_update_vma Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Hi, Jeff, On Tue, Jun 13, 2023 at 08:26:26AM -0700, Jeff Xu wrote: > + more ppl to the list. > > On Mon, Jun 12, 2023 at 6:04 PM Jeff Xu wrote: > > > > Hello, > > > > There seems to be inconsistency in different VMA fixup > > implementations, for example: > > mlock_fixup will skip VMA that is hugettlb, etc, but those checks do > > not exist in mprotect_fixup and madvise_update_vma. Wouldn't this be a > > problem? the merge/split skipped by mlock_fixup, might get acted on in > > the madvice/mprotect case. > > > > mlock_fixup currently check for > > if (newflags == oldflags || (oldflags & VM_SPECIAL) || > > is_vm_hugetlb_page(vma) || vma == get_gate_vma(current->mm) || > > vma_is_dax(vma) || vma_is_secretmem(vma)) The special handling you mentioned in mlock_fixup mostly makes sense to me. E.g., I think we can just ignore mlock a hugetlb page if it won't be swapped anyway. Do you encounter any issue with above? > > Should there be a common function to handle VMA merge/split ? IMHO vma_merge() and split_vma() are the "common functions". Copy Lorenzo as I think he has plan to look into the interface to make it even easier to use. -- Peter Xu