svn commit: r341290 - head/sys/dev/sfxge/common

Andrew Rybchenko arybchik at FreeBSD.org
Fri Nov 30 07:04:15 UTC 2018


Author: arybchik
Date: Fri Nov 30 07:04:13 2018
New Revision: 341290
URL: https://svnweb.freebsd.org/changeset/base/341290

Log:
  sfxge(4): check size of memory to read sensors data to
  
  Size of provided memory should be consistent with specified size.
  
  Submitted by:   Martin Harvey <mharvey at solarflare.com>
  Sponsored by:   Solarflare Communications, Inc.
  MFC after:      1 week
  Differential Revision:  https://reviews.freebsd.org/D18252

Modified:
  head/sys/dev/sfxge/common/mcdi_mon.c

Modified: head/sys/dev/sfxge/common/mcdi_mon.c
==============================================================================
--- head/sys/dev/sfxge/common/mcdi_mon.c	Fri Nov 30 06:47:01 2018	(r341289)
+++ head/sys/dev/sfxge/common/mcdi_mon.c	Fri Nov 30 07:04:13 2018	(r341290)
@@ -221,7 +221,13 @@ efx_mcdi_read_sensors(
 	uint8_t payload[MAX(MC_CMD_READ_SENSORS_EXT_IN_LEN,
 			    MC_CMD_READ_SENSORS_EXT_OUT_LEN)];
 	uint32_t addr_lo, addr_hi;
+	efx_rc_t rc;
 
+	if (EFSYS_MEM_SIZE(esmp) < size) {
+		rc = EINVAL;
+		goto fail1;
+	}
+
 	req.emr_cmd = MC_CMD_READ_SENSORS;
 	req.emr_in_buf = payload;
 	req.emr_in_length = MC_CMD_READ_SENSORS_EXT_IN_LEN;
@@ -238,6 +244,11 @@ efx_mcdi_read_sensors(
 	efx_mcdi_execute(enp, &req);
 
 	return (req.emr_rc);
+
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+	return (rc);
 }
 
 static	__checkReturn	efx_rc_t


More information about the svn-src-all mailing list