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

Commit 7e4e28c5 authored by Oleg Nesterov's avatar Oleg Nesterov
Browse files

uprobes/tracing: Ensure inode != NULL in create_trace_uprobe()



probe_event_enable/disable() check tu->inode != NULL at the start.
This is ugly, if igrab() can fail create_trace_uprobe() should not
succeed and "postpone" the failure.

And S_ISREG(inode->i_mode) check added by d24d7dbf is not safe.

Note: alloc_uprobe() should probably check igrab() != NULL as well.

Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Acked-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
parent 4161824f
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -256,7 +256,7 @@ static int create_trace_uprobe(int argc, char **argv)
	inode = igrab(path.dentry->d_inode);
	inode = igrab(path.dentry->d_inode);
	path_put(&path);
	path_put(&path);


	if (!S_ISREG(inode->i_mode)) {
	if (!inode || !S_ISREG(inode->i_mode)) {
		ret = -EINVAL;
		ret = -EINVAL;
		goto fail_address_parse;
		goto fail_address_parse;
	}
	}
@@ -544,7 +544,7 @@ static int probe_event_enable(struct trace_uprobe *tu, int flag)
	struct uprobe_trace_consumer *utc;
	struct uprobe_trace_consumer *utc;
	int ret = 0;
	int ret = 0;


	if (!tu->inode || tu->consumer)
	if (tu->consumer)
		return -EINTR;
		return -EINTR;


	utc = kzalloc(sizeof(struct uprobe_trace_consumer), GFP_KERNEL);
	utc = kzalloc(sizeof(struct uprobe_trace_consumer), GFP_KERNEL);
@@ -568,7 +568,7 @@ static int probe_event_enable(struct trace_uprobe *tu, int flag)


static void probe_event_disable(struct trace_uprobe *tu, int flag)
static void probe_event_disable(struct trace_uprobe *tu, int flag)
{
{
	if (!tu->inode || !tu->consumer)
	if (!tu->consumer)
		return;
		return;


	uprobe_unregister(tu->inode, tu->offset, &tu->consumer->cons);
	uprobe_unregister(tu->inode, tu->offset, &tu->consumer->cons);