Re: [PATCH v2] lsm: check size of writes
From: Paul Moore <paul@paul-moore.com>
Date: 2025-01-05 04:04:20
Also in:
lkml
On Mon, Dec 23, 2024 at 12:33 AM Kees Cook [off-list ref] wrote:
If the LSM core did a kmem_buckets_create() for each LSM, and the LSMs were adjusted to explicitly allocate from their own bucket set, that would be one way. Or just for the LSM as a whole (1 set of buckets instead of a set for each LSM). I'd be happy to review patches for either idea.
If we're doing the work to shift over to kmem_buckets, it seems like creating per-LSM buckets is the better option unless I'm missing something. I'm also not sure why the LSM framework would need to call kmem_buckets_create() on behalf of the individual LSMs, can someone help me understand why the individual LSMs couldn't do it in their init routines? If it is necessary for the LSM framework to create the buckets and hand them back to the individual LSMs, I would suggest adding a new flag to the lsm_info->flags field that a LSM could set to request a kmem_bucket, and then add a new field to lsm_info that the LSM framework could use to return the bucket to the LSM. LSMs could opt-in to kmem_buckets when they found the time to convert.
I think per-site buckets is going to be the most effective long-term: https://lore.kernel.org/lkml/20240809072532.work.266-kees@kernel.org/ (local) But that doesn't exclude new kmem_buckets_create() users.
Is there an update on the per-site buckets? I agree that would be the preferable solution from a hardening perspective, and if it is on the horizon it may not be worth the effort to convert the LSMs over to an explicit kmem_buckets approach. -- paul-moore.com