Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Jan 2021 18:32:31 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: adc0dcc352bb - main - mpr, mps: Fix an off-by-one bug in the BTDH_MAPPING ioctl
Message-ID:  <202101081832.108IWVsE056777@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=adc0dcc352bb9f5a67a054d95c6959ea5aa26d91

commit adc0dcc352bb9f5a67a054d95c6959ea5aa26d91
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-01-08 18:32:05 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-01-08 18:32:05 +0000

    mpr, mps: Fix an off-by-one bug in the BTDH_MAPPING ioctl
    
    The device mapping table contains sc->max_devices entries, so only
    indices in [0, sc->max_devices) are valid.
    
    MFC after:      3 days
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D27964
---
 sys/dev/mpr/mpr_user.c | 2 +-
 sys/dev/mps/mps_user.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/dev/mpr/mpr_user.c b/sys/dev/mpr/mpr_user.c
index 236e5c9715df..cab865e2e535 100644
--- a/sys/dev/mpr/mpr_user.c
+++ b/sys/dev/mpr/mpr_user.c
@@ -2226,7 +2226,7 @@ mpr_user_btdh(struct mpr_softc *sc, mpr_btdh_mapping_t *data)
 		if (bus != 0)
 			return (EINVAL);
 
-		if (target > sc->max_devices) {
+		if (target >= sc->max_devices) {
 			mpr_dprint(sc, MPR_XINFO, "Target ID is out of range "
 			   "for Bus/Target to DevHandle mapping.");
 			return (EINVAL);
diff --git a/sys/dev/mps/mps_user.c b/sys/dev/mps/mps_user.c
index c80fbc68cdf3..9d4aab54562f 100644
--- a/sys/dev/mps/mps_user.c
+++ b/sys/dev/mps/mps_user.c
@@ -2128,7 +2128,7 @@ mps_user_btdh(struct mps_softc *sc, mps_btdh_mapping_t *data)
 		if (bus != 0)
 			return (EINVAL);
 
-		if (target > sc->max_devices) {
+		if (target >= sc->max_devices) {
 			mps_dprint(sc, MPS_FAULT, "Target ID is out of range "
 			   "for Bus/Target to DevHandle mapping.");
 			return (EINVAL);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101081832.108IWVsE056777>