Re: [RFC PATCH v2 1/2] lsm: add backing_file LSM hooks
Paul Moore <[email protected]>
| Newsgroups | org.kernel.vger.linux-unionfs,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-security-module,org.kernel.vger.selinux,org.ozlabs.lists.linux-erofs |
|---|---|
| Message-ID | <CAHC9VhRNOGk0dGERbD+RRLTWebZu1-7cbvB0a2D0njbnqBRNXQ@mail.gmail.com> |
On Tue, Mar 24, 2026 at 7:01 PM Ryan Lee <[email protected]> wrote: > > Hi Paul, > > I'm currently looking at the patch more closely to implement the hooks > for AppArmor, but here are some typofixes and the like below: Thanks Ryan, I appreciate the extra eyes. > > diff --git a/include/linux/security.h b/include/linux/security.h > > index 83a646d72f6f..1e4c68d5877f 100644 > > --- a/include/linux/security.h > > +++ b/include/linux/security.h unsigned long prot); > > @@ -1140,6 +1146,15 @@ static inline void security_file_release(struct file *file) > > static inline void security_file_free(struct file *file) > > { } > > > > +int security_backing_file_alloc(void **backing_file_blobp, > > + const struct file *user_file) > > +{ > > + return 0; > > +} > > + > > +void security_backing_file_free(void **backing_file_blobp) > > +{ } > > + > > Should these two placeholders be static inline functions, like the > other ones around them? Yes :) The kernel test robot found the same problem yesterday, I've already fixed it in my working branch. > > diff --git a/security/lsm_init.c b/security/lsm_init.c > > index 573e2a7250c4..020eace65973 100644 > > --- a/security/lsm_init.c > > +++ b/security/lsm_init.c > > @@ -293,6 +293,8 @@ static void __init lsm_prepare(struct lsm_info *lsm) > > blobs = lsm->blobs; > > lsm_blob_size_update(&blobs->lbs_cred, &blob_sizes.lbs_cred); > > lsm_blob_size_update(&blobs->lbs_file, &blob_sizes.lbs_file); > > + lsm_blob_size_update(&blobs->lbs_backing_file, > > + &blob_sizes.lbs_backing_file); > > lsm_blob_size_update(&blobs->lbs_ib, &blob_sizes.lbs_ib); > > /* inode blob gets an rcu_head in addition to LSM blobs. */ > > if (blobs->lbs_inode && blob_sizes.lbs_inode == 0) > > @@ -441,6 +443,8 @@ int __init security_init(void) > > if (lsm_debug) { > > lsm_pr("blob(cred) size %d\n", blob_sizes.lbs_cred); > > lsm_pr("blob(file) size %d\n", blob_sizes.lbs_file); > > + lsm_pr("blob(backing_file) size %d\n", > > + blob_sizes.lbs_backing_file); > > lsm_pr("blob(ib) size %d\n", blob_sizes.lbs_ib); > > lsm_pr("blob(inode) size %d\n", blob_sizes.lbs_inode); > > lsm_pr("blob(ipc) size %d\n", blob_sizes.lbs_ipc); > > @@ -462,6 +466,11 @@ int __init security_init(void) > > lsm_file_cache = kmem_cache_create("lsm_file_cache", > > blob_sizes.lbs_file, 0, > > SLAB_PANIC, NULL); > > + if (blob_sizes.lbs_backing_file) > > + lsm_backing_file_cache = kmem_cache_create( > > + "lsm_backing_file_cache", > > + blob_sizes.lbs_file, 0, > > + SLAB_PANIC, NULL); > > Shouldn't blob_sizes.lbs_file here be blob_sizes.lbs_backing_file instead? Good catch, thank you! I'll have the fix in the next posting. I'm hoping to do some more testing today/tomorrow and post a non-RFC patch by the end of the week. If you find anything else that looks awry, or just doesn't work, please let me know. -- paul-moore.com