svn commit: r302275 - stable/10/lib/libusb

2016-06-29 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Jun 29 10:58:36 2016
New Revision: 302275
URL: https://svnweb.freebsd.org/changeset/base/302275

Log:
  MFC r301956, r301957, r301964, r301966, r301968, r301969, r302080,
  r302125 and r302171:
  
  Added multiple new LibUSB v1.0 API functions.
  Refer to the individual commits for more details.

Added:
  stable/10/lib/libusb/libusb10_hotplug.c
 - copied unchanged from r302080, head/lib/libusb/libusb10_hotplug.c
Modified:
  stable/10/lib/libusb/Makefile
  stable/10/lib/libusb/libusb.3
  stable/10/lib/libusb/libusb.h
  stable/10/lib/libusb/libusb10.c
  stable/10/lib/libusb/libusb10.h
  stable/10/lib/libusb/libusb10_desc.c
  stable/10/lib/libusb/libusb10_io.c
  stable/10/lib/libusb/libusb20.c
  stable/10/lib/libusb/libusb20_int.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libusb/Makefile
==
--- stable/10/lib/libusb/Makefile   Wed Jun 29 10:47:44 2016
(r302274)
+++ stable/10/lib/libusb/Makefile   Wed Jun 29 10:58:36 2016
(r302275)
@@ -32,6 +32,7 @@ SRCS+=libusb01.c
 INCS+= libusb.h
 SRCS+= libusb10.c
 SRCS+= libusb10_desc.c
+SRCS+= libusb10_hotplug.c
 SRCS+= libusb10_io.c
 
 .if defined(COMPAT_32BIT)
@@ -67,6 +68,7 @@ CFLAGS+=  -I ../../sys
 .include 
 
 # LibUSB v1.0
+MLINKS += libusb.3 libusb_get_version.3
 MLINKS += libusb.3 libusb_init.3
 MLINKS += libusb.3 libusb_exit.3
 MLINKS += libusb.3 libusb_strerror.3
@@ -75,6 +77,7 @@ MLINKS += libusb.3 libusb_set_debug.3
 MLINKS += libusb.3 libusb_get_device_list.3
 MLINKS += libusb.3 libusb_free_device_list.3
 MLINKS += libusb.3 libusb_get_bus_number.3
+MLINKS += libusb.3 libusb_get_port_number.3
 MLINKS += libusb.3 libusb_get_device_address.3
 MLINKS += libusb.3 libusb_get_device_speed.3
 MLINKS += libusb.3 libusb_get_max_packet_size.3
@@ -99,6 +102,7 @@ MLINKS += libusb.3 libusb_get_driver_np.
 MLINKS += libusb.3 libusb_detach_kernel_driver.3
 MLINKS += libusb.3 libusb_detach_kernel_driver_np.3
 MLINKS += libusb.3 libusb_attach_kernel_driver.3
+MLINKS += libusb.3 libusb_set_auto_detach_kernel_driver.3
 MLINKS += libusb.3 libusb_get_device_descriptor.3
 MLINKS += libusb.3 libusb_get_active_config_descriptor.3
 MLINKS += libusb.3 libusb_get_config_descriptor.3
@@ -108,10 +112,22 @@ MLINKS += libusb.3 libusb_get_string_des
 MLINKS += libusb.3 libusb_get_string_descriptor_ascii.3
 MLINKS += libusb.3 libusb_parse_ss_endpoint_comp.3
 MLINKS += libusb.3 libusb_free_ss_endpoint_comp.3
+MLINKS += libusb.3 libusb_get_ss_endpoint_companion_descriptor.3
+MLINKS += libusb.3 libusb_free_ss_endpoint_companion_descriptor.3
 MLINKS += libusb.3 libusb_parse_bos_descriptor.3
 MLINKS += libusb.3 libusb_free_bos_descriptor.3
