Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Nov 2019 02:12:33 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r355158 - stable/12/sys/dev/cfi
Message-ID:  <201911280212.xAS2CXRJ017441@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Thu Nov 28 02:12:33 2019
New Revision: 355158
URL: https://svnweb.freebsd.org/changeset/base/355158

Log:
  MFC r355101, r355104: cfi: check for inter overflow in cfi_devioctl
  
  Reported by:	Pietro Oliva
  Security:	Possible OOB read in root-only ioctl
  Sponsored by:	The FreeBSD Foundation

Modified:
  stable/12/sys/dev/cfi/cfi_dev.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cfi/cfi_dev.c
==============================================================================
--- stable/12/sys/dev/cfi/cfi_dev.c	Thu Nov 28 02:05:31 2019	(r355157)
+++ stable/12/sys/dev/cfi/cfi_dev.c	Thu Nov 28 02:12:33 2019	(r355158)
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/conf.h>
 #include <sys/ioccom.h>
 #include <sys/kernel.h>
+#include <sys/limits.h>
 #include <sys/malloc.h>   
 #include <sys/proc.h>
 #include <sys/sysctl.h>
@@ -280,7 +281,8 @@ cfi_devioctl(struct cdev *dev, u_long cmd, caddr_t dat
 		rq = (struct cfiocqry *)data;
 		if (rq->offset >= sc->sc_size / sc->sc_width)
 			return (ESPIPE);
-		if (rq->offset + rq->count > sc->sc_size / sc->sc_width)
+		if (rq->offset > ULONG_MAX - rq->count ||
+		    rq->offset + rq->count > sc->sc_size / sc->sc_width)
 			return (ENOSPC);
 
 		while (!error && rq->count--) {



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