[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to get vfsmount from inode?
* Omen Wild (Omen.Wild@xxxxxxxxxxxxx) wrote:
>
> Something like this?
No, cycle the whole namespace looking for mountpoint roots that match
the root of the superblock that the dentry (that you start with) is on.
More like:
> ...
> struct vfsmount *mnt = find_vfsmount(inode->i_sb->s_root);
> ...
>
> static struct vfsmount *find_vfsmount(struct dentry *d) {
struct dentry *root = dget(dentry->d_sb->s_root);
struct namespace *namespace = current->namespace;
struct list_head *head;
struct vfsmount *mnt = NULL;
down_read(&namespace->sem);
list_for_each(head, &namespace->list) {
mnt = list_entry(head, struct vfsmount, mnt_list);
if (mnt->mnt_root == sb_root) {
mntget(mnt);
break; /* this is the problem spot */
}
}
up_read(&namespace->sem);
dput(sb_root);
return mnt;
}
It's pretty fugly, but will find the matches (well, with the 'break' only
the first match. which is not necessarily the path the user used to get
to the dentry!).
thanks,
-chris
--
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net
_______________________________________________
linux-security-module mailing list
linux-security-module@xxxxxxxxxxxxxx
http://mail.wirex.com/mailman/listinfo/linux-security-module
This mailing list archive is a service of Copilotco.