aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/bus.h
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2018-05-31 02:57:58 +0000
committerWarner Losh <imp@FreeBSD.org>2018-05-31 02:57:58 +0000
commitc580ca4cf4a4df702d3cde59ce9bb899c6cdab6e (patch)
tree26d930bc1d54812180b328116ff4e1b4abd84d21 /sys/sys/bus.h
parent92376fa76c0b342f61d8b8505119bdf56d5af781 (diff)
downloadsrc-c580ca4cf4a4df702d3cde59ce9bb899c6cdab6e.tar.gz
src-c580ca4cf4a4df702d3cde59ce9bb899c6cdab6e.zip
Make the data returned by devinfo harder to overflow.
Rather than using fixed-length strings, pack them into a string table to return. Also expand the buffer from ~300 charaters to 3k. This should be enough, even for USB. This fixes a problem where USB pnp info is truncated on return to userland. Differential Revision: https://reviews.freebsd.org/D15629
Notes
Notes: svn path=/head/; revision=334414
Diffstat (limited to 'sys/sys/bus.h')
-rw-r--r--sys/sys/bus.h19
1 files changed, 11 insertions, 8 deletions
diff --git a/sys/sys/bus.h b/sys/sys/bus.h
index 66c227c66d98..c5305fee41d9 100644
--- a/sys/sys/bus.h
+++ b/sys/sys/bus.h
@@ -46,7 +46,7 @@
*/
struct u_businfo {
int ub_version; /**< @brief interface version */
-#define BUS_USER_VERSION 1
+#define BUS_USER_VERSION 2
int ub_generation; /**< @brief generation count */
};
@@ -63,20 +63,23 @@ typedef enum device_state {
/**
* @brief Device information exported to userspace.
+ * The strings are placed one after the other, separated by NUL characters.
+ * Fields should be added after the last one and order maintained for compatibility
*/
+#define BUS_USER_BUFFER (3*1024)
struct u_device {
uintptr_t dv_handle;
uintptr_t dv_parent;
-
- char dv_name[32]; /**< @brief Name of device in tree. */
- char dv_desc[32]; /**< @brief Driver description */
- char dv_drivername[32]; /**< @brief Driver name */
- char dv_pnpinfo[128]; /**< @brief Plug and play info */
- char dv_location[128]; /**< @brief Where is the device? */
uint32_t dv_devflags; /**< @brief API Flags for device */
uint16_t dv_flags; /**< @brief flags for dev state */
device_state_t dv_state; /**< @brief State of attachment */
- /* XXX more driver info? */
+ char dv_fields[BUS_USER_BUFFER]; /**< @brief NUL terminated fields */
+ /* name (name of the device in tree) */
+ /* desc (driver description) */
+ /* drivername (Name of driver without unit number) */
+ /* pnpinfo (Plug and play information from bus) */
+ /* location (Location of device on parent */
+ /* NUL */
};
/* Flags exported via dv_flags. */