Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1355423

Re: [PATCH v5 1/8] debugfs: prevent access to possibly dead file_operations at file open

From Rasmus Villemoes <linux@rasmusvillemoes.dk>
Newsgroups linux.kernel
Subject Re: [PATCH v5 1/8] debugfs: prevent access to possibly dead file_operations at file open
Date 2016-03-10 23:00 +0100
Message-ID <rbgMG-4AF-7@gated-at.bofh.it> (permalink)
References <r9FYS-4XC-5@gated-at.bofh.it> <r9FYT-4XC-27@gated-at.bofh.it>
Organization D03

Show all headers | View raw


On Sun, Mar 06 2016, Nicolai Stange <nicstange@gmail.com> wrote:

> + *
> + * Allow any ongoing concurrent call into debugfs_remove() or
> + * debugfs_remove_recursive() blocked by a former call to
> + * debugfs_use_file_start() to proceed and return to its caller.
> + */
> +static void debugfs_use_file_finish(int srcu_idx) __releases(&debugfs_srcu)
> +{
> +	srcu_read_unlock(&debugfs_srcu, srcu_idx);
> +}
> +
> +#define F_DENTRY(filp) ((filp)->f_path.dentry)
> +
> +#define REAL_FOPS_DEREF(dentry)					\
> +	((const struct file_operations *)(dentry)->d_fsdata)
> +
> +static int open_proxy_open(struct inode *inode, struct file *filp)
> +{
> +	const struct dentry *dentry = F_DENTRY(filp);
> +	const struct file_operations *real_fops = NULL;
> +	int srcu_idx, r;
> +
> +	r = debugfs_use_file_start(dentry, &srcu_idx);
> +	if (r) {
> +		debugfs_use_file_finish(srcu_idx);
> +		r = -ENOENT;
> +		goto out;

this...

> +out:
> +	fops_put(real_fops);
> +	debugfs_use_file_finish(srcu_idx);

... and that seems like an obvious double unlock?

Rasmus

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v5 0/8] fix debugfs file removal races Nicolai Stange <nicstange@gmail.com> - 2016-03-06 13:30 +0100
  [PATCH v5 3/8] debugfs: add support for self-protecting attribute file fops Nicolai Stange <nicstange@gmail.com> - 2016-03-06 13:30 +0100
  [PATCH v5 8/8] debugfs: unproxify files created through debugfs_create_u32_array() Nicolai Stange <nicstange@gmail.com> - 2016-03-06 13:30 +0100
  [PATCH v5 1/8] debugfs: prevent access to possibly dead file_operations at file open Nicolai Stange <nicstange@gmail.com> - 2016-03-06 13:30 +0100
    Re: [PATCH v5 1/8] debugfs: prevent access to possibly dead file_operations at file open Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-03-10 23:00 +0100
      Re: [PATCH v5 1/8] debugfs: prevent access to possibly dead file_operations at file open Nicolai Stange <nicstange@gmail.com> - 2016-03-11 20:30 +0100
  [PATCH v5 4/8] debugfs, coccinelle: check for obsolete DEFINE_SIMPLE_ATTRIBUTE() usage Nicolai Stange <nicstange@gmail.com> - 2016-03-06 13:30 +0100
  [PATCH v5 6/8] debugfs: unproxify files created through debugfs_create_bool() Nicolai Stange <nicstange@gmail.com> - 2016-03-06 13:30 +0100
  [PATCH v5 2/8] debugfs: prevent access to removed files' private data Nicolai Stange <nicstange@gmail.com> - 2016-03-06 13:30 +0100

csiph-web