slirp: udp: fix NULL pointer dereference because of uninitialized socket
PATCH v2 1/1 slirp: udp: fix NULL pointer dereference because of uninitialized socket
When guest sends udp packet with source port and source addr 0, uninitialized socket is picked up when looking for matching and already created udp sockets, and later passed to sosendto() where NULL pointer dereference is hit during so->slirp->vnetwork_mask.s_addr access.
Fix this by checking that the socket is not just a socket stub.
This is CVE-2014-3640.
---
v1 -> v2
* change the check so that it's consistent with the rest of the code
slirp/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
slirp/udp.c +1 -1
@@ -152,7 +152,7 @@ udp_input(register struct mbuf *m, int iphlen)* Locate pcb for datagram. */ so = slirp->udp_last_so; -if (so->so_lport != uh->uh_sport || +if (so == &slirp->udb || so->so_lport != uh->uh_sport || so->so_laddr.s_addr != ip->ip_src.s_addr) {struct socket *tmp;
Signature · 1 line
1.9.3
Quoted 25 lines · Petr Matousek
When guest sends udp packet with source port and source addr 0, uninitialized socket is picked up when looking for matching and already created udp sockets, and later passed to
sosendto()where NULL pointer dereference is hit duringso->slirp->vnetwork_mask.s_addraccess.Fix this by checking that the socket is not just a socket stub.
This is CVE-2014-3640.
Signed-off-by Petr Matousek <[email protected]>Reported-by Xavier Mehrenberger <[email protected]>Reported-by Stephane Duverger <[email protected]>---
v1 -> v2
* change the check so that it's consistent with the rest of the codeslirp/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)slirp/udp.c +0
-0
slirp/udp.c udp_input(register struct mbuf *m, int iphlen) · line 158
Quoted 8 lines
slirp/udp.c +1
-1@@ -152,7 +152,7 @@ udp_input(register struct mbuf *m, int iphlen)* Locate pcb for datagram. */ so = slirp->udp_last_so; -if (so->so_lport != uh->uh_sport || +if (so == &slirp->udb || so->so_lport != uh->uh_sport || so->so_laddr.s_addr != ip->ip_src.s_addr) {struct socket *tmp;
Thanks,
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux
Quoted 5 lines · Petr Matousek
When guest sends udp packet with source port and source addr 0, uninitialized socket is picked up when looking for matching and already created udp sockets, and later passed to
sosendto()where NULL pointer dereference is hit duringso->slirp->vnetwork_mask.s_addraccess.
Quoted 7 lines
Fix this by checking that the socket is not just a socket stub.
This is CVE-2014-3640.
Signed-off-by Petr Matousek <[email protected]>Reported-by Xavier Mehrenberger <[email protected]>Reported-by Stephane Duverger <[email protected]>
Quoted 22 lines
---
v1 -> v2
* change the check so that it's consistent with the rest of the codeslirp/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)slirp/udp.c +1
-1@@ -152,7 +152,7 @@ udp_input(register struct mbuf *m, int iphlen)* Locate pcb for datagram. */ so = slirp->udp_last_so; -if (so->so_lport != uh->uh_sport || +if (so == &slirp->udb || so->so_lport != uh->uh_sport || so->so_laddr.s_addr != ip->ip_src.s_addr) {struct socket *tmp;Signature · 1 line
1.9.3
Quoting Petr Matousek (2014-09-18 01:35:37)
Quoted 5 lines
When guest sends udp packet with source port and source addr 0, uninitialized socket is picked up when looking for matching and already created udp sockets, and later passed to
sosendto()where NULL pointer dereference is hit duringso->slirp->vnetwork_mask.s_addraccess.
Quoted 7 lines
Fix this by checking that the socket is not just a socket stub.
This is CVE-2014-3640.
Signed-off-by Petr Matousek <[email protected]>Reported-by Xavier Mehrenberger <[email protected]>Reported-by Stephane Duverger <[email protected]>
Ping. Looking to pull this in for 2.1.2. Release is "asap"
Quoted 22 lines
---
v1 -> v2
* change the check so that it's consistent with the rest of the codeslirp/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)slirp/udp.c +1
-1@@ -152,7 +152,7 @@ udp_input(register struct mbuf *m, int iphlen)* Locate pcb for datagram. */ so = slirp->udp_last_so; -if (so->so_lport != uh->uh_sport || +if (so == &slirp->udb || so->so_lport != uh->uh_sport || so->so_laddr.s_addr != ip->ip_src.s_addr) {struct socket *tmp;Signature · 1 line
1.9.3
Quoted 5 lines · Petr Matousek
When guest sends udp packet with source port and source addr 0, uninitialized socket is picked up when looking for matching and already created udp sockets, and later passed to
sosendto()where NULL pointer dereference is hit duringso->slirp->vnetwork_mask.s_addraccess.
Quoted 7 lines
Fix this by checking that the socket is not just a socket stub.
This is CVE-2014-3640.
Signed-off-by Petr Matousek <[email protected]>Reported-by Xavier Mehrenberger <[email protected]>Reported-by Stephane Duverger <[email protected]>
slirp->udb initially is a dummy element of the list which initially points to itself and never gets used (and slirp->udp_last_so initially points to it too).
Thanks,
/mjt
Quoted 17 lines
slirp/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)slirp/udp.c +1
-1@@ -152,7 +152,7 @@ udp_input(register struct mbuf *m, int iphlen)* Locate pcb for datagram. */ so = slirp->udp_last_so; -if (so->so_lport != uh->uh_sport || +if (so == &slirp->udb || so->so_lport != uh->uh_sport || so->so_laddr.s_addr != ip->ip_src.s_addr) {struct socket *tmp;
Peter Maydell
AppliedQuoted 8 lines · Michael Tokarev
Quoted 7 lines · Petr Matousek
When guest sends udp packet with source port and source addr 0, uninitialized socket is picked up when looking for matching and already created udp sockets, and later passed to
sosendto()where NULL pointer dereference is hit duringso->slirp->vnetwork_mask.s_addraccess.Fix this by checking that the socket is not just a socket stub.
Quoted 7 lines
Quoted 5 lines
This is CVE-2014-3640.
Signed-off-by Petr Matousek <[email protected]>Reported-by Xavier Mehrenberger <[email protected]>Reported-by Stephane Duverger <[email protected]>Reviewed-by Michael Tokarev <[email protected]>
Applied to master, thanks.
-- PMM