Re: [PATCH 2/5] Protectable Memory Allocator

2017-06-06 Thread Laura Abbott
On 06/06/2017 04:34 AM, Igor Stoppa wrote: > On 06/06/17 09:25, Christoph Hellwig wrote: >> On Tue, Jun 06, 2017 at 01:44:32PM +0900, Tetsuo Handa wrote: > > [..] > >>> As far as I know, not all CONFIG_MMU=y architectures provide >>> set_memory_ro()/set_memory_rw(). You need to provide fallback f

Re: [PATCH 2/5] Protectable Memory Allocator

2017-06-06 Thread Igor Stoppa
On 06/06/17 15:08, Tetsuo Handa wrote: > Igor Stoppa wrote: +struct pmalloc_node { + struct hlist_node nodes_list; + atomic_t used_words; + unsigned int total_words; + __PMALLOC_ALIGNED align_t data[]; +}; >>> >>> Is this __PMALLOC_ALIGNED needed? Why not use "lon

Re: [PATCH 2/5] Protectable Memory Allocator

2017-06-06 Thread Tetsuo Handa
Igor Stoppa wrote: > >> +struct pmalloc_node { > >> + struct hlist_node nodes_list; > >> + atomic_t used_words; > >> + unsigned int total_words; > >> + __PMALLOC_ALIGNED align_t data[]; > >> +}; > > > > Is this __PMALLOC_ALIGNED needed? Why not use "long" and "BITS_PER_LONG" ? > > In an earlie

Re: [PATCH 2/5] Protectable Memory Allocator

2017-06-06 Thread Igor Stoppa
Hi, thanks a lot for the review. My answers are in-line below. I have rearranged your comments because I wasn't sure how to reply to them inlined. On 06/06/17 07:44, Tetsuo Handa wrote: > Igor Stoppa wrote: [...] > As far as I know, not all CONFIG_MMU=y architectures provide > set_memory_ro()/se

Re: [PATCH 2/5] Protectable Memory Allocator

2017-06-06 Thread Igor Stoppa
On 06/06/17 09:25, Christoph Hellwig wrote: > On Tue, Jun 06, 2017 at 01:44:32PM +0900, Tetsuo Handa wrote: [..] >> As far as I know, not all CONFIG_MMU=y architectures provide >> set_memory_ro()/set_memory_rw(). You need to provide fallback for >> architectures which do not provide set_memory_ro

Re: [PATCH 2/5] Protectable Memory Allocator

2017-06-05 Thread Christoph Hellwig
On Tue, Jun 06, 2017 at 01:44:32PM +0900, Tetsuo Handa wrote: > Igor Stoppa wrote: > > +int pmalloc_protect_pool(struct pmalloc_pool *pool) > > +{ > > + struct pmalloc_node *node; > > + > > + if (!pool) > > + return -EINVAL; > > + mutex_lock(&pool->nodes_list_mutex); > > + hlist_f

Re: [PATCH 2/5] Protectable Memory Allocator

2017-06-05 Thread Tetsuo Handa
Igor Stoppa wrote: > +int pmalloc_protect_pool(struct pmalloc_pool *pool) > +{ > + struct pmalloc_node *node; > + > + if (!pool) > + return -EINVAL; > + mutex_lock(&pool->nodes_list_mutex); > + hlist_for_each_entry(node, &pool->nodes_list_head, nodes_list) { > +

[PATCH 2/5] Protectable Memory Allocator

2017-06-05 Thread Igor Stoppa
The MMU available in many systems runnign Linux can often provide R/O protection to the memory pages it handles. However, this works efficiently only when said pages contain only data that does not need to be modified. This can work well for statically allocated variables, however it doe not fit