Open
Fix CVE-2026-9539 #21
chenyanpanAdd on Aug 16
Fix CVE-2026-9539 #21
Open
Total: 2 files changed+126-1
| @@ -0,0 +1,121 @@ | |||
| 1 | +From 927bca7344e31fd58e2f7afaca784aad4400eb84 Mon Sep 17 00:00:00 2001 | ||
| 2 | +From: Samuel Thibault <samuel.thibault@ens-lyon.org> | ||
| 3 | +Date: Sat, 23 May 2026 22:06:59 +0200 | ||
| 4 | +Subject: [PATCH] oob: cap urgent data count to what is actually available | ||
| 5 | + | ||
| 6 | +so_urgc is provided by the guest sender, so can arbitrary and beyond | ||
| 7 | +what we actually have. Worse, this can lead to an sb_cc integer | ||
| 8 | +underflow leading to leaking gigabytes of data. | ||
| 9 | + | ||
| 10 | +Fixes #93 | ||
| 11 | + | ||
| 12 | +Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> | ||
| 13 | +--- | ||
| 14 | + src/socket.c | 40 +++++++++++++++++++++++----------------- | ||
| 15 | + 1 file changed, 23 insertions(+), 17 deletions(-) | ||
| 16 | + | ||
| 17 | +diff --git a/src/socket.c b/src/socket.c | ||
| 18 | +index 77c5cf69..c491d0fd 100644 | ||
| 19 | +--- a/src/socket.c | ||
| 20 | ++++ b/src/socket.c | ||
| 21 | +@@ -339,7 +339,8 @@ int sorecvoob(struct socket *so) | ||
| 22 | + int sosendoob(struct socket *so) | ||
| 23 | + { | ||
| 24 | + struct sbuf *sb = &so->so_rcv; | ||
| 25 | +- char buff[2048]; /* XXX Shouldn't be sending more oob data than this */ | ||
| 26 | ++ uint32_t urgc = so->so_urgc; | ||
| 27 | ++ char buff[2048]; | ||
| 28 | + | ||
| 29 | + int n; | ||
| 30 | + | ||
| 31 | +@@ -347,12 +348,15 @@ int sosendoob(struct socket *so) | ||
| 32 | + DEBUG_ARG("so = %p", so); | ||
| 33 | + DEBUG_ARG("sb->sb_cc = %d", sb->sb_cc); | ||
| 34 | + | ||
| 35 | +- if (so->so_urgc > sizeof(buff)) | ||
| 36 | +- so->so_urgc = sizeof(buff); /* XXXX */ | ||
| 37 | ++ if (urgc > sizeof(buff)) | ||
| 38 | ++ urgc = sizeof(buff); | ||
| 39 | ++ | ||
| 40 | ++ if (urgc > sb->sb_cc) | ||
| 41 | ++ urgc = sb->sb_cc; | ||
| 42 | + | ||
| 43 | + if (sb->sb_rptr < sb->sb_wptr) { | ||
| 44 | + /* We can send it directly */ | ||
| 45 | +- n = slirp_send(so, sb->sb_rptr, so->so_urgc, | ||
| 46 | ++ n = slirp_send(so, sb->sb_rptr, urgc, | ||
| 47 | + (MSG_OOB)); /* |MSG_DONTWAIT)); */ | ||
| 48 | + } else { | ||
| 49 | + /* | ||
| 50 | +@@ -360,7 +364,6 @@ int sosendoob(struct socket *so) | ||
| 51 | + * we must copy all data to a linear buffer then | ||
| 52 | + * send it all | ||
| 53 | + */ | ||
| 54 | +- uint32_t urgc = so->so_urgc; /* Amount of room left in buff */ | ||
| 55 | + int len = (sb->sb_data + sb->sb_datalen) - sb->sb_rptr; | ||
| 56 | + if (len > urgc) { | ||
| 57 | + len = urgc; | ||
| 58 | +@@ -405,7 +408,7 @@ int sosendoob(struct socket *so) | ||
| 59 | + */ | ||
| 60 | + int sowrite(struct socket *so) | ||
| 61 | + { | ||
| 62 | +- int n, nn; | ||
| 63 | ++ int n, nn, noob = 0; | ||
| 64 | + struct sbuf *sb = &so->so_rcv; | ||
| 65 | + int len = sb->sb_cc; | ||
| 66 | + struct iovec iov[2]; | ||
| 67 | +@@ -415,16 +418,20 @@ int sowrite(struct socket *so) | ||
| 68 | + | ||
| 69 | + if (so->so_urgc) { | ||
| 70 | + uint32_t expected = so->so_urgc; | ||
| 71 | +- if (sosendoob(so) < expected) { | ||
| 72 | +- /* Treat a short write as a fatal error too, | ||
| 73 | +- * rather than continuing on and sending the urgent | ||
| 74 | +- * data as if it were non-urgent and leaving the | ||
| 75 | +- * so_urgc count wrong. | ||
| 76 | +- */ | ||
| 77 | ++ int noob = sosendoob(so); | ||
| 78 | ++ | ||
| 79 | ++ if (noob <= 0) | ||
| 80 | + goto err_disconnected; | ||
| 81 | +- } | ||
| 82 | ++ | ||
| 83 | ++ if (noob < expected) | ||
| 84 | ++ /* Short write: either we have not yet received all | ||
| 85 | ++ * urgent data, or the socket buffers are full. Leave | ||
| 86 | ++ * it for later when we have data or have room. */ | ||
| 87 | ++ return noob; | ||
| 88 | ++ | ||
| 89 | + if (sb->sb_cc == 0) | ||
| 90 | +- return 0; | ||
| 91 | ++ /* Nothing left to write actually */ | ||
| 92 | ++ return noob; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + /* | ||
| 96 | +@@ -455,12 +462,11 @@ int sowrite(struct socket *so) | ||
| 97 | + } else | ||
| 98 | + n = 1; | ||
| 99 | + } | ||
| 100 | +- /* Check if there's urgent data to send, and if so, send it */ | ||
| 101 | + | ||
| 102 | + nn = slirp_send(so, iov[0].iov_base, iov[0].iov_len, 0); | ||
| 103 | + /* This should never happen, but people tell me it does *shrug* */ | ||
| 104 | + if (nn < 0 && (errno == EAGAIN || errno == EINTR)) | ||
| 105 | +- return 0; | ||
| 106 | ++ return noob; | ||
| 107 | + | ||
| 108 | + if (nn <= 0) { | ||
| 109 | + goto err_disconnected; | ||
| 110 | +@@ -487,7 +493,7 @@ int sowrite(struct socket *so) | ||
| 111 | + if ((so->so_state & SS_FWDRAIN) && sb->sb_cc == 0) | ||
| 112 | + sofcantsendmore(so); | ||
| 113 | + | ||
| 114 | +- return nn; | ||
| 115 | ++ return noob + nn; | ||
| 116 | + | ||
| 117 | + err_disconnected: | ||
| 118 | + DEBUG_MISC(" --- sowrite disconnected, so->so_state = %x, errno = %d", | ||
| 119 | +-- | ||
| 120 | +GitLab | ||
| 121 | + | ||
| @@ -1,11 +1,12 @@ | |||
| 1 | Name: libslirp | 1 | Name: libslirp |
| 2 | Version: 4.7.0 | 2 | Version: 4.7.0 |
| 3 | -Release: 2 | 3 | +Release: 3 |
| 4 | Summary: A general purpose TCP-IP emulator | 4 | Summary: A general purpose TCP-IP emulator |
| 5 | 5 | ||
| 6 | License: BSD-3-Clause and MIT | 6 | License: BSD-3-Clause and MIT |
| 7 | URL: https://gitlab.freedesktop.org/slirp/libslirp | 7 | URL: https://gitlab.freedesktop.org/slirp/libslirp |
| 8 | Source0: %{url}/-/archive/v%{version}/%{name}-%{version}.tar.xz | 8 | Source0: %{url}/-/archive/v%{version}/%{name}-%{version}.tar.xz |
| 9 | +Patch1: backport-CVE-2026-9539.patch | ||
| 9 | 10 | ||
| 10 | BuildRequires: git-core | 11 | BuildRequires: git-core |
| 11 | BuildRequires: meson | 12 | BuildRequires: meson |
| @@ -46,6 +47,9 @@ developing applications that use libslirp. | |||
| 46 | %{_libdir}/pkgconfig/slirp.pc | 47 | %{_libdir}/pkgconfig/slirp.pc |
| 47 | 48 | ||
| 48 | %changelog | 49 | %changelog |
| 50 | +* Tue Aug 18 2026 chenyanpan <chenyanpan@xfusion.com> - 4.7.0-3 | ||
| 51 | +- Fix CVE-2026-9539 | ||
| 52 | + | ||
| 49 | * Fri Dec 09 2022 liukuo <liukuo@kylinos.cn> - 4.7.0-2 | 53 | * Fri Dec 09 2022 liukuo <liukuo@kylinos.cn> - 4.7.0-2 |
| 50 | - License compliance rectification | 54 | - License compliance rectification |
| 51 | 55 | ||