Skip to content

Commit e033e7d

Browse files
committed
Merge branch 'dhowells' (patches from DavidH)
Merge misc fixes from David Howells. Two afs fixes and a key refcounting fix. * dhowells: afs: Fix afs_lookup() to not clobber the version on a new dentry afs: Fix use-after-loss-of-ref keys: Fix request_key() cache
2 parents 3f1f9a9 + f52b83b commit e033e7d

3 files changed

Lines changed: 13 additions & 21 deletions

File tree

‎fs/afs/dir.c‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,7 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
908908
unsigned int flags)
909909
{
910910
struct afs_vnode *dvnode = AFS_FS_I(dir);
911+
struct afs_fid fid = {};
911912
struct inode *inode;
912913
struct dentry *d;
913914
struct key *key;
@@ -951,21 +952,18 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
951952
afs_stat_v(dvnode, n_lookup);
952953
inode = afs_do_lookup(dir, dentry, key);
953954
key_put(key);
954-
if (inode == ERR_PTR(-ENOENT)) {
955+
if (inode == ERR_PTR(-ENOENT))
955956
inode = afs_try_auto_mntpt(dentry, dir);
956-
} else {
957-
dentry->d_fsdata =
958-
(void *)(unsigned long)dvnode->status.data_version;
959-
}
957+
958+
if (!IS_ERR_OR_NULL(inode))
959+
fid = AFS_FS_I(inode)->fid;
960+
960961
d = d_splice_alias(inode, dentry);
961962
if (!IS_ERR_OR_NULL(d)) {
962963
d->d_fsdata = dentry->d_fsdata;
963-
trace_afs_lookup(dvnode, &d->d_name,
964-
inode ? AFS_FS_I(inode) : NULL);
964+
trace_afs_lookup(dvnode, &d->d_name, &fid);
965965
} else {
966-
trace_afs_lookup(dvnode, &dentry->d_name,
967-
IS_ERR_OR_NULL(inode) ? NULL
968-
: AFS_FS_I(inode));
966+
trace_afs_lookup(dvnode, &dentry->d_name, &fid);
969967
}
970968
return d;
971969
}

‎include/trace/events/afs.h‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -915,9 +915,9 @@ TRACE_EVENT(afs_call_state,
915915

916916
TRACE_EVENT(afs_lookup,
917917
TP_PROTO(struct afs_vnode *dvnode, const struct qstr *name,
918-
struct afs_vnode *vnode),
918+
struct afs_fid *fid),
919919

920-
TP_ARGS(dvnode, name, vnode),
920+
TP_ARGS(dvnode, name, fid),
921921

922922
TP_STRUCT__entry(
923923
__field_struct(struct afs_fid, dfid )
@@ -928,13 +928,7 @@ TRACE_EVENT(afs_lookup,
928928
TP_fast_assign(
929929
int __len = min_t(int, name->len, 23);
930930
__entry->dfid = dvnode->fid;
931-
if (vnode) {
932-
__entry->fid = vnode->fid;
933-
} else {
934-
__entry->fid.vid = 0;
935-
__entry->fid.vnode = 0;
936-
__entry->fid.unique = 0;
937-
}
931+
__entry->fid = *fid;
938932
memcpy(__entry->name, name->name, __len);
939933
__entry->name[__len] = 0;
940934
),

‎kernel/cred.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ void exit_creds(struct task_struct *tsk)
175175
put_cred(cred);
176176

177177
#ifdef CONFIG_KEYS_REQUEST_CACHE
178-
key_put(current->cached_requested_key);
179-
current->cached_requested_key = NULL;
178+
key_put(tsk->cached_requested_key);
179+
tsk->cached_requested_key = NULL;
180180
#endif
181181
}
182182

0 commit comments

Comments
 (0)