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=-0.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 83D90C38A2A for ; Fri, 8 May 2020 23:53:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4168F20820 for ; Fri, 8 May 2020 23:53:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="NlxsLycU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4168F20820 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CEEF8900025; Fri, 8 May 2020 19:53:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C9FC090001C; Fri, 8 May 2020 19:53:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDC69900025; Fri, 8 May 2020 19:53:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0150.hostedemail.com [216.40.44.150]) by kanga.kvack.org (Postfix) with ESMTP id A6C5F90001C for ; Fri, 8 May 2020 19:53:08 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 68F5F4DB8 for ; Fri, 8 May 2020 23:53:08 +0000 (UTC) X-FDA: 76795205256.10.horn28_8fc927b395427 X-HE-Tag: horn28_8fc927b395427 X-Filterd-Recvd-Size: 4097 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Fri, 8 May 2020 23:53:07 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C36D12063A; Fri, 8 May 2020 23:53:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588981987; bh=HhHKaurLAmb7NjsgrxbGjxSSVFmDRRfuuN9UCDjB39o=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NlxsLycULu/0pDE5VncKMqsY68TvDzrBX4Z64itAzdFVs23jjGQe08PfomP/NtWT8 t+PlAdQE7wuMV/9rpzTnihUcJMRtJqlsdArVibUT/u4A0ZhILXtPYgryyu3m8JvFgO cvEh5TrYedonuRC3JSEcG71eqRoSLBbbgIM2fD/M= Date: Fri, 8 May 2020 16:53:06 -0700 From: Andrew Morton To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-nvdimm@lists.01.org, kexec@lists.infradead.org, Vishal Verma , Dave Jiang , Pavel Tatashin , stable@vger.kernel.org, Dan Williams Subject: Re: [PATCH v4 1/4] device-dax: Don't leak kernel memory to user space after unloading kmem Message-Id: <20200508165306.7cd806f7e451c5c9bc2a40ac@linux-foundation.org> In-Reply-To: <20200508084217.9160-2-david@redhat.com> References: <20200508084217.9160-1-david@redhat.com> <20200508084217.9160-2-david@redhat.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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, 8 May 2020 10:42:14 +0200 David Hildenbrand w= rote: > Assume we have kmem configured and loaded: > [root@localhost ~]# cat /proc/iomem > ... > 140000000-33fffffff : Persistent Memory$ > 140000000-1481fffff : namespace0.0 > 150000000-33fffffff : dax0.0 > 150000000-33fffffff : System RAM >=20 > Assume we try to unload kmem. This force-unloading will work, even if > memory cannot get removed from the system. > [root@localhost ~]# rmmod kmem > [ 86.380228] removing memory fails, because memory [0x0000000150000= 000-0x0000000157ffffff] is onlined > ... > [ 86.431225] kmem dax0.0: DAX region [mem 0x150000000-0x33fffffff] = cannot be hotremoved until the next reboot >=20 > Now, we can reconfigure the namespace: > [root@localhost ~]# ndctl create-namespace --force --reconfig=3Dnames= pace0.0 --mode=3Ddevdax > [ 131.409351] nd_pmem namespace0.0: could not reserve region [mem 0x= 140000000-0x33fffffff]dax > [ 131.410147] nd_pmem: probe of namespace0.0 failed with error -16na= mespace0.0 --mode=3Ddevdax > ... >=20 > This fails as expected due to the busy memory resource, and the memory > cannot be used. However, the dax0.0 device is removed, and along its na= me. >=20 > The name of the memory resource now points at freed memory (name of the > device). > [root@localhost ~]# cat /proc/iomem > ... > 140000000-33fffffff : Persistent Memory > 140000000-1481fffff : namespace0.0 > 150000000-33fffffff : =EF=BF=BD_=EF=BF=BD^7_=EF=BF=BD=EF=BF=BD/_=EF= =BF=BD=EF=BF=BDwR=EF=BF=BD=EF=BF=BDWQ=EF=BF=BD=EF=BF=BD=EF=BF=BD^=EF=BF=BD= =EF=BF=BD=EF=BF=BD ... > 150000000-33fffffff : System RAM >=20 > We have to make sure to duplicate the string. While at it, remove the > superfluous setting of the name and fixup a stale comment. >=20 > Fixes: 9f960da72b25 ("device-dax: "Hotremove" persistent memory that is= used like normal RAM") > Cc: stable@vger.kernel.org # v5.3 hm. Is this really -stable material? These are all privileged operations, I expect? Assuming "yes", I've queued this separately, staged for 5.7-rcX. I'll redo patches 2-4 as a three-patch series for 5.8-rc1. > Cc: Dan Williams > Cc: Vishal Verma > Cc: Dave Jiang > Cc: Pavel Tatashin Reviewers, please ;)