slirp: check sscanf result when emulating ident
PATCH 1/1 slirp: check sscanf result when emulating ident
When emulating ident in tcp_emu, if the strchr checks passed but the sscanf check failed, two uninitialized variables would be copied and sent in the reply.
--- slirp/tcp_subr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
slirp/tcp_subr.c +6 -6
@@ -664,12 +664,12 @@ tcp_emu(struct socket *so, struct mbuf *m)break ; } } - } - so_rcv->sb_cc =snprintf (so_rcv->sb_data, - so_rcv->sb_datalen, -"%d,%d\r\n" , n1, n2); - so_rcv->sb_rptr = so_rcv->sb_data; - so_rcv->sb_wptr = so_rcv->sb_data + so_rcv->sb_cc; + so_rcv->sb_cc =snprintf (so_rcv->sb_data, + so_rcv->sb_datalen, +"%d,%d\r\n" , n1, n2); + so_rcv->sb_rptr = so_rcv->sb_data; + so_rcv->sb_wptr = so_rcv->sb_data + so_rcv->sb_cc; + } }m_free (m);return 0 ;
Signature · 1 line
2.15.1
Samuel Thibault
AppliedWilliam Bowling, le ven. 01 mars 2019 21:45:56 +0000, a ecrit:
Quoted 5 lines
When emulating ident in
tcp_emu, if the strchr checks passed but the sscanf check failed, two uninitialized variables would be copied and sent in the reply.Signed-off-by William Bowling <[email protected]>
Applied to my tree, thanks!
Quoted 31 lines
--- slirp/tcp_subr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)slirp/tcp_subr.c +6
-6@@ -664,12 +664,12 @@ tcp_emu(struct socket *so, struct mbuf *m)break ; } } - } - so_rcv->sb_cc =snprintf (so_rcv->sb_data, - so_rcv->sb_datalen, -"%d,%d\r\n" , n1, n2); - so_rcv->sb_rptr = so_rcv->sb_data; - so_rcv->sb_wptr = so_rcv->sb_data + so_rcv->sb_cc; + so_rcv->sb_cc =snprintf (so_rcv->sb_data, + so_rcv->sb_datalen, +"%d,%d\r\n" , n1, n2); + so_rcv->sb_rptr = so_rcv->sb_data; + so_rcv->sb_wptr = so_rcv->sb_data + so_rcv->sb_cc; + } }m_free (m);return 0 ;Signature · 1 line
2.15.1
Signature · 6 lines
Samuel
What's this script do?
unzip ; touch ; finger ; mount ; gasp ; yes ; umount ; sleep
Hint for the answer: not everything is computer-oriented. Sometimes you're
in a sleeping bag, camping out.
(Contributed by Frans van der Zande.)Hi William, Samuel,
Quoted 3 lines · William Bowling
When emulating ident in
tcp_emu, if the strchr checks passed but the sscanf check failed, two uninitialized variables would be copied and sent in the reply.
William: How did you notice that? Using a static analyzer?
Samuel: since this diff is not obvious without looking at the context (also due to the code re-indent), can you improve the commit description, such (or better):
"Move this code inside the if(sscanf()) clause".
We have a data leak, Cc'ing qemu-stable.
(Adding the address I noticed you Cc'ed [email protected], so that confirms my guess).
Quoted 2 lines
Signed-off-by William Bowling <[email protected]>
Thanks,
Phil.
Quoted 28 lines
--- slirp/tcp_subr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)slirp/tcp_subr.c +6
-6@@ -664,12 +664,12 @@ tcp_emu(struct socket *so, struct mbuf *m)break ; } } - } - so_rcv->sb_cc =snprintf (so_rcv->sb_data, - so_rcv->sb_datalen, -"%d,%d\r\n" , n1, n2); - so_rcv->sb_rptr = so_rcv->sb_data; - so_rcv->sb_wptr = so_rcv->sb_data + so_rcv->sb_cc; + so_rcv->sb_cc =snprintf (so_rcv->sb_data, + so_rcv->sb_datalen, +"%d,%d\r\n" , n1, n2); + so_rcv->sb_rptr = so_rcv->sb_data; + so_rcv->sb_wptr = so_rcv->sb_data + so_rcv->sb_cc; + } }m_free (m);return 0 ;
Hello,
Philippe Mathieu-Daudé, le sam. 02 mars 2019 18:42:42 +0100, a ecrit:
Quoted 2 lines
Samuel: since this diff is not obvious without looking at the context (also due to the code re-indent),
I dropped the code re-indent to make the change obvious. I still added the commit description, always better goes with saying it :)
Thanks!
Samuel
Hi Phil,
William: How did you notice that? Using a static analyzer?
It was while looking into a previous CVE in tcp_emu, just with a manual code review.
We have a data leak, Cc'ing qemu-stable.
Quoted 2 lines
(Adding the address I noticed you Cc'ed [email protected], so that confirms my guess).
Yeah the report and patch went via the security list initially due to the info leak.
Cheers,
Will
Quoted 61 lines · Philippe Mathieu-Daudé
Hi William, Samuel,
Quoted 3 lines · William Bowling
When emulating ident in
tcp_emu, if the strchr checks passed but the sscanf check failed, two uninitialized variables would be copied and sent in the reply.William: How did you notice that? Using a static analyzer?
Samuel: since this diff is not obvious without looking at the context (also due to the code re-indent), can you improve the commit description, such (or better):
"Move this code inside the if(sscanf()) clause".
We have a data leak, Cc'ing qemu-stable.
(Adding the address I noticed you Cc'ed [email protected], so that confirms my guess).Quoted 2 lines
Signed-off-by William Bowling <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Thanks,
Phil.
Quoted 9 lines
--- slirp/tcp_subr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)slirp/tcp_subr.c +0
-0slirp/tcp_subr.c tcp_emu(struct socket *so, struct mbuf *m) · line 668
Quoted 5 lines
slirp/tcp_subr.c +0
-2@@ -664,12 +664,12 @@ tcp_emu(struct socket *so, struct mbuf *m)break ; } } - } - so_rcv->sb_cc =snprintf(so_rcv->sb_data,
slirp/tcp_subr.c tcp_emu(struct socket *so, struct mbuf *m) · line 669
Quoted 1 line
slirp/tcp_subr.c +0
-1-
so_rcv->sb_datalen,slirp/tcp_subr.c tcp_emu(struct socket *so, struct mbuf *m) · line 670
Quoted 1 line
slirp/tcp_subr.c +0
-1- "%d,%d\r\n",n1, n2);
slirp/tcp_subr.c tcp_emu(struct socket *so, struct mbuf *m) · line 672
Quoted 2 lines
slirp/tcp_subr.c +0
-2- so_rcv->sb_rptr = so_rcv->sb_data; - so_rcv->sb_wptr = so_rcv->sb_data +
so_rcv->sb_cc;Quoted 10 lines
slirp/tcp_subr.c +6
-0+ so_rcv->sb_cc =snprintf (so_rcv->sb_data, + so_rcv->sb_datalen, +"%d,%d\r\n" , n1, n2); + so_rcv->sb_rptr = so_rcv->sb_data; + so_rcv->sb_wptr = so_rcv->sb_data + so_rcv->sb_cc; + } }m_free (m);return 0 ;
Signature · 3 lines
GPG Key ID: 0x980F711A GPG Key Fingerprint: AA38 2A0E 7D22 18A9 6086 0289 41DC E04B 980F 711A