diff options
| author | Gyorgy Sarvari <skandigraun@gmail.com> | 2025-11-19 00:03:20 +1300 |
|---|---|---|
| committer | Anuj Mittal <anuj.mittal@oss.qualcomm.com> | 2025-11-19 08:46:56 +0530 |
| commit | f6c6cdce9d5bab67dceffa47448562417e01cee7 (patch) | |
| tree | 07ec8062385e8bd03f933d44b8f7261df658a175 /meta-oe/recipes-devtools | |
| parent | fd052187aca0d053cecc3e13680f7894bdeab006 (diff) | |
| download | meta-openembedded-f6c6cdce9d5bab67dceffa47448562417e01cee7.tar.gz | |
iptraf-ng: patch CVE-2024-52949
Details: https://nvd.nist.gov/vuln/detail/CVE-2024-52949
Pick the commit that mentions the CVE in its description.
Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
(cherry picked from commit 16071ef98f7cfd1501e9c399ac27afe2e061b22a)
Signed-off-by: Ankur Tyagi <ankur.tyagi85@gmail.com>
Signed-off-by: Anuj Mittal <anuj.mittal@oss.qualcomm.com>
Diffstat (limited to 'meta-oe/recipes-devtools')
| -rw-r--r-- | meta-oe/recipes-devtools/iptraf/iptraf-ng/CVE-2024-52949.patch | 218 | ||||
| -rw-r--r-- | meta-oe/recipes-devtools/iptraf/iptraf-ng_1.2.1.bb | 1 |
2 files changed, 219 insertions, 0 deletions
diff --git a/meta-oe/recipes-devtools/iptraf/iptraf-ng/CVE-2024-52949.patch b/meta-oe/recipes-devtools/iptraf/iptraf-ng/CVE-2024-52949.patch new file mode 100644 index 0000000000..be6624dcdb --- /dev/null +++ b/meta-oe/recipes-devtools/iptraf/iptraf-ng/CVE-2024-52949.patch | |||
| @@ -0,0 +1,218 @@ | |||
| 1 | From 6a35a7f68c2dd946c5092376d71bbf0b925e2c4e Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Vitezslav Samel <vitezslav@samel.cz> | ||
| 3 | Date: Thu, 21 Nov 2024 08:43:57 +0100 | ||
| 4 | Subject: [PATCH] interface names: limit length to IFNAMSIZ | ||
| 5 | |||
| 6 | This fixes CVE-2024-52949 (stack based buffer overflow) | ||
| 7 | when copying user supplied interface name without any | ||
| 8 | check. | ||
| 9 | |||
| 10 | Problem was reported by Massimiliano Ferraresi and Massimiliano Brolli | ||
| 11 | from TIM Red team (https://www.gruppotim.it/it/footer/red-team.html) | ||
| 12 | |||
| 13 | CVE: CVE-2024-52949 | ||
| 14 | Upstream-Status: Backport [https://github.com/iptraf-ng/iptraf-ng/commit/2b623e991115358a57275af8a53feb5ae707b3ae] | ||
| 15 | |||
| 16 | Reported-by: Massimiliano Ferraresi, Massimiliano Brolli | ||
| 17 | Signed-off-by: Vitezslav Samel <vitezslav@samel.cz> | ||
| 18 | --- | ||
| 19 | src/ifaces.c | 16 ++++++++-------- | ||
| 20 | src/ifstats.c | 6 +++--- | ||
| 21 | src/iptraf-ng-compat.h | 1 + | ||
| 22 | src/iptraf.c | 9 +++++++++ | ||
| 23 | src/othptab.c | 2 +- | ||
| 24 | src/promisc.c | 2 +- | ||
| 25 | src/tcptable.c | 4 ++-- | ||
| 26 | src/wrapper.c | 8 ++++++++ | ||
| 27 | 8 files changed, 33 insertions(+), 15 deletions(-) | ||
| 28 | |||
| 29 | diff --git a/src/ifaces.c b/src/ifaces.c | ||
| 30 | index aeb1614..4c5a545 100644 | ||
| 31 | --- a/src/ifaces.c | ||
| 32 | +++ b/src/ifaces.c | ||
| 33 | @@ -67,7 +67,7 @@ int dev_up(char *iface) | ||
| 34 | |||
| 35 | fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); | ||
| 36 | |||
| 37 | - strcpy(ifr.ifr_name, iface); | ||
| 38 | + ifname_copy(ifr.ifr_name, iface); | ||
| 39 | ir = ioctl(fd, SIOCGIFFLAGS, &ifr); | ||
| 40 | |||
| 41 | close(fd); | ||
| 42 | @@ -90,7 +90,7 @@ int dev_get_ifindex(const char *iface) | ||
| 43 | return fd; | ||
| 44 | |||
| 45 | struct ifreq ifr; | ||
| 46 | - strcpy(ifr.ifr_name, iface); | ||
| 47 | + ifname_copy(ifr.ifr_name, iface); | ||
| 48 | int ir = ioctl(fd, SIOCGIFINDEX, &ifr); | ||
| 49 | |||
| 50 | /* need to preserve errno across call to close() */ | ||
| 51 | @@ -114,7 +114,7 @@ int dev_get_mtu(const char *iface) | ||
| 52 | return fd; | ||
| 53 | |||
| 54 | struct ifreq ifr; | ||
| 55 | - strcpy(ifr.ifr_name, iface); | ||
| 56 | + ifname_copy(ifr.ifr_name, iface); | ||
| 57 | int ir = ioctl(fd, SIOCGIFMTU, &ifr); | ||
| 58 | |||
| 59 | /* need to preserve errno across call to close() */ | ||
| 60 | @@ -138,7 +138,7 @@ int dev_get_flags(const char *iface) | ||
| 61 | return fd; | ||
| 62 | |||
| 63 | struct ifreq ifr; | ||
| 64 | - strcpy(ifr.ifr_name, iface); | ||
| 65 | + ifname_copy(ifr.ifr_name, iface); | ||
| 66 | int ir = ioctl(fd, SIOCGIFFLAGS, &ifr); | ||
| 67 | |||
| 68 | /* need to preserve errno across call to close() */ | ||
| 69 | @@ -162,7 +162,7 @@ int dev_set_flags(const char *iface, int flags) | ||
| 70 | return fd; | ||
| 71 | |||
| 72 | struct ifreq ifr; | ||
| 73 | - strcpy(ifr.ifr_name, iface); | ||
| 74 | + ifname_copy(ifr.ifr_name, iface); | ||
| 75 | int ir = ioctl(fd, SIOCGIFFLAGS, &ifr); | ||
| 76 | if (ir == -1) | ||
| 77 | goto err; | ||
| 78 | @@ -190,7 +190,7 @@ int dev_clear_flags(const char *iface, int flags) | ||
| 79 | return fd; | ||
| 80 | |||
| 81 | struct ifreq ifr; | ||
| 82 | - strcpy(ifr.ifr_name, iface); | ||
| 83 | + ifname_copy(ifr.ifr_name, iface); | ||
| 84 | int ir = ioctl(fd, SIOCGIFFLAGS, &ifr); | ||
| 85 | if (ir == -1) | ||
| 86 | goto err; | ||
| 87 | @@ -233,7 +233,7 @@ int dev_get_ifname(int ifindex, char *ifname) | ||
| 88 | return ir; | ||
| 89 | } | ||
| 90 | |||
| 91 | - strncpy(ifname, ifr.ifr_name, IFNAMSIZ); | ||
| 92 | + ifname_copy(ifname, ifr.ifr_name); | ||
| 93 | return ir; | ||
| 94 | } | ||
| 95 | |||
| 96 | @@ -256,7 +256,7 @@ int dev_bind_ifname(int fd, const char * const ifname) | ||
| 97 | int ir; | ||
| 98 | struct ifreq ifr; | ||
| 99 | |||
| 100 | - strcpy(ifr.ifr_name, ifname); | ||
| 101 | + ifname_copy(ifr.ifr_name, ifname); | ||
| 102 | ir = ioctl(fd, SIOCGIFINDEX, &ifr); | ||
| 103 | if (ir) | ||
| 104 | return ir; | ||
| 105 | diff --git a/src/ifstats.c b/src/ifstats.c | ||
| 106 | index 00a2a3f..1b687b6 100644 | ||
| 107 | --- a/src/ifstats.c | ||
| 108 | +++ b/src/ifstats.c | ||
| 109 | @@ -194,7 +194,7 @@ static void initiflist(struct iflist **list) | ||
| 110 | |||
| 111 | struct iflist *itmp = alloc_iflist_entry(); | ||
| 112 | itmp->ifindex = ifindex; | ||
| 113 | - strcpy(itmp->ifname, ifname); | ||
| 114 | + ifname_copy(itmp->ifname, ifname); | ||
| 115 | |||
| 116 | /* make the linked list sorted by ifindex */ | ||
| 117 | struct iflist *cur = *list, *last = NULL; | ||
| 118 | @@ -714,9 +714,9 @@ void selectiface(char *ifname, int withall, int *aborted) | ||
| 119 | if (!(*aborted) && (list != NULL)) { | ||
| 120 | ptmp = (struct iflist *) scrolllist.textptr->nodeptr; | ||
| 121 | if ((withall) && (ptmp->prev_entry == NULL)) /* All Interfaces */ | ||
| 122 | - strcpy(ifname, ""); | ||
| 123 | + ifname_copy(ifname, ""); | ||
| 124 | else | ||
| 125 | - strcpy(ifname, ptmp->ifname); | ||
| 126 | + ifname_copy(ifname, ptmp->ifname); | ||
| 127 | } | ||
| 128 | |||
| 129 | tx_destroy_list(&scrolllist); | ||
| 130 | diff --git a/src/iptraf-ng-compat.h b/src/iptraf-ng-compat.h | ||
| 131 | index 5aec185..845f18b 100644 | ||
| 132 | --- a/src/iptraf-ng-compat.h | ||
| 133 | +++ b/src/iptraf-ng-compat.h | ||
| 134 | @@ -112,6 +112,7 @@ extern void *xmallocz(size_t size); | ||
| 135 | extern char *xstrdup(const char *s); | ||
| 136 | extern int strtoul_ui(char const *s, int base, unsigned int *result); | ||
| 137 | extern int strtol_i(char const *s, int base, int *result); | ||
| 138 | +extern void ifname_copy(char *dst, const char *src); | ||
| 139 | |||
| 140 | extern void die(const char *err, ...) __noreturn __printf(1,2); | ||
| 141 | extern void die_errno(const char *fmt, ...) __noreturn __printf(1,2); | ||
| 142 | diff --git a/src/iptraf.c b/src/iptraf.c | ||
| 143 | index 95f8e53..e5dcb64 100644 | ||
| 144 | --- a/src/iptraf.c | ||
| 145 | +++ b/src/iptraf.c | ||
| 146 | @@ -388,6 +388,15 @@ int main(int argc, char **argv) | ||
| 147 | if (__builtin_popcount(command) > 1) | ||
| 148 | die("only one of -i|-d|-s|-z|-l|-g options must be used"); | ||
| 149 | |||
| 150 | + /* sanity check of passed arguments */ | ||
| 151 | + if ((i_opt && strlen(i_opt) >= IFNAMSIZ) || | ||
| 152 | + (d_opt && strlen(d_opt) >= IFNAMSIZ) || | ||
| 153 | + (s_opt && strlen(s_opt) >= IFNAMSIZ) || | ||
| 154 | + (z_opt && strlen(z_opt) >= IFNAMSIZ) || | ||
| 155 | + (l_opt && strlen(l_opt) >= IFNAMSIZ)) { | ||
| 156 | + die("interface name is too long"); | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | strcpy(current_logfile, ""); | ||
| 160 | |||
| 161 | if (f_opt) { | ||
| 162 | diff --git a/src/othptab.c b/src/othptab.c | ||
| 163 | index d1d9658..80f3dc8 100644 | ||
| 164 | --- a/src/othptab.c | ||
| 165 | +++ b/src/othptab.c | ||
| 166 | @@ -271,7 +271,7 @@ struct othptabent *add_othp_entry(struct othptable *table, struct pkt_hdr *pkt, | ||
| 167 | } | ||
| 168 | |||
| 169 | new_entry->protocol = protocol; | ||
| 170 | - strcpy(new_entry->iface, ifname); | ||
| 171 | + ifname_copy(new_entry->iface, ifname); | ||
| 172 | |||
| 173 | new_entry->pkt_length = pkt->pkt_len; | ||
| 174 | |||
| 175 | diff --git a/src/promisc.c b/src/promisc.c | ||
| 176 | index d94e8bb..4737962 100644 | ||
| 177 | --- a/src/promisc.c | ||
| 178 | +++ b/src/promisc.c | ||
| 179 | @@ -70,7 +70,7 @@ static void promisc_enable_dev(struct list_head *promisc, int sock, const char * | ||
| 180 | struct promisc_list *new = xmallocz(sizeof(*new)); | ||
| 181 | |||
| 182 | new->ifindex = ifindex; | ||
| 183 | - strcpy(new->ifname, dev); | ||
| 184 | + ifname_copy(new->ifname, dev); | ||
| 185 | list_add_tail(&new->list, promisc); | ||
| 186 | } | ||
| 187 | |||
| 188 | diff --git a/src/tcptable.c b/src/tcptable.c | ||
| 189 | index 159d628..2c4efc1 100644 | ||
| 190 | --- a/src/tcptable.c | ||
| 191 | +++ b/src/tcptable.c | ||
| 192 | @@ -365,8 +365,8 @@ struct tcptableent *addentry(struct tcptable *table, | ||
| 193 | * Store interface name | ||
| 194 | */ | ||
| 195 | |||
| 196 | - strcpy(new_entry->ifname, ifname); | ||
| 197 | - strcpy(new_entry->oth_connection->ifname, ifname); | ||
| 198 | + ifname_copy(new_entry->ifname, ifname); | ||
| 199 | + ifname_copy(new_entry->oth_connection->ifname, ifname); | ||
| 200 | |||
| 201 | /* | ||
| 202 | * Zero out MAC address fields | ||
| 203 | diff --git a/src/wrapper.c b/src/wrapper.c | ||
| 204 | index 2eb3b59..1d2dc6f 100644 | ||
| 205 | --- a/src/wrapper.c | ||
| 206 | +++ b/src/wrapper.c | ||
| 207 | @@ -78,3 +78,11 @@ int strtol_i(char const *s, int base, int *result) | ||
| 208 | *result = ul; | ||
| 209 | return 0; | ||
| 210 | } | ||
| 211 | + | ||
| 212 | +/* it's up to the caller to ensure there is room for */ | ||
| 213 | +/* at least IFNAMSIZ bytes in dst */ | ||
| 214 | +void ifname_copy(char *dst, const char *src) | ||
| 215 | +{ | ||
| 216 | + strncpy(dst, src, IFNAMSIZ - 1); | ||
| 217 | + dst[IFNAMSIZ - 1] = '\0'; | ||
| 218 | +} | ||
diff --git a/meta-oe/recipes-devtools/iptraf/iptraf-ng_1.2.1.bb b/meta-oe/recipes-devtools/iptraf/iptraf-ng_1.2.1.bb index 0f6bbb4d54..a622621990 100644 --- a/meta-oe/recipes-devtools/iptraf/iptraf-ng_1.2.1.bb +++ b/meta-oe/recipes-devtools/iptraf/iptraf-ng_1.2.1.bb | |||
| @@ -28,6 +28,7 @@ SRC_URI = "https://src.fedoraproject.org/repo/pkgs/iptraf-ng/v${PV}.tar.gz/sha51 | |||
| 28 | file://iptraf-ng-tmpfiles.conf \ | 28 | file://iptraf-ng-tmpfiles.conf \ |
| 29 | file://ncurses-config.patch \ | 29 | file://ncurses-config.patch \ |
| 30 | file://0001-make-Make-CC-weak-assignment.patch \ | 30 | file://0001-make-Make-CC-weak-assignment.patch \ |
| 31 | file://CVE-2024-52949.patch \ | ||
| 31 | " | 32 | " |
| 32 | SRC_URI[sha256sum] = "9f5cef584065420dea1ba32c86126aede1fa9bd25b0f8362b0f9fd9754f00870" | 33 | SRC_URI[sha256sum] = "9f5cef584065420dea1ba32c86126aede1fa9bd25b0f8362b0f9fd9754f00870" |
| 33 | 34 | ||
