mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 19:51:31 -04:00
fs/9p: avoid accessing utsname after namespace has been torn down
During trinity fuzzing in a kvmtool guest, I stumbled across the
following:
Unable to handle kernel NULL pointer dereference at virtual address 00000004
PC is at v9fs_file_do_lock+0xc8/0x1a0
LR is at v9fs_file_do_lock+0x48/0x1a0
[<c01e2ed0>] (v9fs_file_do_lock+0xc8/0x1a0) from [<c0119154>] (locks_remove_flock+0x8c/0x124)
[<c0119154>] (locks_remove_flock+0x8c/0x124) from [<c00d9bf0>] (__fput+0x58/0x1e4)
[<c00d9bf0>] (__fput+0x58/0x1e4) from [<c0044340>] (task_work_run+0xac/0xe8)
[<c0044340>] (task_work_run+0xac/0xe8) from [<c002e36c>] (do_exit+0x6bc/0x8d8)
[<c002e36c>] (do_exit+0x6bc/0x8d8) from [<c002e674>] (do_group_exit+0x3c/0xb0)
[<c002e674>] (do_group_exit+0x3c/0xb0) from [<c002e6f8>] (__wake_up_parent+0x0/0x18)
I believe this is due to an attempt to access utsname()->nodename, after
exit_task_namespaces() has been called, leaving current->nsproxy->uts_ns
as NULL and causing the above dereference.
A similar issue was fixed for lockd in 9a1b6bf818 ("LOCKD: Don't call
utsname()->nodename from nlmclnt_setlockargs"), so this patch attempts
something similar for 9pfs.
Cc: Eric Van Hensbergen <[email protected]>
Cc: Ron Minnich <[email protected]>
Cc: Latchesar Ionkov <[email protected]>
Cc: Trond Myklebust <[email protected]>
Signed-off-by: Will Deacon <[email protected]>
Signed-off-by: Eric Van Hensbergen <[email protected]>
This commit is contained in:
parent
e0d6cb9cd3
commit
50192abe02
3 changed files with 12 additions and 2 deletions
|
|
@ -992,6 +992,7 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
|
|||
{
|
||||
int err;
|
||||
struct p9_client *clnt;
|
||||
char *client_id;
|
||||
|
||||
err = 0;
|
||||
clnt = kmalloc(sizeof(struct p9_client), GFP_KERNEL);
|
||||
|
|
@ -1000,6 +1001,10 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
|
|||
|
||||
clnt->trans_mod = NULL;
|
||||
clnt->trans = NULL;
|
||||
|
||||
client_id = utsname()->nodename;
|
||||
memcpy(clnt->name, client_id, strlen(client_id) + 1);
|
||||
|
||||
spin_lock_init(&clnt->lock);
|
||||
INIT_LIST_HEAD(&clnt->fidlist);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue