Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-19 Thread Igor Stoppa
Hello, On 10/05/17 18:45, Dave Hansen wrote: > On 05/10/2017 08:19 AM, Igor Stoppa wrote: >> So I'd like to play a little what-if scenario: >> what if I was to support exclusively virtual memory and convert to it >> everything that might need sealing? > > Because of the issues related to fracturi

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-10 Thread Dave Hansen
On 05/10/2017 08:19 AM, Igor Stoppa wrote: > So I'd like to play a little what-if scenario: > what if I was to support exclusively virtual memory and convert to it > everything that might need sealing? Because of the issues related to fracturing large pages, you might have had to go this route eve

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-10 Thread Igor Stoppa
On 10/05/17 14:43, Michal Hocko wrote: > On Wed 10-05-17 11:57:42, Igor Stoppa wrote: >> On 10/05/17 11:05, Michal Hocko wrote: > [...] >>> To me it seems that this being an initialization mostly thingy a simple >>> allocator which manages a pool of pages (one set of sealed and one for >>> allocati

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-10 Thread Michal Hocko
On Wed 10-05-17 11:57:42, Igor Stoppa wrote: > On 10/05/17 11:05, Michal Hocko wrote: [...] > > To me it seems that this being an initialization mostly thingy a simple > > allocator which manages a pool of pages (one set of sealed and one for > > allocations) > > Shouldn't also the set of pages u

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-10 Thread Igor Stoppa
On 10/05/17 11:05, Michal Hocko wrote: > On Fri 05-05-17 13:42:27, Igor Stoppa wrote: [...] >> ... in the case I have in mind, I have various, heterogeneous chunks of >> data, coming from various subsystems, not necessarily page aligned. >> And, even if they were page aligned, most likely they wo

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-10 Thread Michal Hocko
On Fri 05-05-17 13:42:27, Igor Stoppa wrote: > On 04/05/17 19:49, Laura Abbott wrote: > > [adding kernel-hardening since I think there would be interest] > > thank you, I overlooked this > > > > BPF takes the approach of calling set_memory_ro to mark regions as > > read only. I'm certainly over

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-10 Thread Michal Hocko
On Fri 05-05-17 15:19:19, Igor Stoppa wrote: > > > On 04/05/17 17:01, Michal Hocko wrote: > > On Thu 04-05-17 16:37:55, Igor Stoppa wrote: > > [...] > > >> The disadvantage is that anything can happen, undetected, while the seal > >> is lifted. > > > > Yes and I think this makes it basically p

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-09 Thread Igor Stoppa
On 08/05/17 18:25, Laura Abbott wrote: > On 05/05/2017 03:42 AM, Igor Stoppa wrote: >> On 04/05/17 19:49, Laura Abbott wrote: [...] > PAGE_SIZE is still 4K/16K/64K but the underlying page table mappings > may use larger mappings (2MB, 32M, 512M, etc.). The ARM architecture > has a break-before-ma

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-08 Thread Laura Abbott
On 05/05/2017 03:42 AM, Igor Stoppa wrote: > On 04/05/17 19:49, Laura Abbott wrote: >> [adding kernel-hardening since I think there would be interest] > > thank you, I overlooked this > > >> BPF takes the approach of calling set_memory_ro to mark regions as >> read only. I'm certainly over simpl

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-05 Thread Igor Stoppa
On 04/05/17 17:01, Michal Hocko wrote: > On Thu 04-05-17 16:37:55, Igor Stoppa wrote: [...] >> The disadvantage is that anything can happen, undetected, while the seal >> is lifted. > > Yes and I think this makes it basically pointless ok, this goes a bit beyond what I had in mind initially,

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-05 Thread Igor Stoppa
On 04/05/17 20:24, Dave Hansen wrote: > 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 al

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-05 Thread Igor Stoppa
On 04/05/17 19:49, Laura Abbott wrote: > [adding kernel-hardening since I think there would be interest] thank you, I overlooked this > BPF takes the approach of calling set_memory_ro to mark regions as > read only. I'm certainly over simplifying but it sounds like this > is mostly a mechanism t

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-05 Thread Igor Stoppa
On 04/05/17 17:30, Dave Hansen wrote: > On 05/04/2017 01:17 AM, Igor Stoppa wrote: >> Or, let me put it differently: my goal is to not fracture more pages >> than needed. >> It will probably require some profiling to figure out what is the >> ballpark of the memory footprint. > > This is easy to s

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-04 Thread Dave Hansen
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

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-04 Thread Laura Abbott
[adding kernel-hardening since I think there would be interest] On 05/03/2017 05:06 AM, Igor Stoppa wrote: > Hello, > > please review my (longish) line of thoughts, below. > > I've restructured them so that they should be easier to follow. > > > Observations > > > * it is current

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-04 Thread Dave Hansen
On 05/04/2017 01:17 AM, Igor Stoppa wrote: > Or, let me put it differently: my goal is to not fracture more pages > than needed. > It will probably require some profiling to figure out what is the > ballpark of the memory footprint. This is easy to say, but hard to do. What if someone loads a dif

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-04 Thread Michal Hocko
On Thu 04-05-17 16:37:55, Igor Stoppa wrote: > On 04/05/17 16:11, Michal Hocko wrote: > > On Thu 04-05-17 15:14:10, Igor Stoppa wrote: > > > I believe that this is a fundamental question. Sealing sounds useful > > for after-boot usecases as well and it would change the approach > > considerably. C

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-04 Thread Igor Stoppa
On 04/05/17 16:11, Michal Hocko wrote: > On Thu 04-05-17 15:14:10, Igor Stoppa wrote: > I believe that this is a fundamental question. Sealing sounds useful > for after-boot usecases as well and it would change the approach > considerably. Coming up with an ad-hoc solution for the boot only way >

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-04 Thread Michal Hocko
On Thu 04-05-17 15:14:10, Igor Stoppa wrote: [...] > I wonder if you are thinking about loadable modules or maybe livepatch. > My proposal, in its current form, is only about what is done when the > kernel initialization is performed. So it would not take those cases > under its umbrella. Actually

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-04 Thread Igor Stoppa
On 04/05/17 14:21, Michal Hocko wrote: > On Wed 03-05-17 15:06:36, Igor Stoppa wrote: [...] >> * In most, if not all, the cases that could be enhanced, the code will >> be calling kmalloc/vmalloc, indicating GFP_KERNEL as the desired type of >> memory. > > How do you tell that the seal is active

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-04 Thread Michal Hocko
On Wed 03-05-17 15:06:36, Igor Stoppa wrote: > Hello, > > please review my (longish) line of thoughts, below. > > I've restructured them so that they should be easier to follow. > > > Observations > > > * it is currently possible, by using prefix "__read_only", to have the > linke

Re: RFC v2: post-init-read-only protection for data allocated dynamically

2017-05-04 Thread Igor Stoppa
Hi, I suspect this was accidentally a Reply-To instead of a Reply-All, so I'm putting back the CCs that were dropped. On 03/05/17 21:41, Dave Hansen wrote: > On 05/03/2017 05:06 AM, Igor Stoppa wrote: >> My starting point are the policy DB of SE Linux and the LSM Hooks, but >> eventually I would l