Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2fb59d62 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
* 'audit.b43' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit-current:
  [PATCH] audit: watching subtrees
  [PATCH] new helper - inotify_evict_watch()
  [PATCH] new helper - inotify_clone_watch()
  [PATCH] new helpers - collect_mounts() and release_collected_mounts()
  [PATCH] pass dentry to audit_inode()/audit_inode_child()
parents efdc3131 74c3cbe3
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -38,7 +38,7 @@ int sysctl_vfs_cache_pressure __read_mostly = 100;
EXPORT_SYMBOL_GPL(sysctl_vfs_cache_pressure);
EXPORT_SYMBOL_GPL(sysctl_vfs_cache_pressure);


 __cacheline_aligned_in_smp DEFINE_SPINLOCK(dcache_lock);
 __cacheline_aligned_in_smp DEFINE_SPINLOCK(dcache_lock);
static __cacheline_aligned_in_smp DEFINE_SEQLOCK(rename_lock);
__cacheline_aligned_in_smp DEFINE_SEQLOCK(rename_lock);


EXPORT_SYMBOL(dcache_lock);
EXPORT_SYMBOL(dcache_lock);


+1 −1
Original line number Original line Diff line number Diff line
@@ -413,7 +413,7 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
	d_move(old_dentry, dentry);
	d_move(old_dentry, dentry);
	fsnotify_move(old_dir->d_inode, new_dir->d_inode, old_name,
	fsnotify_move(old_dir->d_inode, new_dir->d_inode, old_name,
		old_dentry->d_name.name, S_ISDIR(old_dentry->d_inode->i_mode),
		old_dentry->d_name.name, S_ISDIR(old_dentry->d_inode->i_mode),
		NULL, old_dentry->d_inode);
		NULL, old_dentry);
	fsnotify_oldname_free(old_name);
	fsnotify_oldname_free(old_name);
	unlock_rename(new_dir, old_dir);
	unlock_rename(new_dir, old_dir);
	dput(dentry);
	dput(dentry);
+43 −0
Original line number Original line Diff line number Diff line
@@ -666,6 +666,49 @@ out:
}
}
EXPORT_SYMBOL_GPL(inotify_add_watch);
EXPORT_SYMBOL_GPL(inotify_add_watch);


/**
 * inotify_clone_watch - put the watch next to existing one
 * @old: already installed watch
 * @new: new watch
 *
 * Caller must hold the inotify_mutex of inode we are dealing with;
 * it is expected to remove the old watch before unlocking the inode.
 */
s32 inotify_clone_watch(struct inotify_watch *old, struct inotify_watch *new)
{
	struct inotify_handle *ih = old->ih;
	int ret = 0;

	new->mask = old->mask;
	new->ih = ih;

	mutex_lock(&ih->mutex);

	/* Initialize a new watch */
	ret = inotify_handle_get_wd(ih, new);
	if (unlikely(ret))
		goto out;
	ret = new->wd;

	get_inotify_handle(ih);

	new->inode = igrab(old->inode);

	list_add(&new->h_list, &ih->watches);
	list_add(&new->i_list, &old->inode->inotify_watches);
out:
	mutex_unlock(&ih->mutex);
	return ret;
}

void inotify_evict_watch(struct inotify_watch *watch)
{
	get_inotify_watch(watch);
	mutex_lock(&watch->ih->mutex);
	inotify_remove_watch_locked(watch->ih, watch);
	mutex_unlock(&watch->ih->mutex);
}

