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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44E1FC433EF for ; Wed, 13 Apr 2022 16:25:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236864AbiDMQ1z (ORCPT ); Wed, 13 Apr 2022 12:27:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236865AbiDMQ10 (ORCPT ); Wed, 13 Apr 2022 12:27:26 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4C0984A931 for ; Wed, 13 Apr 2022 09:25:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649867101; 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=RgEcoM6U2AWPf465Xahivshzo2kZbOX7C4c0ahKp1Dw=; b=Eplmut0vF4DlV6c+zkqOtHlqzpvGJ3v8k5+lbRl4yV4OIA9iFxRyXwgYXzb6KlsVO9QzW3 nl7HxNwJgX3oOvsp23Un2bK8WEuOBeDieMudWOsbppTnuMOa3/mJXAO8o3AjJSCeWGDNZi qjYkdrvIe6mRigEbiz/xC4dFVOxgsL0= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-307-Etneel-TNCu0P8BCgL-ZbA-1; Wed, 13 Apr 2022 12:25:00 -0400 X-MC-Unique: Etneel-TNCu0P8BCgL-ZbA-1 Received: by mail-wm1-f71.google.com with SMTP id n37-20020a05600c502500b0038fdc1394c6so459356wmr.6 for ; Wed, 13 Apr 2022 09:24:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=RgEcoM6U2AWPf465Xahivshzo2kZbOX7C4c0ahKp1Dw=; b=t5O09WNr3hts5uznGdCvfE2fJ1jFfGwEk34NTu0Rt0yXPNgx3UzwhVLgMAFQYdd5cO QULybZ12fsjIy7Yv1NMibNxcYmre5SB7ZDciKnmh72xy4jDN14Rz7FrsugGciTvNLNs5 ylU42MKAzZ1HhQBZgU2BCqXtRXNTqK8ZfuRuwAR2uUSTJU5Y0EcPoOKubj/ind+rNBT3 mqfppSy6CcL2ByOvXKkAYCfewUYZIth/ZPFHTsZ2LsfTrOMAd53y/wuGcYXhVmWI1ZBC 74L4yxL9YTfFLOE16l586vb5DVQbDHNjgYzXbsapY8bLQBLQvYVDEp8zevZ3XDWg5Dxe VN6Q== X-Gm-Message-State: AOAM533ynyqJFM707tCm0CO8OODyUw08Badn1oQakvL2L7WJctfFJeGZ 17mZPi8UlvgdS20nJDpjZWM0dkKLD1eeg5ZS+KS321YPHOcdJL0Da19K2IRw55KT+rxZ+WCuHof pES8ye7YNRZL2Pho6YfkNaURP X-Received: by 2002:a05:600c:3c8f:b0:38e:4e47:3e95 with SMTP id bg15-20020a05600c3c8f00b0038e4e473e95mr9076127wmb.173.1649867098870; Wed, 13 Apr 2022 09:24:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwylTIzzqJtz5EFX+MPmIPe9ZuRAk8yMJ3/juBgt0JzCyKFOBhzlfQN6ejdx28PKvB0mUKO0g== X-Received: by 2002:a05:600c:3c8f:b0:38e:4e47:3e95 with SMTP id bg15-20020a05600c3c8f00b0038e4e473e95mr9076112wmb.173.1649867098647; Wed, 13 Apr 2022 09:24:58 -0700 (PDT) Received: from ?IPV6:2003:cb:c704:5800:1078:ebb9:e2c3:ea8c? (p200300cbc70458001078ebb9e2c3ea8c.dip0.t-ipconnect.de. [2003:cb:c704:5800:1078:ebb9:e2c3:ea8c]) by smtp.gmail.com with ESMTPSA id n7-20020a5d5987000000b00207891050d4sm16274621wri.46.2022.04.13.09.24.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Apr 2022 09:24:58 -0700 (PDT) Message-ID: <1686fd2d-d9c3-ec12-32df-8c4c5ae26b08@redhat.com> Date: Wed, 13 Apr 2022 18:24:56 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Subject: Re: [PATCH v5 04/13] mm/shmem: Restrict MFD_INACCESSIBLE memory against RLIMIT_MEMLOCK Content-Language: en-US To: Jason Gunthorpe Cc: Sean Christopherson , Andy Lutomirski , Chao Peng , kvm list , Linux Kernel Mailing List , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Linux API , qemu-devel@nongnu.org, Paolo Bonzini , Jonathan Corbet , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , the arch/x86 maintainers , "H. Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , "Kirill A. Shutemov" , "Nakajima, Jun" , Dave Hansen , Andi Kleen References: <20220310140911.50924-1-chao.p.peng@linux.intel.com> <20220310140911.50924-5-chao.p.peng@linux.intel.com> <02e18c90-196e-409e-b2ac-822aceea8891@www.fastmail.com> <7ab689e7-e04d-5693-f899-d2d785b09892@redhat.com> <20220412143636.GG64706@ziepe.ca> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20220412143636.GG64706@ziepe.ca> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12.04.22 16:36, Jason Gunthorpe wrote: > On Fri, Apr 08, 2022 at 08:54:02PM +0200, David Hildenbrand wrote: > >> RLIMIT_MEMLOCK was the obvious candidate, but as we discovered int he >> past already with secretmem, it's not 100% that good of a fit (unmovable >> is worth than mlocked). But it gets the job done for now at least. > > No, it doesn't. There are too many different interpretations how > MELOCK is supposed to work > > eg VFIO accounts per-process so hostile users can just fork to go past > it. > > RDMA is per-process but uses a different counter, so you can double up > > iouring is per-user and users a 3rd counter, so it can triple up on > the above two Thanks for that summary, very helpful. > >> So I'm open for alternative to limit the amount of unmovable memory we >> might allocate for user space, and then we could convert seretmem as well. > > I think it has to be cgroup based considering where we are now :\ Most probably. I think the important lessons we learned are that * mlocked != unmovable. * RLIMIT_MEMLOCK should most probably never have been abused for unmovable memory (especially, long-term pinning) -- Thanks, David / dhildenb