+MLINKS += libusb.3 libusb_get_usb_2_0_extension_descriptor.3
+MLINKS += libusb.3 libusb_free_usb_2_0_extension_descriptor.3
+MLINKS += libusb.3 libusb_get_ss_usb_device_capability_descriptor.3
+MLINKS += libusb.3 libusb_free_ss_usb_device_capability_descriptor.3
+MLINKS += libusb.3 libusb_get_container_id_descriptor.3
+MLINKS += libusb.3 libusb_free_container_id_descriptor.3
+MLINKS += libusb.3 libusb_alloc_streams.3
+MLINKS += libusb.3 libusb_free_streams.3
 MLINKS += libusb.3 libusb_alloc_transfer.3
 MLINKS += libusb.3 libusb_free_transfer.3
+MLINKS += libusb.3 libusb_transfer_set_stream_id.3
+MLINKS += libusb.3 libusb_transfer_get_stream_id.3
 MLINKS += libusb.3 libusb_submit_transfer.3
 MLINKS += libusb.3 libusb_cancel_transfer.3
 MLINKS += libusb.3 libusb_control_transfer.3
@@ -133,6 +149,8 @@ MLINKS += libusb.3 libusb_handle_events_
 MLINKS += libusb.3 libusb_get_next_timeout.3
 MLINKS += libusb.3 libusb_set_pollfd_notifiers.3
 MLINKS += libusb.3 libusb_get_pollfds.3
+MLINKS += libusb.3 libusb_hotplug_register_callback.3
+MLINKS += libusb.3 libusb_hotplug_deregister_callback.3
 
 # LibUSB v0.1
 MLINKS += libusb.3 usb_open.3

Modified: stable/10/lib/libusb/libusb.3
==
--- stable/10/lib/libusb/libusb.3   Wed Jun 29 10:47:44 2016
(r302274)
+++ stable/10/lib/libusb/libusb.3   Wed Jun 29 10:58:36 2016
(r302275)
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 5, 2014
+.Dd June 23, 2016
 .Dt LIBUSB 3
 .Os
 .Sh NAME
@@ -43,6 +43,10 @@ The
 library contains interfaces for directly managing a usb device.
 The current implementation supports v1.0 of the libusb API.
 .Sh LIBRARY INITIALISATION / DEINITIALISATION
+.Ft "const struct libusb_version *"
+.Fn libusb_get_version "void"
+This function returns version information about LibUSB.
+.Pp
 .Ft int
 .Fn libusb_init libusb_context **ctx
 This function initialises libusb.
@@ -102,6 +106,12 @@ counter decremented once.
 Returns the number of the bus contained by the device
 .Fa dev .
 .Pp
+.Ft uint8_t
+.Fn libusb_get_port_number "libusb_device *dev"
+Returns the port number which the 

svn commit: r302272 - stable/10/lib/libusb

2016-06-29 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Jun 29 10:43:31 2016
New Revision: 302272
URL: https://svnweb.freebsd.org/changeset/base/302272

Log:
  MFC r301842:
  Implement code to stop all USB endpoints before executing a USB device
  reset command, alternate setting command or set configuration
  command. Else LibUSB v1.0 will not re-open the endpoints which the
  kernel closes and the USB application might wait infinitely for
  transfers to complete.

Modified:
  stable/10/lib/libusb/libusb10.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libusb/libusb10.c
==
--- stable/10/lib/libusb/libusb10.c Wed Jun 29 10:40:34 2016
(r302271)
+++ stable/10/lib/libusb/libusb10.c Wed Jun 29 10:43:31 2016
(r302272)
@@ -51,6 +51,8 @@
 #include "libusb.h"
 #include "libusb10.h"
 
+#defineLIBUSB_NUM_SW_ENDPOINTS (16 * 4)
+
 static pthread_mutex_t default_context_lock = PTHREAD_MUTEX_INITIALIZER;
 struct libusb_context *usbi_default_context = NULL;
 
