wok-current rev 25585
Fix linux build with gcc > 6
author | Stanislas Leduc <shann@slitaz.org> |
---|---|
date | Thu May 25 15:49:26 2023 +0000 (18 months ago) |
parents | 4b92affc463d |
children | d93a872413c7 |
files | linux/receipt linux/stuff/linux-with-gcc8.patch |
line diff
1.1 --- a/linux/receipt Thu May 25 10:56:33 2023 +0000 1.2 +++ b/linux/receipt Thu May 25 15:49:26 2023 +0000 1.3 @@ -234,7 +234,10 @@ 1.4 aufs3-loopback.patch 1.5 aufs3-mmap.patch 1.6 EOT 1.7 - 1.8 + 1.9 + # Patch for GCC > 6.x 1.10 + patch -p1 < $stuff/linux-with-gcc8.patch 1.11 + 1.12 # Mrproper and lguest 1.13 echo "Make kernel proper and then build lguest..." 1.14 make mrproper
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/linux/stuff/linux-with-gcc8.patch Thu May 25 15:49:26 2023 +0000 2.3 @@ -0,0 +1,101 @@ 2.4 +Upstream commit e5dfa3f902b9 ("usbip: Fix potential format overflow in 2.5 +userspace tools") 2.6 + 2.7 + 2.8 +The usbip userspace tools call sprintf()/snprintf() and don't check for 2.9 +the return value which can lead the paths to overflow, truncating the 2.10 +final file in the path. 2.11 + 2.12 +More urgently, GCC 7 now warns that these aren't checked with 2.13 +-Wformat-overflow, and with -Werror enabled in configure.ac, that makes 2.14 +these tools unbuildable. 2.15 + 2.16 +This patch fixes these problems by replacing sprintf() with snprintf() in 2.17 +one place and adding checks for the return value of snprintf(). 2.18 + 2.19 +Reviewed-by: Peter Senna Tschudin <peter.se...@gmail.com> 2.20 +Signed-off-by: Jonathan Dieter <jdie...@lesbg.com> 2.21 +Acked-by: Shuah Khan <shua...@osg.samsung.com> 2.22 +Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org> 2.23 +Signed-off-by: Shuah Khan <shua...@osg.samsung.com> 2.24 + 2.25 +diff --git a/tools/usb/usbip/libsrc/usbip_common.c b/tools/usb/usbip/libsrc/usbip_common.c 2.26 +index ac73710..01dd4b2 100644 2.27 +--- a/drivers/staging/usbip/userspace/libsrc/usbip_common.c 2.28 ++++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.c 2.29 +@@ -215,9 +215,15 @@ 2.30 + struct usbip_usb_interface *uinf) 2.31 + { 2.32 + char busid[SYSFS_BUS_ID_SIZE]; 2.33 ++ unsigned int size; 2.34 + struct udev_device *sif; 2.35 + 2.36 +- sprintf(busid, "%s:%d.%d", udev->busid, udev->bConfigurationValue, i); 2.37 ++ size = snprintf(busid, sizeof(busid), "%s:%d.%d", 2.38 ++ udev->busid, udev->bConfigurationValue, i); 2.39 ++ if (size >= sizeof(busid)) { 2.40 ++ err("busid length %u >= %lu", size, sizeof(busid)); 2.41 ++ return -1; 2.42 ++ } 2.43 + 2.44 + sif = udev_device_new_from_subsystem_sysname(udev_context, "usb", busid); 2.45 + if (!sif) { 2.46 +diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c 2.47 +b/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c 2.48 +index 9d415228883d..c10379439668 100644 2.49 +--- a/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c 2.50 ++++ b/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c 2.51 +@@ -39,13 +39,19 @@ 2.52 + static int32_t read_attr_usbip_status(struct usbip_usb_device *udev) 2.53 + { 2.54 + char status_attr_path[SYSFS_PATH_MAX]; 2.55 ++ unsigned int size; 2.56 + int fd; 2.57 + int length; 2.58 + char status; 2.59 + int value = 0; 2.60 + 2.61 +- snprintf(status_attr_path, SYSFS_PATH_MAX, "%s/usbip_status", 2.62 +- udev->path); 2.63 ++ size = snprintf(status_attr_path, sizeof(status_attr_path), 2.64 ++ "%s/usbip_status", udev->path); 2.65 ++ if (size >= sizeof(status_attr_path)) { 2.66 ++ err("usbip_status path length %u >= %lu", size, 2.67 ++ sizeof(status_attr_path)); 2.68 ++ return -1; 2.69 ++ } 2.70 + 2.71 + if ((fd = open(status_attr_path, O_RDONLY)) < 0) { 2.72 + err("error opening attribute %s", status_attr_path); 2.73 +@@ -224,6 +230,7 @@ 2.74 + { 2.75 + char attr_name[] = "usbip_sockfd"; 2.76 + char sockfd_attr_path[SYSFS_PATH_MAX]; 2.77 ++ unsigned int size; 2.78 + char sockfd_buff[30]; 2.79 + int ret; 2.80 + 2.81 +@@ -243,10 +250,19 @@ 2.82 + } 2.83 + 2.84 + /* only the first interface is true */ 2.85 +- snprintf(sockfd_attr_path, sizeof(sockfd_attr_path), "%s/%s", 2.86 ++ size = snprintf(sockfd_attr_path, sizeof(sockfd_attr_path), "%s/%s", 2.87 + edev->udev.path, attr_name); 2.88 ++ if (size >= sizeof(sockfd_attr_path)) { 2.89 ++ err("exported device path length %u >= %lu", size, 2.90 ++ sizeof(sockfd_attr_path)); 2.91 ++ return -1; 2.92 ++ } 2.93 + 2.94 +- snprintf(sockfd_buff, sizeof(sockfd_buff), "%d\n", sockfd); 2.95 ++ size = snprintf(sockfd_buff, sizeof(sockfd_buff), "%d\n", sockfd); 2.96 ++ if (size >= sizeof(sockfd_buff)) { 2.97 ++ err("socket length %u >= %lu", size, sizeof(sockfd_buff)); 2.98 ++ return -1; 2.99 ++ } 2.100 + 2.101 + ret = write_sysfs_attribute(sockfd_attr_path, sockfd_buff, 2.102 + strlen(sockfd_buff)); 2.103 +-- 2.104 +2.14.1