diff options
author | sbruno <sbruno@FreeBSD.org> | 2016-04-19 18:27:28 +0000 |
---|---|---|
committer | sbruno <sbruno@FreeBSD.org> | 2016-04-19 18:27:28 +0000 |
commit | 2a633810e805be71a069c4b6e402bbcf3d9a20ed (patch) | |
tree | fe58f3a0d263b01e4532f17adba1a23adf56a3d3 /sys/dev/aac | |
parent | edd3a7f3f93b3eeeb0c74eba010647ff648ea3d3 (diff) | |
download | FreeBSD-src-2a633810e805be71a069c4b6e402bbcf3d9a20ed.zip FreeBSD-src-2a633810e805be71a069c4b6e402bbcf3d9a20ed.tar.gz |
aacraid(4): Sanely copyin userland pointers and ensure that we don't get
anything janky from a user. (cturt)
aac(4): landergriffith+freebsdbugzilla@gmail.com pointed out that aacraid(4)
had the same issue and handling of pointers, so let's change that too.
PR: 206573
Submitted by: cturt@hardenedbsd.org
Obtained from: HardenedBSD
MFC after: 1 week
Diffstat (limited to 'sys/dev/aac')
-rw-r--r-- | sys/dev/aac/aac.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/sys/dev/aac/aac.c b/sys/dev/aac/aac.c index 4028cb4..2d7996f 100644 --- a/sys/dev/aac/aac.c +++ b/sys/dev/aac/aac.c @@ -3103,18 +3103,30 @@ aac_ioctl_send_raw_srb(struct aac_softc *sc, caddr_t arg) /* Retrieve correct SG entries. */ if (fibsize == (sizeof(struct aac_srb) + srbcmd->sg_map.SgCount * sizeof(struct aac_sg_entry))) { + struct aac_sg_entry sg; + sge = srbcmd->sg_map.SgEntry; sge64 = NULL; - srb_sg_bytecount = sge->SgByteCount; - srb_sg_address = (void *)(uintptr_t)sge->SgAddress; + + if ((error = copyin(sge, &sg, sizeof(sg))) != 0) + goto out; + + srb_sg_bytecount = sg.SgByteCount; + srb_sg_address = (void *)(uintptr_t)sg.SgAddress; } #ifdef __amd64__ else if (fibsize == (sizeof(struct aac_srb) + srbcmd->sg_map.SgCount * sizeof(struct aac_sg_entry64))) { + struct aac_sg_entry64 sg; + sge = NULL; sge64 = (struct aac_sg_entry64 *)srbcmd->sg_map.SgEntry; - srb_sg_bytecount = sge64->SgByteCount; - srb_sg_address = (void *)sge64->SgAddress; + + if ((error = copyin(sge64, &sg, sizeof(sg))) != 0) + goto out; + + srb_sg_bytecount = sg.SgByteCount; + srb_sg_address = (void *)sg.SgAddress; if (sge64->SgAddress > 0xffffffffull && (sc->flags & AAC_FLAGS_SG_64BIT) == 0) { error = EINVAL; |