@@ -442,7 +444,7 @@ libusb_open(libusb_device *dev, libusb_d
if (dev == NULL)
return (LIBUSB_ERROR_INVALID_PARAM);
 
-   err = libusb20_dev_open(pdev, 16 * 4 /* number of endpoints */ );
+   err = libusb20_dev_open(pdev, LIBUSB_NUM_SW_ENDPOINTS);
if (err) {
libusb_unref_device(dev);
return (LIBUSB_ERROR_NO_MEM);
@@ -1489,7 +1491,17 @@ libusb_cancel_transfer(struct libusb_tra
 UNEXPORTED void
 libusb10_cancel_all_transfer(libusb_device *dev)
 {
-   /* TODO */
+   struct libusb20_device *pdev = dev->os_priv;
+   unsigned x;
+
+   for (x = 0; x != LIBUSB_NUM_SW_ENDPOINTS; x++) {
+   struct libusb20_transfer *xfer;
+
+   xfer = libusb20_tr_get_pointer(pdev, x);
+   if (xfer == NULL)
+   continue;
+   libusb20_tr_close(xfer);
+   }
 }
 
 uint16_t
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r302271 - stable/10/sys/ofed/include/linux

2016-06-29 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Jun 29 10:40:34 2016
New Revision: 302271
URL: https://svnweb.freebsd.org/changeset/base/302271

Log:
  MFC r301544:
  Fallback to arc4rand() in the LinuxKPI when read_random() returns
  zero. This can happen for virtual machines.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/ofed/include/linux/etherdevice.h
  stable/10/sys/ofed/include/linux/random.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/ofed/include/linux/etherdevice.h
==
--- stable/10/sys/ofed/include/linux/etherdevice.h  Wed Jun 29 10:33:11 
2016(r302270)
+++ stable/10/sys/ofed/include/linux/etherdevice.h  Wed Jun 29 10:40:34 
2016(r302271)
@@ -137,7 +137,8 @@ eth_broadcast_addr(u8 *pa)
 static inline void
 random_ether_addr(u8 * dst)
 {
-   read_random(dst, 6);
+   if (read_random(dst, 6) == 0)
+   arc4rand(dst, 6, 0);
 
dst[0] &= 0xfe;
dst[0] |= 0x02;

Modified: stable/10/sys/ofed/include/linux/random.h
==
--- stable/10/sys/ofed/include/linux/random.h   Wed Jun 29 10:33:11 2016
(r302270)
+++ stable/10/sys/ofed/include/linux/random.h   Wed Jun 29 10:40:34 2016
(r302271)
@@ -2,7 +2,7 @@
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
  * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -31,11 +31,13 @@
 #define_LINUX_RANDOM_H_
 
 #include 
+#include 
 
 static inline void
 get_random_bytes(void *buf, int nbytes)
 {
-   read_random(buf, nbytes);
+   if (read_random(buf, nbytes) == 0)
+   arc4rand(buf, nbytes, 0);
 }
 
 #endif /* _LINUX_RANDOM_H_ */
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r302270 - in stable/10/sys/dev/mlx5: . mlx5_core mlx5_en

2016-06-29 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Jun 29 10:33:11 2016
New Revision: 302270
URL: https://svnweb.freebsd.org/changeset/base/302270

Log:
  MFC r301545:
  Add SR-IOV guest support to the mlx5en driver.
  
  This patch adds the missing pieces needed for device setup using the
  mlx5en driver inside a virtual machine which is providing hardware
  access through SR-IOV.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/mlx5/driver.h
  stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c
  stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c
  stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
  stable/10/sys/dev/mlx5/vport.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/mlx5/driver.h
==
--- stable/10/sys/dev/mlx5/driver.h Wed Jun 29 10:29:52 2016
(r302269)
+++ stable/10/sys/dev/mlx5/driver.h Wed Jun 29 10:33:11 2016
(r302270)
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c
==
--- stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c   Wed Jun 29 10:29:52 
2016(r302269)
+++ stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c   Wed Jun 29 10:33:11 
2016(r302270)
@@ -471,6 +471,241 @@ int mlx5_set_nic_vport_promisc(struct ml
return mlx5_modify_nic_vport_context(mdev, in, sizeof(in));
 }
 EXPORT_SYMBOL_GPL(mlx5_set_nic_vport_promisc);
+
+int mlx5_query_nic_vport_mac_list(struct mlx5_core_dev *dev,
+ u32 vport,
+ enum mlx5_list_type list_type,
+ u8 addr_list[][ETH_ALEN],
+ int *list_size)
+{
+   u32 in[MLX5_ST_SZ_DW(query_nic_vport_context_in)];
+   void *nic_vport_ctx;
+   int max_list_size;
+   int req_list_size;
+   u8 *mac_addr;
+   int out_sz;
+   void *out;
+   int err;
+   int i;
+
+   req_list_size = *list_size;
+
+   max_list_size = (list_type == MLX5_NIC_VPORT_LIST_TYPE_UC) ?
+   1 << MLX5_CAP_GEN_MAX(dev, log_max_current_uc_list) :
+   1 << MLX5_CAP_GEN_MAX(dev, log_max_current_mc_list);
+
+   if (req_list_size > max_list_size) {
+   mlx5_core_warn(dev, "Requested list size (%d) > (%d) 
max_list_size\n",
+  req_list_size, max_list_size);
+   req_list_size = max_list_size;
+   }
+
+   out_sz = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in) +
+req_list_size * MLX5_ST_SZ_BYTES(mac_address_layout);
+
+   memset(in, 0, sizeof(in));
+   out = kzalloc(out_sz, GFP_KERNEL);
+   if (!out)
+   return -ENOMEM;
+
+   MLX5_SET(query_nic_vport_context_in, in, opcode,
+MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT);
+   MLX5_SET(query_nic_vport_context_in, in, allowed_list_type, list_type);
+   MLX5_SET(query_nic_vport_context_in, in, vport_number, vport);
+
+   if (vport)
+   MLX5_SET(query_nic_vport_context_in, in, other_vport, 1);
+
+   err = mlx5_cmd_exec_check_status(dev, in, sizeof(in), out, out_sz);
+   if (err)
+   goto out;
+
+   nic_vport_ctx = MLX5_ADDR_OF(query_nic_vport_context_out, out,
+nic_vport_context);
+   req_list_size = MLX5_GET(nic_vport_context, nic_vport_ctx,
+allowed_list_size);
+
+   *list_size = req_list_size;
+   for (i = 0; i < req_list_size; i++) {
+   mac_addr = MLX5_ADDR_OF(nic_vport_context,
+   nic_vport_ctx,
+   current_uc_mac_address[i]) + 2;
+   ether_addr_copy(addr_list[i], mac_addr);
+   }
+out:
+   kfree(out);
+   return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_mac_list);
+
+int mlx5_modify_nic_vport_mac_list(struct mlx5_core_dev *dev,
+  enum mlx5_list_type list_type,
+  u8 addr_list[][ETH_ALEN],
+  int list_size)
+{
+   u32 out[MLX5_ST_SZ_DW(modify_nic_vport_context_out)];
+   void *nic_vport_ctx;
+   int max_list_size;
+   int in_sz;
+   void *in;
+   int err;
+   int i;
+
+   max_list_size = list_type == MLX5_NIC_VPORT_LIST_TYPE_UC ?
+1 << MLX5_CAP_GEN(dev, log_max_current_uc_list) :
+1 << MLX5_CAP_GEN(dev, log_max_current_mc_list);
+
+   if (list_size > max_list_size)
+   return -ENOSPC;
+
+   in_sz = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in) +
+   list_size * MLX5_ST_SZ_BYTES(mac_address_layout);
+
+   memset(out, 0, sizeof(out));
+   in = kzalloc(in_sz, GFP_KERNEL);
+   if (!in)
+

svn commit: r302269 - stable/10/sys/dev/mlx5/mlx5_core

2016-06-29 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Jun 29 10:29:52 2016
New Revision: 302269
URL: https://svnweb.freebsd.org/changeset/base/302269

Log:
  MFC r302139:
  Use correct Q-counter output array.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c
==
--- stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c   Wed Jun 29 10:25:32 
2016(r302268)
+++ stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c   Wed Jun 29 10:29:52 
2016(r302269)
@@ -71,7 +71,7 @@ static int mlx5_query_nic_vport_context(
 int mlx5_vport_alloc_q_counter(struct mlx5_core_dev *mdev, int *counter_set_id)
 {
u32 in[MLX5_ST_SZ_DW(alloc_q_counter_in)];
-   u32 out[MLX5_ST_SZ_DW(alloc_q_counter_in)];
+   u32 out[MLX5_ST_SZ_DW(alloc_q_counter_out)];
int err;
 
memset(in, 0, sizeof(in));
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r302266 - stable/10/sys/dev/usb/controller

2016-06-29 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Jun 29 10:21:45 2016
New Revision: 302266
URL: https://svnweb.freebsd.org/changeset/base/302266

Log:
  MFC r302076:
  Update the definition for number of scratch pages to match the latest
  version of the XHCI specification. Make sure the code can handle the
  maximum number of allowed scratch pages.
  
  Submitted by: shichun...@dell.com

Modified:
  stable/10/sys/dev/usb/controller/xhci.c
  stable/10/sys/dev/usb/controller/xhci.h
  stable/10/sys/dev/usb/controller/xhcireg.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/controller/xhci.c
==
--- stable/10/sys/dev/usb/controller/xhci.c Wed Jun 29 07:55:45 2016
(r302265)
+++ stable/10/sys/dev/usb/controller/xhci.c Wed Jun 29 10:21:45 2016
(r302266)
@@ -215,7 +215,7 @@ static void
 xhci_iterate_hw_softc(struct usb_bus *bus, usb_bus_mem_sub_cb_t *cb)
 {
struct xhci_softc *sc = XHCI_BUS2SC(bus);
-   uint8_t i;
+   uint16_t i;
 
cb(bus, >sc_hw.root_pc, >sc_hw.root_pg,
   sizeof(struct xhci_hw_root), XHCI_PAGE_SIZE);
@@ -223,7 +223,7 @@ xhci_iterate_hw_softc(struct usb_bus *bu
cb(bus, >sc_hw.ctx_pc, >sc_hw.ctx_pg,
   sizeof(struct xhci_dev_ctx_addr), XHCI_PAGE_SIZE);
 
-   for (i = 0; i != XHCI_MAX_SCRATCHPADS; i++) {
+   for (i = 0; i != sc->sc_noscratch; i++) {
cb(bus, >sc_hw.scratch_pc[i], >sc_hw.scratch_pg[i],
XHCI_PAGE_SIZE, XHCI_PAGE_SIZE);
}

Modified: stable/10/sys/dev/usb/controller/xhci.h
==
--- stable/10/sys/dev/usb/controller/xhci.h Wed Jun 29 07:55:45 2016
(r302265)
+++ stable/10/sys/dev/usb/controller/xhci.h Wed Jun 29 10:21:45 2016
(r302266)
@@ -30,7 +30,7 @@
 
 #defineXHCI_MAX_DEVICESMIN(USB_MAX_DEVICES, 128)
 #defineXHCI_MAX_ENDPOINTS  32  /* hardcoded - do not change */
-#defineXHCI_MAX_SCRATCHPADS32
+#defineXHCI_MAX_SCRATCHPADS1024
 #defineXHCI_MAX_EVENTS (16 * 13)
 #defineXHCI_MAX_COMMANDS   (16 * 1)
 #defineXHCI_MAX_RSEG   1
@@ -495,14 +495,15 @@ struct xhci_softc {
uint16_tsc_command_idx;
uint16_tsc_imod_default;
 
+   /* number of scratch pages */
+   uint16_tsc_noscratch;
+
uint8_t sc_event_ccs;
uint8_t sc_command_ccs;
/* number of XHCI device slots */
uint8_t sc_noslot;
/* number of ports on root HUB */
uint8_t sc_noport;
-   /* number of scratch pages */
-   uint8_t sc_noscratch;
/* root HUB device configuration */
uint8_t sc_conf;
/* root HUB port event bitmap, max 256 ports */

Modified: stable/10/sys/dev/usb/controller/xhcireg.h
==
--- stable/10/sys/dev/usb/controller/xhcireg.h  Wed Jun 29 07:55:45 2016
(r302265)
+++ stable/10/sys/dev/usb/controller/xhcireg.h  Wed Jun 29 10:21:45 2016
(r302266)
@@ -52,8 +52,8 @@
 #defineXHCI_HCSPARAMS2 0x08/* RO structual parameters 2 */
 #defineXHCI_HCS2_IST(x)((x) & 0xF)
 #defineXHCI_HCS2_ERST_MAX(x)   (((x) >> 4) & 0xF)
-#defineXHCI_HCS2_SPR(x)(((x) >> 24) & 0x1)
-#defineXHCI_HCS2_SPB_MAX(x)(((x) >> 27) & 0x7F)
+#defineXHCI_HCS2_SPR(x)(((x) >> 26) & 0x1)
+#defineXHCI_HCS2_SPB_MAX(x)x) >> 16) & 0x3E0) | (((x) >> 27) & 
0x1F))
 #defineXHCI_HCSPARAMS3 0x0C/* RO structual parameters 3 */
 #defineXHCI_HCS3_U1_DEL(x) ((x) & 0xFF)
 #defineXHCI_HCS3_U2_DEL(x) (((x) >> 16) & 0x)
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r302259 - stable/10/sys/compat/linux

2016-06-29 Thread Dmitry Chagin
Author: dchagin
Date: Wed Jun 29 06:04:45 2016
New Revision: 302259
URL: https://svnweb.freebsd.org/changeset/base/302259

Log:
  MFC r302213:
  
  Fix a bug introduced in r283433.
  
  [1] Remove unneeded sockaddr conversion before kern_recvit() call as the from
  argument is used to record result (the source address of the received 
message) only.
  
  [2] In Linux the type of msg_namelen member of struct msghdr is signed but 
native
  msg_namelen has a unsigned type (socklen_t). So use the proper storage to 
fetch fromlen
  from userspace and than check the user supplied value and return EINVAL if it 
is less
  than 0 as a Linux do.
  
  Reported by:  Thomas Mueller  [1]
  Tested by:Thomas Mueller  [both]
  Reviewed by:  kib@

Modified:
  stable/10/sys/compat/linux/linux_socket.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/compat/linux/linux_socket.c
==
--- stable/10/sys/compat/linux/linux_socket.c   Wed Jun 29 05:21:25 2016
(r302258)
+++ stable/10/sys/compat/linux/linux_socket.c   Wed Jun 29 06:04:45 2016
(r302259)
@@ -1040,18 +1040,16 @@ linux_recvfrom(struct thread *td, struct
 {
struct msghdr msg;
struct iovec aiov;
-   int error;
+   int error, fromlen;
 
if (PTRIN(args->fromlen) != NULL) {
-   error = copyin(PTRIN(args->fromlen), _namelen,
-   sizeof(msg.msg_namelen));
-   if (error != 0)
-   return (error);
-
-   error = linux_to_bsd_sockaddr((struct sockaddr 
*)PTRIN(args->from),
-   msg.msg_namelen);
+   error = copyin(PTRIN(args->fromlen), ,
+   sizeof(fromlen));
if (error != 0)
return (error);
+   if (fromlen < 0)
+   return (EINVAL);
+   msg.msg_namelen = fromlen;
} else
msg.msg_namelen = 0;
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"