NCPFS memleak/crazyness?
Hello!
Looking at fs/ncpfs/ioctl.c (latest 2.4 bk tree), I seem to see a place where we use userspace-pointers directly (And eventually doing kfree on these). In NCP_IOC_SETOBJECTNAME handler, we allocated space (newname pointer), copy stuff from userspace to there and then assign userspace pointer to our internal structure, whoops! Or am I missing something?
Seems that following patch is needed. (Same problem is present in 2.5 and same patch should apply)
Found with help of smatch + enhanced unfree script.
Bye,
Oleg
===== fs/ncpfs/ioctl.c 1.3 vs edited =====
fs/ncpfs/ioctl.c +1 -1
@@ -434,7 +434,7 @@ oldprivatelen = server->priv.len; server->auth.auth_type = user.auth_type; server->auth.object_name_len = user.object_name_len; - server->auth.object_name = user.object_name; + server->auth.object_name = newname; server->priv.len =0 ; server->priv.data =NULL ;/* leave critical section */
Quoted 10 lines · Oleg Drokin
Hello!
Looking at
fs/ncpfs/ioctl.c(latest 2.4 bk tree), I seem to see a place where we use userspace-pointers directly (And eventually doing kfree on these). InNCP_IOC_SETOBJECTNAMEhandler, we allocated space (newname pointer), copy stuff from userspace to there and then assign userspace pointer to our internal structure, whoops! Or am I missing something?Seems that following patch is needed. (Same problem is present in 2.5 and same patch should apply)
Definitely. Alan, Linus, Marcelo (alphabetically) please apply... 2.2.x should not be affected as it does not support this ioctl.
Petr Vandrovec
From Oleg Drokin:
In NCP_IOC_SETOBJECTNAME handler, we allocated space (newname pointer), copy stuff from userspace to there and then assign userspace pointer to our internal structure, whoops!
===== fs/ncpfs/ioctl.c 1.3 vs edited =====
fs/ncpfs/ioctl.c +1 -1
@@ -434,7 +434,7 @@ oldprivatelen = server->priv.len; server->auth.auth_type = user.auth_type; server->auth.object_name_len = user.object_name_len; - server->auth.object_name = user.object_name; + server->auth.object_name = newname; server->priv.len =0 ; server->priv.data =NULL ;/* leave critical section */