/**
/**
 * inotify_rm_wd - remove a watch from an inotify instance
 * inotify_rm_wd - remove a watch from an inotify instance
 * @ih: inotify handle
 * @ih: inotify handle
+5 −5
Original line number Original line Diff line number Diff line
@@ -1174,7 +1174,7 @@ static int fastcall do_path_lookup(int dfd, const char *name,
out:
out:
	if (unlikely(!retval && !audit_dummy_context() && nd->dentry &&
	if (unlikely(!retval && !audit_dummy_context() && nd->dentry &&
				nd->dentry->d_inode))
				nd->dentry->d_inode))
		audit_inode(name, nd->dentry->d_inode);
		audit_inode(name, nd->dentry);
out_fail:
out_fail:
	return retval;
	return retval;


@@ -1214,7 +1214,7 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
	retval = path_walk(name, nd);
	retval = path_walk(name, nd);
	if (unlikely(!retval && !audit_dummy_context() && nd->dentry &&
	if (unlikely(!retval && !audit_dummy_context() && nd->dentry &&
				nd->dentry->d_inode))
				nd->dentry->d_inode))
		audit_inode(name, nd->dentry->d_inode);
		audit_inode(name, nd->dentry);


	return retval;
	return retval;


@@ -1469,7 +1469,7 @@ static int may_delete(struct inode *dir,struct dentry *victim,int isdir)
		return -ENOENT;
		return -ENOENT;


	BUG_ON(victim->d_parent->d_inode != dir);
	BUG_ON(victim->d_parent->d_inode != dir);
	audit_inode_child(victim->d_name.name, victim->d_inode, dir);
	audit_inode_child(victim->d_name.name, victim, dir);


	error = permission(dir,MAY_WRITE | MAY_EXEC, NULL);
	error = permission(dir,MAY_WRITE | MAY_EXEC, NULL);
	if (error)
	if (error)
@@ -1783,7 +1783,7 @@ do_last:
	 * It already exists.
	 * It already exists.
	 */
	 */
	mutex_unlock(&dir->d_inode->i_mutex);
	mutex_unlock(&dir->d_inode->i_mutex);
	audit_inode(pathname, path.dentry->d_inode);
	audit_inode(pathname, path.dentry);


	error = -EEXIST;
	error = -EEXIST;
	if (flag & O_EXCL)
	if (flag & O_EXCL)
@@ -2562,7 +2562,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
	if (!error) {
	if (!error) {
		const char *new_name = old_dentry->d_name.name;
		const char *new_name = old_dentry->d_name.name;
		fsnotify_move(old_dir, new_dir, old_name, new_name, is_dir,
		fsnotify_move(old_dir, new_dir, old_name, new_name, is_dir,
			      new_dentry->d_inode, old_dentry->d_inode);
			      new_dentry->d_inode, old_dentry);
	}
	}
	fsnotify_oldname_free(old_name);
	fsnotify_oldname_free(old_name);


+21 −1
Original line number Original line Diff line number Diff line
@@ -246,7 +246,7 @@ static struct vfsmount *clone_mnt(struct vfsmount *old, struct dentry *root,
			list_add(&mnt->mnt_slave, &old->mnt_slave_list);
			list_add(&mnt->mnt_slave, &old->mnt_slave_list);
			mnt->mnt_master = old;
			mnt->mnt_master = old;
			CLEAR_MNT_SHARED(mnt);
			CLEAR_MNT_SHARED(mnt);
		} else {
		} else if (!(flag & CL_PRIVATE)) {
			if ((flag & CL_PROPAGATION) || IS_MNT_SHARED(old))
			if ((flag & CL_PROPAGATION) || IS_MNT_SHARED(old))
				list_add(&mnt->mnt_share, &old->mnt_share);
				list_add(&mnt->mnt_share, &old->mnt_share);
			if (IS_MNT_SLAVE(old))
			if (IS_MNT_SLAVE(old))
@@ -746,6 +746,26 @@ Enomem:
	return NULL;
	return NULL;
}
}


struct vfsmount *collect_mounts(struct vfsmount *mnt, struct dentry *dentry)
{
	struct vfsmount *tree;
	down_read(&namespace_sem);
	tree = copy_tree(mnt, dentry, CL_COPY_ALL | CL_PRIVATE);
	up_read(&namespace_sem);
	return tree;
}

void drop_collected_mounts(struct vfsmount *mnt)
{
	LIST_HEAD(umount_list);
	down_read(&namespace_sem);
	spin_lock(&vfsmount_lock);
	umount_tree(mnt, 0, &umount_list);
	spin_unlock(&vfsmount_lock);
	up_read(&namespace_sem);
	release_mounts(&umount_list);
}

/*
/*
 *  @source_mnt : mount tree to be attached
 *  @source_mnt : mount tree to be attached
 *  @nd         : place the mount tree @source_mnt is attached
 *  @nd         : place the mount tree @source_mnt is attached
Loading