Skip to content

Commit 360f034

Browse files
committed
Merge tag 'trace-v6.7-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing fixes from Steven Rostedt: - Fix a NULL kernel dereference in set_gid() on tracefs mounting. When tracefs is mounted with "gid=1000", it will update the existing dentries to have the new gid. The tracefs_inode which is retrieved by a container_of(dentry->d_inode) has flags to see if the inode belongs to the eventfs system. The issue that was fixed was if getdents() was called on tracefs that was previously mounted, and was not closed. It will leave a "cursor dentry" in the subdirs list of the current dentries that set_gid() walks. On a remount of tracefs, the container_of(dentry->d_inode) will dereference a NULL pointer and cause a crash when referenced. Simply have a check for dentry->d_inode to see if it is NULL and if so, skip that entry. - Fix the bits of the eventfs_inode structure. The "is_events" bit was taken from the nr_entries field, but the nr_entries field wasn't updated to be 30 bits and was still 31. Including the "is_freed" bit this would use 33 bits which would make the structure use another integer for just one bit. * tag 'trace-v6.7-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: eventfs: Fix bitwise fields for "is_events" tracefs: Check for dentry->d_inode exists in set_gid()
2 parents 981d041 + fd56cd5 commit 360f034

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

fs/tracefs/inode.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ static void set_gid(struct dentry *parent, kgid_t gid)
215215
struct dentry *dentry = list_entry(tmp, struct dentry, d_child);
216216
next = tmp->next;
217217

218+
/* Note, getdents() can add a cursor dentry with no inode */
219+
if (!dentry->d_inode)
220+
continue;
221+
218222
spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
219223

220224
change_gid(dentry, gid);

fs/tracefs/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct eventfs_inode {
6363
};
6464
unsigned int is_freed:1;
6565
unsigned int is_events:1;
66-
unsigned int nr_entries:31;
66+
unsigned int nr_entries:30;
6767
};
6868

6969
static inline struct tracefs_inode *get_tracefs(const struct inode *inode)

0 commit comments

Comments
 (0)