From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756200AbdEDRZI (ORCPT ); Thu, 4 May 2017 13:25:08 -0400 Received: from mga07.intel.com ([134.134.136.100]:34996 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756039AbdEDRYs (ORCPT ); Thu, 4 May 2017 13:24:48 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,287,1491289200"; d="scan'208";a="82566279" Subject: Re: RFC v2: post-init-read-only protection for data allocated dynamically To: Michal Hocko , Igor Stoppa References: <9200d87d-33b6-2c70-0095-e974a30639fd@huawei.com> <20170504112159.GC31540@dhcp22.suse.cz> <83d4556c-b21c-7ae5-6e83-4621a74f9fd5@huawei.com> <20170504131131.GI31540@dhcp22.suse.cz> <20170504140126.GJ31540@dhcp22.suse.cz> Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org From: Dave Hansen Message-ID: <361e39e9-517a-2fc2-016c-23f9359fef0a@intel.com> Date: Thu, 4 May 2017 10:24:42 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170504140126.GJ31540@dhcp22.suse.cz> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/04/2017 07:01 AM, Michal Hocko wrote: > Just to make my proposal more clear. I suggest the following workflow > > cache = kmem_cache_create(foo, object_size, ..., SLAB_SEAL); > > obj = kmem_cache_alloc(cache, gfp_mask); > init_obj(obj) > [more allocations] > kmem_cache_seal(cache); > > All slab pages belonging to the cache would get write protection. All > new allocations from this cache would go to new slab pages. Later > kmem_cache_seal will write protect only those new pages. Igor, what sizes of objects are you after here, mostly? I ask because slub, at least, doesn't work at all for objects >PAGE_SIZE. It just punts those to the page allocator. But, you _could_ still use vmalloc() for those.