From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752005AbdHCMWQ (ORCPT ); Thu, 3 Aug 2017 08:22:16 -0400 Received: from lhrrgout.huawei.com ([194.213.3.17]:32605 "EHLO lhrrgout.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751895AbdHCMWO (ORCPT ); Thu, 3 Aug 2017 08:22:14 -0400 Subject: Re: [RFC] Tagging of vmalloc pages for supporting the pmalloc allocator To: Michal Hocko CC: Jerome Glisse , Linux-MM , LKML , , "kernel-hardening@lists.openwall.com" , Kees Cook References: <07063abd-2f5d-20d9-a182-8ae9ead26c3c@huawei.com> <20170802170848.GA3240@redhat.com> <8e82639c-40db-02ce-096a-d114b0436d3c@huawei.com> <20170803114844.GO12521@dhcp22.suse.cz> From: Igor Stoppa Message-ID: Date: Thu, 3 Aug 2017 15:20:31 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170803114844.GO12521@dhcp22.suse.cz> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.122.225.51] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090203.5983155E.00DA,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 3db2c30f7e2b879293415014fb85a590 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/08/17 14:48, Michal Hocko wrote: > On Thu 03-08-17 13:11:45, Igor Stoppa wrote: >> On 02/08/17 20:08, Jerome Glisse wrote: >>> On Wed, Aug 02, 2017 at 06:14:28PM +0300, Igor Stoppa wrote: [...] >>>> from include/linux/mm_types.h: >>>> >>>> struct page { >>>> ... >>>> union { >>>> unsigned long private; /* Mapping-private opaque data: >>>> * usually used for buffer_heads >>>> * if PagePrivate set; used for >>>> * swp_entry_t if PageSwapCache; >>>> * indicates order in the buddy >>>> * system if PG_buddy is set. >>>> */ [...] >> If the "Mapping-private" was dropped or somehow connected exclusively to >> the cases listed in the comment, then I think it would be more clear >> that the comment needs to be intended as related to mapping in certain >> cases only. >> But it is otherwise ok to use the "private" field for whatever purpose >> it might be suitable, as long as it is not already in use. > > I would recommend adding a new field into the enum... s/enum/union/ ? If not, I am not sure what is the enum that you are talking about. [...] >> But, to reply more specifically to your advice, yes, I think I could add >> a flag to vm_struct and then retrieve its value, for the address being >> processed, by passing through find_vm_area(). > > ... and you can store vm_struct pointer to the struct page there "there" as in the new field of the union? btw, what would be a meaningful name, since "private" is already taken? For simplicity, I'll use, for now, "private2" > and you> won't need to do the slow find_vm_area. I haven't checked very closely > but this should be possible in principle. I guess other callers might > benefit from this as well. I am confused about this: if "private2" is a pointer, but when I get an address, I do not even know if the address represents a valid pmalloc page, how can i know when it's ok to dereference "private2"? Since it's just another field in a union, it can actually contain a value that should be interpreted as some other field, right? -- thanks, igor