wok-current rev 25586
Fix linux build with gcc > 6 again
author | Stanislas Leduc <shann@slitaz.org> |
---|---|
date | Mon May 29 12:23:26 2023 +0000 (19 months ago) |
parents | a58264a81dff |
children | 9a8523e9619e |
files | linux/receipt linux/stuff/linux-fix-format-overflow-gcc8.patch linux/stuff/linux-fix-noreturn-attributes-gcc8.patch linux/stuff/linux-usbip-fix-format-overflow-gcc8.patch linux/stuff/linux-usbip-fix-implicit-fallthrough-gcc8.patch linux/stuff/linux-with-gcc8.patch ncursesw-dev/receipt |
line diff
1.1 --- a/linux/receipt Thu May 25 15:49:26 2023 +0000 1.2 +++ b/linux/receipt Mon May 29 12:23:26 2023 +0000 1.3 @@ -235,8 +235,13 @@ 1.4 aufs3-mmap.patch 1.5 EOT 1.6 1.7 - # Patch for GCC > 6.x 1.8 - patch -p1 < $stuff/linux-with-gcc8.patch 1.9 + # Patch for GCC > 6.x 1.10 + # usbip (format overflow / implicit-fallthrough) 1.11 + # kernel (format overflow) 1.12 + patch -p1 < $stuff/linux-usbip-fix-format-overflow-gcc8.patch 1.13 + patch -p1 < $stuff/linux-usbip-fix-implicit-fallthrough-gcc8.patch 1.14 + patch -p1 < $stuff/linux-fix-format-overflow-gcc8.patch 1.15 + patch -p1 < $stuff/linux-fix-noreturn-attributes-gcc8.patch 1.16 1.17 # Mrproper and lguest 1.18 echo "Make kernel proper and then build lguest..."
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/linux/stuff/linux-fix-format-overflow-gcc8.patch Mon May 29 12:23:26 2023 +0000 2.3 @@ -0,0 +1,13 @@ 2.4 +diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c 2.5 +index 5f87ad561b08..39e20974f4a3 100644 2.6 +--- a/scripts/kconfig/confdata.c 2.7 ++++ b/scripts/kconfig/confdata.c 2.8 +@@ -720,7 +720,7 @@ int conf_write(const char *name) 2.9 + struct menu *menu; 2.10 + const char *basename; 2.11 + const char *str; 2.12 +- char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1]; 2.13 ++ char dirname[PATH_MAX+1], tmpname[PATH_MAX+22], newname[PATH_MAX+8]; 2.14 + char *env; 2.15 + 2.16 + dirname[0] = 0;
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/linux/stuff/linux-fix-noreturn-attributes-gcc8.patch Mon May 29 12:23:26 2023 +0000 3.3 @@ -0,0 +1,77 @@ 3.4 +gcc-7 has an "optimization" pass that completely screws up, and 3.5 +generates the code expansion for the (impossible) case of calling 3.6 +ilog2() with a zero constant, even when the code gcc compiles does not 3.7 +actually have a zero constant. 3.8 + 3.9 +And we try to generate a compile-time error for anybody doing ilog2() on 3.10 +a constant where that doesn't make sense (be it zero or negative). So 3.11 +now gcc7 will fail the build due to our sanity checking, because it 3.12 +created that constant-zero case that didn't actually exist in the source 3.13 +code. 3.14 + 3.15 +There's a whole long discussion on the kernel mailing about how to work 3.16 +around this gcc bug. The gcc people themselevs have discussed their 3.17 +"feature" in 3.18 + 3.19 + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72785 3.20 + 3.21 +but it's all water under the bridge, because while it looked at one 3.22 +point like it would be solved by the time gcc7 was released, that was 3.23 +not to be. 3.24 + 3.25 +So now we have to deal with this compiler braindamage. 3.26 + 3.27 +And the only simple approach seems to be to just delete the code that 3.28 +tries to warn about bad uses of ilog2(). 3.29 + 3.30 +So now "ilog2()" will just return 0 not just for the value 1, but for 3.31 +any non-positive value too. 3.32 + 3.33 +It's not like I can recall anybody having ever actually tried to use 3.34 +this function on any invalid value, but maybe the sanity check just 3.35 +meant that such code never made it out in public. 3.36 + 3.37 +Reported-by: Laura Abbott <labbott@redhat.com> 3.38 +Cc: John Stultz <john.stultz@linaro.org>, 3.39 +Cc: Thomas Gleixner <tglx@linutronix.de> 3.40 +Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> 3.41 +Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> 3.42 + 3.43 +diff --git a/include/linux/log2.h b/include/linux/log2.h 3.44 +index ef3d4f67118ce..c373295f359fa 100644 3.45 +--- a/include/linux/log2.h 3.46 ++++ b/include/linux/log2.h 3.47 +@@ -16,12 +16,6 @@ 3.48 + #include <linux/bitops.h> 3.49 + 3.50 + /* 3.51 +- * deal with unrepresentable constant logarithms 3.52 +- */ 3.53 +-extern __attribute__((const, noreturn)) 3.54 +-int ____ilog2_NaN(void); 3.55 +- 3.56 +-/* 3.57 + * non-constant log of base 2 calculators 3.58 + * - the arch may override these in asm/bitops.h if they can be implemented 3.59 + * more efficiently than using fls() and fls64() 3.60 +@@ -85,7 +79,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n) 3.61 + #define ilog2(n) \ 3.62 + ( \ 3.63 + __builtin_constant_p(n) ? ( \ 3.64 +- (n) < 1 ? ____ilog2_NaN() : \ 3.65 ++ (n) < 2 ? 0 : \ 3.66 + (n) & (1ULL << 63) ? 63 : \ 3.67 + (n) & (1ULL << 62) ? 62 : \ 3.68 + (n) & (1ULL << 61) ? 61 : \ 3.69 +@@ -148,10 +142,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n) 3.70 + (n) & (1ULL << 4) ? 4 : \ 3.71 + (n) & (1ULL << 3) ? 3 : \ 3.72 + (n) & (1ULL << 2) ? 2 : \ 3.73 +- (n) & (1ULL << 1) ? 1 : \ 3.74 +- (n) & (1ULL << 0) ? 0 : \ 3.75 +- ____ilog2_NaN() \ 3.76 +- ) : \ 3.77 ++ 1 ) : \ 3.78 + (sizeof(n) <= 4) ? \ 3.79 + __ilog2_u32(n) : \ 3.80 + __ilog2_u64(n) \
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/linux/stuff/linux-usbip-fix-format-overflow-gcc8.patch Mon May 29 12:23:26 2023 +0000 4.3 @@ -0,0 +1,103 @@ 4.4 +Upstream commit e5dfa3f902b9 ("usbip: Fix potential format overflow in 4.5 +userspace tools") 4.6 + 4.7 + 4.8 +The usbip userspace tools call sprintf()/snprintf() and don't check for 4.9 +the return value which can lead the paths to overflow, truncating the 4.10 +final file in the path. 4.11 + 4.12 +More urgently, GCC 7 now warns that these aren't checked with 4.13 +-Wformat-overflow, and with -Werror enabled in configure.ac, that makes 4.14 +these tools unbuildable. 4.15 + 4.16 +This patch fixes these problems by replacing sprintf() with snprintf() in 4.17 +one place and adding checks for the return value of snprintf(). 4.18 + 4.19 +Reviewed-by: Peter Senna Tschudin <peter.se...@gmail.com> 4.20 +Signed-off-by: Jonathan Dieter <jdie...@lesbg.com> 4.21 +Acked-by: Shuah Khan <shua...@osg.samsung.com> 4.22 +Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org> 4.23 +Signed-off-by: Shuah Khan <shua...@osg.samsung.com> 4.24 + 4.25 +diff --git a/tools/usb/usbip/libsrc/usbip_common.c b/tools/usb/usbip/libsrc/usbip_common.c 4.26 +index ac73710..01dd4b2 100644 4.27 +--- a/drivers/staging/usbip/userspace/libsrc/usbip_common.c 4.28 ++++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.c 4.29 +@@ -215,9 +215,16 @@ 4.30 + struct usbip_usb_interface *uinf) 4.31 + { 4.32 + char busid[SYSFS_BUS_ID_SIZE]; 4.33 ++ int size; 4.34 + struct udev_device *sif; 4.35 + 4.36 +- sprintf(busid, "%s:%d.%d", udev->busid, udev->bConfigurationValue, i); 4.37 ++ size = snprintf(busid, sizeof(busid), "%s:%d.%d", 4.38 ++ udev->busid, udev->bConfigurationValue, i); 4.39 ++ if (size < 0 || (unsigned int)size >= sizeof(busid)) { 4.40 ++ err("busid length %i >= %lu or < 0", size, 4.41 ++ (unsigned long)sizeof(busid)); 4.42 ++ return -1; 4.43 ++ } 4.44 + 4.45 + sif = udev_device_new_from_subsystem_sysname(udev_context, "usb", busid); 4.46 + if (!sif) { 4.47 +diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c 4.48 +b/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c 4.49 +index 9d415228883d..c10379439668 100644 4.50 +--- a/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c 4.51 ++++ b/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c 4.52 +@@ -39,13 +39,19 @@ 4.53 + static int32_t read_attr_usbip_status(struct usbip_usb_device *udev) 4.54 + { 4.55 + char status_attr_path[SYSFS_PATH_MAX]; 4.56 ++ int size; 4.57 + int fd; 4.58 + int length; 4.59 + char status; 4.60 + int value = 0; 4.61 + 4.62 +- snprintf(status_attr_path, SYSFS_PATH_MAX, "%s/usbip_status", 4.63 +- udev->path); 4.64 ++ size = snprintf(status_attr_path, sizeof(status_attr_path), 4.65 ++ "%s/usbip_status", udev->path); 4.66 ++ if (size < 0 || (unsigned int)size >= sizeof(status_attr_path)) { 4.67 ++ err("usbip_status path length %i >= %lu or < 0", size, 4.68 ++ (unsigned long)sizeof(status_attr_path)); 4.69 ++ return -1; 4.70 ++ } 4.71 + 4.72 + if ((fd = open(status_attr_path, O_RDONLY)) < 0) { 4.73 + err("error opening attribute %s", status_attr_path); 4.74 +@@ -224,6 +230,7 @@ 4.75 + { 4.76 + char attr_name[] = "usbip_sockfd"; 4.77 + char sockfd_attr_path[SYSFS_PATH_MAX]; 4.78 ++ int size; 4.79 + char sockfd_buff[30]; 4.80 + int ret; 4.81 + 4.82 +@@ -244,10 +251,20 @@ 4.83 + } 4.84 + 4.85 + /* only the first interface is true */ 4.86 +- snprintf(sockfd_attr_path, sizeof(sockfd_attr_path), "%s/%s", 4.87 ++ size = snprintf(sockfd_attr_path, sizeof(sockfd_attr_path), "%s/%s", 4.88 + edev->udev.path, attr_name); 4.89 ++ if (size < 0 || (unsigned int)size >= sizeof(sockfd_attr_path)) { 4.90 ++ err("exported device path length %i >= %lu or < 0", size, 4.91 ++ (unsigned long)sizeof(sockfd_attr_path)); 4.92 ++ return -1; 4.93 ++ } 4.94 + 4.95 +- snprintf(sockfd_buff, sizeof(sockfd_buff), "%d\n", sockfd); 4.96 ++ size = snprintf(sockfd_buff, sizeof(sockfd_buff), "%d\n", sockfd); 4.97 ++ if (size < 0 || (unsigned int)size >= sizeof(sockfd_buff)) { 4.98 ++ err("socket length %i >= %lu or < 0", size, 4.99 ++ (unsigned long)sizeof(sockfd_buff)); 4.100 ++ return -1; 4.101 ++ } 4.102 + 4.103 + ret = write_sysfs_attribute(sockfd_attr_path, sockfd_buff, 4.104 + strlen(sockfd_buff)); 4.105 +-- 4.106 +2.14.1
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/linux/stuff/linux-usbip-fix-implicit-fallthrough-gcc8.patch Mon May 29 12:23:26 2023 +0000 5.3 @@ -0,0 +1,25 @@ 5.4 +GCC 7 now warns when switch statements fall through implicitly, and with 5.5 +-Werror enabled in configure.ac, that makes these tools unbuildable. 5.6 + 5.7 +We fix this by notifying the compiler that this particular case statement 5.8 +is meant to fall through. 5.9 + 5.10 +Reviewed-by: Peter Senna Tschudin <peter.senna@xxxxxxxxx> 5.11 +Signed-off-by: Jonathan Dieter <jdieter@xxxxxxxxx> 5.12 +--- 5.13 + tools/usb/usbip/src/usbip.c | 2 ++ 5.14 + 1 file changed, 2 insertions(+) 5.15 + 5.16 +diff --git a/tools/usb/usbip/src/usbip.c b/tools/usb/usbip/src/usbip.c 5.17 +index d7599d9..73d8eee 100644 5.18 +--- a/drivers/staging/usbip/userspace/src/usbip.c 5.19 ++++ b/drivers/staging/usbip/userspace/src/usbip.c 5.20 +@@ -176,6 +176,8 @@ int main(int argc, char *argv[]) 5.21 + break; 5.22 + case '?': 5.23 + printf("usbip: invalid option\n"); 5.24 ++ /* Terminate after printing error */ 5.25 ++ /* FALLTHRU */ 5.26 + default: 5.27 + usbip_usage(); 5.28 + goto out;
6.1 --- a/linux/stuff/linux-with-gcc8.patch Thu May 25 15:49:26 2023 +0000 6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 6.3 @@ -1,101 +0,0 @@ 6.4 -Upstream commit e5dfa3f902b9 ("usbip: Fix potential format overflow in 6.5 -userspace tools") 6.6 - 6.7 - 6.8 -The usbip userspace tools call sprintf()/snprintf() and don't check for 6.9 -the return value which can lead the paths to overflow, truncating the 6.10 -final file in the path. 6.11 - 6.12 -More urgently, GCC 7 now warns that these aren't checked with 6.13 --Wformat-overflow, and with -Werror enabled in configure.ac, that makes 6.14 -these tools unbuildable. 6.15 - 6.16 -This patch fixes these problems by replacing sprintf() with snprintf() in 6.17 -one place and adding checks for the return value of snprintf(). 6.18 - 6.19 -Reviewed-by: Peter Senna Tschudin <peter.se...@gmail.com> 6.20 -Signed-off-by: Jonathan Dieter <jdie...@lesbg.com> 6.21 -Acked-by: Shuah Khan <shua...@osg.samsung.com> 6.22 -Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org> 6.23 -Signed-off-by: Shuah Khan <shua...@osg.samsung.com> 6.24 - 6.25 -diff --git a/tools/usb/usbip/libsrc/usbip_common.c b/tools/usb/usbip/libsrc/usbip_common.c 6.26 -index ac73710..01dd4b2 100644 6.27 ---- a/drivers/staging/usbip/userspace/libsrc/usbip_common.c 6.28 -+++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.c 6.29 -@@ -215,9 +215,15 @@ 6.30 - struct usbip_usb_interface *uinf) 6.31 - { 6.32 - char busid[SYSFS_BUS_ID_SIZE]; 6.33 -+ unsigned int size; 6.34 - struct udev_device *sif; 6.35 - 6.36 -- sprintf(busid, "%s:%d.%d", udev->busid, udev->bConfigurationValue, i); 6.37 -+ size = snprintf(busid, sizeof(busid), "%s:%d.%d", 6.38 -+ udev->busid, udev->bConfigurationValue, i); 6.39 -+ if (size >= sizeof(busid)) { 6.40 -+ err("busid length %u >= %lu", size, sizeof(busid)); 6.41 -+ return -1; 6.42 -+ } 6.43 - 6.44 - sif = udev_device_new_from_subsystem_sysname(udev_context, "usb", busid); 6.45 - if (!sif) { 6.46 -diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c 6.47 -b/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c 6.48 -index 9d415228883d..c10379439668 100644 6.49 ---- a/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c 6.50 -+++ b/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c 6.51 -@@ -39,13 +39,19 @@ 6.52 - static int32_t read_attr_usbip_status(struct usbip_usb_device *udev) 6.53 - { 6.54 - char status_attr_path[SYSFS_PATH_MAX]; 6.55 -+ unsigned int size; 6.56 - int fd; 6.57 - int length; 6.58 - char status; 6.59 - int value = 0; 6.60 - 6.61 -- snprintf(status_attr_path, SYSFS_PATH_MAX, "%s/usbip_status", 6.62 -- udev->path); 6.63 -+ size = snprintf(status_attr_path, sizeof(status_attr_path), 6.64 -+ "%s/usbip_status", udev->path); 6.65 -+ if (size >= sizeof(status_attr_path)) { 6.66 -+ err("usbip_status path length %u >= %lu", size, 6.67 -+ sizeof(status_attr_path)); 6.68 -+ return -1; 6.69 -+ } 6.70 - 6.71 - if ((fd = open(status_attr_path, O_RDONLY)) < 0) { 6.72 - err("error opening attribute %s", status_attr_path); 6.73 -@@ -224,6 +230,7 @@ 6.74 - { 6.75 - char attr_name[] = "usbip_sockfd"; 6.76 - char sockfd_attr_path[SYSFS_PATH_MAX]; 6.77 -+ unsigned int size; 6.78 - char sockfd_buff[30]; 6.79 - int ret; 6.80 - 6.81 -@@ -243,10 +250,19 @@ 6.82 - } 6.83 - 6.84 - /* only the first interface is true */ 6.85 -- snprintf(sockfd_attr_path, sizeof(sockfd_attr_path), "%s/%s", 6.86 -+ size = snprintf(sockfd_attr_path, sizeof(sockfd_attr_path), "%s/%s", 6.87 - edev->udev.path, attr_name); 6.88 -+ if (size >= sizeof(sockfd_attr_path)) { 6.89 -+ err("exported device path length %u >= %lu", size, 6.90 -+ sizeof(sockfd_attr_path)); 6.91 -+ return -1; 6.92 -+ } 6.93 - 6.94 -- snprintf(sockfd_buff, sizeof(sockfd_buff), "%d\n", sockfd); 6.95 -+ size = snprintf(sockfd_buff, sizeof(sockfd_buff), "%d\n", sockfd); 6.96 -+ if (size >= sizeof(sockfd_buff)) { 6.97 -+ err("socket length %u >= %lu", size, sizeof(sockfd_buff)); 6.98 -+ return -1; 6.99 -+ } 6.100 - 6.101 - ret = write_sysfs_attribute(sockfd_attr_path, sockfd_buff, 6.102 - strlen(sockfd_buff)); 6.103 --- 6.104 -2.14.1
7.1 --- a/ncursesw-dev/receipt Thu May 25 15:49:26 2023 +0000 7.2 +++ b/ncursesw-dev/receipt Mon May 29 12:23:26 2023 +0000 7.3 @@ -25,5 +25,5 @@ 7.4 # nicely for both. 7.5 cp -a $install/usr/include $fs/usr 7.6 cp $install/usr/bin/ncursesw6-config $fs/usr/bin 7.7 - cp -a $install/usr/share/pkgconfig $fs/usr/lib 7.8 + cp -a $install/usr/lib/pkgconfig $fs/usr/lib 7.9 }