Update to 4.14.11 (Fixes bug #1533864)

Signed-off-by: Jonathan Dieter <jdieter@lesbg.com>
f38
Jonathan Dieter 7 years ago
parent d4bd705498
commit fd77ca35a9

1
.gitignore vendored

@ -2,3 +2,4 @@
/usbip-3.18.tar.xz
/usbip-4.5.tar.xz
/usbip-4.9.9.tar.xz
/usbip-4.14.11.tar.xz

@ -1,108 +0,0 @@
From cd2517f4b56e7147d013c7030e09d2c2e3562f2a Mon Sep 17 00:00:00 2001
From: Jonathan Dieter <jdieter@lesbg.com>
Date: Mon, 27 Feb 2017 10:04:29 +0200
Subject: [PATCH v4 1/2] usbip: Fix-format-overflow
The usbip userspace tools call sprintf()/snprintf() and don't check for
the return value which can lead the paths to overflow, truncating the
final file in the path.
More urgently, GCC 7 now warns that these aren't checked with
-Wformat-overflow, and with -Werror enabled in configure.ac, that makes
these tools unbuildable.
This patch fixes these problems by replacing sprintf() with snprintf() in
one place and adding checks for the return value of snprintf().
Reviewed-by: Peter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: Jonathan Dieter <jdieter@lesbg.com>
---
tools/usb/usbip/libsrc/usbip_common.c | 9 ++++++++-
tools/usb/usbip/libsrc/usbip_host_common.c | 28 +++++++++++++++++++++++-----
2 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/tools/usb/usbip/libsrc/usbip_common.c b/tools/usb/usbip/libsrc/usbip_common.c
index ac73710..1517a23 100644
--- a/tools/usb/usbip/libsrc/usbip_common.c
+++ b/tools/usb/usbip/libsrc/usbip_common.c
@@ -215,9 +215,16 @@ int read_usb_interface(struct usbip_usb_device *udev, int i,
struct usbip_usb_interface *uinf)
{
char busid[SYSFS_BUS_ID_SIZE];
+ int size;
struct udev_device *sif;
- sprintf(busid, "%s:%d.%d", udev->busid, udev->bConfigurationValue, i);
+ size = snprintf(busid, sizeof(busid), "%s:%d.%d",
+ udev->busid, udev->bConfigurationValue, i);
+ if (size < 0 || (unsigned int)size >= sizeof(busid)) {
+ err("busid length %i >= %lu or < 0", size,
+ (long unsigned)sizeof(busid));
+ return -1;
+ }
sif = udev_device_new_from_subsystem_sysname(udev_context, "usb", busid);
if (!sif) {
diff --git a/tools/usb/usbip/libsrc/usbip_host_common.c b/tools/usb/usbip/libsrc/usbip_host_common.c
index 9d41522..6ff7b60 100644
--- a/tools/usb/usbip/libsrc/usbip_host_common.c
+++ b/tools/usb/usbip/libsrc/usbip_host_common.c
@@ -40,13 +40,20 @@ struct udev *udev_context;
static int32_t read_attr_usbip_status(struct usbip_usb_device *udev)
{
char status_attr_path[SYSFS_PATH_MAX];
+ int size;
int fd;
int length;
char status;
int value = 0;
- snprintf(status_attr_path, SYSFS_PATH_MAX, "%s/usbip_status",
- udev->path);
+ size = snprintf(status_attr_path, sizeof(status_attr_path),
+ "%s/usbip_status", udev->path);
+ if (size < 0 || (unsigned int)size >= sizeof(status_attr_path)) {
+ err("usbip_status path length %i >= %lu or < 0", size,
+ (long unsigned)sizeof(status_attr_path));
+ return -1;
+ }
+
fd = open(status_attr_path, O_RDONLY);
if (fd < 0) {
@@ -218,6 +225,7 @@ int usbip_export_device(struct usbip_exported_device *edev, int sockfd)
{
char attr_name[] = "usbip_sockfd";
char sockfd_attr_path[SYSFS_PATH_MAX];
+ int size;
char sockfd_buff[30];
int ret;
@@ -237,10 +245,20 @@ int usbip_export_device(struct usbip_exported_device *edev, int sockfd)
}
/* only the first interface is true */
- snprintf(sockfd_attr_path, sizeof(sockfd_attr_path), "%s/%s",
- edev->udev.path, attr_name);
+ size = snprintf(sockfd_attr_path, sizeof(sockfd_attr_path), "%s/%s",
+ edev->udev.path, attr_name);
+ if (size < 0 || (unsigned int)size >= sizeof(sockfd_attr_path)) {
+ err("exported device path length %i >= %lu or < 0", size,
+ (long unsigned)sizeof(sockfd_attr_path));
+ return -1;
+ }
- snprintf(sockfd_buff, sizeof(sockfd_buff), "%d\n", sockfd);
+ size = snprintf(sockfd_buff, sizeof(sockfd_buff), "%d\n", sockfd);
+ if (size < 0 || (unsigned int)size >= sizeof(sockfd_buff)) {
+ err("socket length %i >= %lu or < 0", size,
+ (long unsigned)sizeof(sockfd_buff));
+ return -1;
+ }
ret = write_sysfs_attribute(sockfd_attr_path, sockfd_buff,
strlen(sockfd_buff));
--
2.9.3

@ -1,33 +0,0 @@
From b1cabcfde670c82aff0ef07c21095d63c29cbf3e Mon Sep 17 00:00:00 2001
From: Jonathan Dieter <jdieter@lesbg.com>
Date: Mon, 27 Feb 2017 10:13:01 +0200
Subject: [PATCH v4 2/2] usbip: Fix implicit fallthrough warning
GCC 7 now warns when switch statements fall through implicitly, and with
-Werror enabled in configure.ac, that makes these tools unbuildable.
We fix this by notifying the compiler that this particular case statement
is meant to fall through.
Reviewed-by: Peter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: Jonathan Dieter <jdieter@lesbg.com>
---
tools/usb/usbip/src/usbip.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/usb/usbip/src/usbip.c b/tools/usb/usbip/src/usbip.c
index d7599d9..73d8eee 100644
--- a/tools/usb/usbip/src/usbip.c
+++ b/tools/usb/usbip/src/usbip.c
@@ -176,6 +176,8 @@ int main(int argc, char *argv[])
break;
case '?':
printf("usbip: invalid option\n");
+ /* Terminate after printing error */
+ /* FALLTHRU */
default:
usbip_usage();
goto out;
--
2.9.3

@ -1 +1 @@
SHA512 (usbip-4.9.9.tar.xz) = 0cf4b2384a42ad3c0242d73e11e0830943b31f6c95a5f7a75f730084a291f994fcc7370c9ed70580218ecadda221c6d636c68f4b41d224847e1f1c82adcafb84
SHA512 (usbip-4.14.11.tar.xz) = 9572ee6a9e0eef4accca33f6596dd11645c6ba072c070be9dccf21b03a51813f9c75b1294e817f99b6085da92edaf2a295be4219c8dce16bbc8b5c35ca786720

@ -4,9 +4,9 @@ Name: usbip
License: GPLv2+
Summary: USB/IP user-space
Group: System Environment/Daemons
Version: 4.9.9
Release: 6%{?dist}
#Source: https://www.kernel.org/pub/linux/kernel/v3.x/linux-%%{version}.tar.xz
Version: 4.14.11
Release: 1%{?dist}
#Source: https://www.kernel.org/pub/linux/kernel/v4.x/linux-%%{version}.tar.xz
# In the interests of keeping the source rpm from being ridiculously large,
# download the Linux kernel from above and run `extract_usbip.sh <version>`
# in the SOURCE directory.
@ -21,8 +21,6 @@ Source99: extract_usbip.sh
# The following patches have been submitted to the LKML (see the thread
# starting at https://www.spinics.net/lists/kernel/msg2448891.html) and are
# still in the process of being reviewed.
Patch1: 0001-usbip-Fix-format-overflow.patch
Patch2: 0002-usbip-Fix-implicit-fallthrough-warning.patch
Requires: kmod(usbip-core.ko)
Requires: kmod(usbip-host.ko)
Requires: kmod(vhci-hcd.ko)
@ -57,8 +55,6 @@ development
%prep
%setup -q
%patch1 -p4
%patch2 -p4
%build
./autogen.sh
@ -97,6 +93,12 @@ install -pm 644 %{SOURCE2} %{buildroot}%{_unitdir}
%{_libdir}/*.so
%changelog
* Sat Jan 13 2018 Jonathan Dieter <jdieter@lesbg.com> - 4.14.11-1
- Update usbip to 4.14.11
* Fri Jan 12 2018 Zamir SUN <sztsian@gmail.com> - 4.14.0-1
- Update usbip to 4.14.0 (Fixes bug #1533864)
* Sat Aug 26 2017 Jonathan Dieter <jdieter@lesbg.com> - 4.9.9-6
- Exclude s390x because it doesn't support USB

Loading…
Cancel
Save