Skip to content

Commit 2bfe15c

Browse files
cgzonespcmoore
authored andcommitted
mm: create security context for memfd_secret inodes
Create a security context for the inodes created by memfd_secret(2) via the LSM hook inode_init_security_anon to allow a fine grained control. As secret memory areas can affect hibernation and have a global shared limit access control might be desirable. Signed-off-by: Christian Göttsche <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent 9691e4f commit 2bfe15c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

mm/secretmem.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,20 @@ static struct file *secretmem_file_create(unsigned long flags)
180180
{
181181
struct file *file = ERR_PTR(-ENOMEM);
182182
struct inode *inode;
183+
const char *anon_name = "[secretmem]";
184+
const struct qstr qname = QSTR_INIT(anon_name, strlen(anon_name));
185+
int err;
183186

184187
inode = alloc_anon_inode(secretmem_mnt->mnt_sb);
185188
if (IS_ERR(inode))
186189
return ERR_CAST(inode);
187190

191+
err = security_inode_init_security_anon(inode, &qname, NULL);
192+
if (err) {
193+
file = ERR_PTR(err);
194+
goto err_free_inode;
195+
}
196+
188197
file = alloc_file_pseudo(inode, secretmem_mnt, "secretmem",
189198
O_RDWR, &secretmem_fops);
190199
if (IS_ERR(file))

0 commit comments

Comments
 (0)