ipx: call ipxitf_put() in ioctl error path
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 ipx: call ipxitf_put() in ioctl error path
We should call ipxitf_put() if the copy_to_user() fails.
net/ipx/af_ipx.c +2 -3
@@ -1168,11 +1168,10 @@ static int ipxitf_ioctl(unsigned int cmd, void __user *arg) sipx->sipx_network = ipxif->if_netnum;memcpy (sipx->sipx_node, ipxif->if_node,sizeof (sipx->sipx_node)); - rc = -EFAULT ; + rc =0 ;if (copy_to_user (arg, &ifr,sizeof (ifr))) -break ; + rc = -EFAULT ;ipxitf_put (ipxif); - rc =0 ;break ; }case SIOCAIPXITFCRT :
From: Dan Carpenter <[email protected]>
Date: Tue, 2 May 2017 13:58:53 +0300
Quoted 4 lines
We should call
ipxitf_put()if thecopy_to_user()fails.Reported-by 李强 <[email protected]>Signed-off-by Dan Carpenter <[email protected]>
Applied, thanks Dan.
Quoted 13 lines · Dan Carpenter
We should call
ipxitf_put()if thecopy_to_user()fails.Reported-by 李强 <[email protected]>Signed-off-by Dan Carpenter <[email protected]>net/ipx/af_ipx.c +0
-0@@ -1168,11 +1168,10 @@ static int ipxitf_ioctl(unsigned int cmd, void __user *arg) sipx->sipx_network = ipxif->if_netnum;memcpy (sipx->sipx_node, ipxif->if_node,sizeof (sipx->sipx_node));
net/ipx/af_ipx.c static int ipxitf_ioctl(unsigned int cmd, void __user *arg) · line 1177
Quoted 10 lines
net/ipx/af_ipx.c +2
-3- rc = -EFAULT ; + rc =0 ;if (copy_to_user (arg, &ifr,sizeof (ifr))) -break ; + rc = -EFAULT ;ipxitf_put (ipxif); - rc =0 ;break ; }case SIOCAIPXITFCRT :
This refcount overflow flaw (and resulting use-after-free) appears to be reachable from unprivileged userspace, though I think it requires an interface already be configured, so this is likely not much risk to most users. Someone more familiar with IPX should double-check...
And, of course, I should point out this flaw would have been blocked entirely by using refcount_t:
https://lkml.org/lkml/2017/3/17/193
And if it didn't require a configured interface, it would be mitigated with module autoload blocking:
https://lkml.org/lkml/2017/4/19/1088
(Yes, yes, I know both are still being worked on, but this is a good example to show another case where they'd have been useful.)
-Kees
Signature · 2 lines
Kees Cook Pixel Security