mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
perf/core: Fix bad use of igrab()
As Miklos reported and suggested:
"This pattern repeats two times in trace_uprobe.c and in
kernel/events/core.c as well:
ret = kern_path(filename, LOOKUP_FOLLOW, &path);
if (ret)
goto fail_address_parse;
inode = igrab(d_inode(path.dentry));
path_put(&path);
And it's wrong. You can only hold a reference to the inode if you
have an active ref to the superblock as well (which is normally
through path.mnt) or holding s_umount.
This way unmounting the containing filesystem while the tracepoint is
active will give you the "VFS: Busy inodes after unmount..." message
and a crash when the inode is finally put.
Solution: store path instead of inode."
This patch fixes the issue in kernel/event/core.c.
Reviewed-and-tested-by: Alexander Shishkin <[email protected]>
Reported-by: Miklos Szeredi <[email protected]>
Signed-off-by: Song Liu <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Vince Weaver <[email protected]>
Fixes: 375637bc52 ("perf/core: Introduce address range filtering")
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
This commit is contained in:
parent
a1150c2022
commit
9511bce9fe
3 changed files with 12 additions and 15 deletions
|
|
@ -6668,7 +6668,7 @@ static void perf_event_addr_filters_exec(struct perf_event *event, void *data)
|
|||
|
||||
raw_spin_lock_irqsave(&ifh->lock, flags);
|
||||
list_for_each_entry(filter, &ifh->list, entry) {
|
||||
if (filter->inode) {
|
||||
if (filter->path.dentry) {
|
||||
event->addr_filters_offs[count] = 0;
|
||||
restart++;
|
||||
}
|
||||
|
|
@ -7333,7 +7333,7 @@ static bool perf_addr_filter_match(struct perf_addr_filter *filter,
|
|||
struct file *file, unsigned long offset,
|
||||
unsigned long size)
|
||||
{
|
||||
if (filter->inode != file_inode(file))
|
||||
if (d_inode(filter->path.dentry) != file_inode(file))
|
||||
return false;
|
||||
|
||||
if (filter->offset > offset + size)
|
||||
|
|
@ -8686,8 +8686,7 @@ static void free_filters_list(struct list_head *filters)
|
|||
struct perf_addr_filter *filter, *iter;
|
||||
|
||||
list_for_each_entry_safe(filter, iter, filters, entry) {
|
||||
if (filter->inode)
|
||||
iput(filter->inode);
|
||||
path_put(&filter->path);
|
||||
list_del(&filter->entry);
|
||||
kfree(filter);
|
||||
}
|
||||
|
|
@ -8784,7 +8783,7 @@ static void perf_event_addr_filters_apply(struct perf_event *event)
|
|||
* Adjust base offset if the filter is associated to a binary
|
||||
* that needs to be mapped:
|
||||
*/
|
||||
if (filter->inode)
|
||||
if (filter->path.dentry)
|
||||
event->addr_filters_offs[count] =
|
||||
perf_addr_filter_apply(filter, mm);
|
||||
|
||||
|
|
@ -8858,7 +8857,6 @@ perf_event_parse_addr_filter(struct perf_event *event, char *fstr,
|
|||
{
|
||||
struct perf_addr_filter *filter = NULL;
|
||||
char *start, *orig, *filename = NULL;
|
||||
struct path path;
|
||||
substring_t args[MAX_OPT_ARGS];
|
||||
int state = IF_STATE_ACTION, token;
|
||||
unsigned int kernel = 0;
|
||||
|
|
@ -8971,19 +8969,18 @@ perf_event_parse_addr_filter(struct perf_event *event, char *fstr,
|
|||
goto fail_free_name;
|
||||
|
||||
/* look up the path and grab its inode */
|
||||
ret = kern_path(filename, LOOKUP_FOLLOW, &path);
|
||||
ret = kern_path(filename, LOOKUP_FOLLOW,
|
||||
&filter->path);
|
||||
if (ret)
|
||||
goto fail_free_name;
|
||||
|
||||
filter->inode = igrab(d_inode(path.dentry));
|
||||
path_put(&path);
|
||||
kfree(filename);
|
||||
filename = NULL;
|
||||
|
||||
ret = -EINVAL;
|
||||
if (!filter->inode ||
|
||||
!S_ISREG(filter->inode->i_mode))
|
||||
/* free_filters_list() will iput() */
|
||||
if (!filter->path.dentry ||
|
||||
!S_ISREG(d_inode(filter->path.dentry)
|
||||
->i_mode))
|
||||
goto fail;
|
||||
|
||||
event->addr_filters.nr_file_filters++;
|
||||
|
|
|
|||
Loading…
Reference in a new issue