Skip to content

Commit dc18101

Browse files
pcmooregregkh
authored andcommitted
netlabel: fix out-of-bounds memory accesses
[ Upstream commit 5578de4 ] There are two array out-of-bounds memory accesses, one in cipso_v4_map_lvl_valid(), the other in netlbl_bitmap_walk(). Both errors are embarassingly simple, and the fixes are straightforward. As a FYI for anyone backporting this patch to kernels prior to v4.8, you'll want to apply the netlbl_bitmap_walk() patch to cipso_v4_bitmap_walk() as netlbl_bitmap_walk() doesn't exist before Linux v4.8. Reported-by: Jann Horn <jannh@google.com> Fixes: 446fda4 ("[NetLabel]: CIPSOv4 engine") Fixes: 3faa8f9 ("netlabel: Move bitmap manipulation functions to the NetLabel core.") Signed-off-by: Paul Moore <paul@paul-moore.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent aba029c commit dc18101

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

net/ipv4/cipso_ipv4.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ static int cipso_v4_bitmap_walk(const unsigned char *bitmap,
167167
(state == 0 && (byte & bitmask) == 0))
168168
return bit_spot;
169169

170-
bit_spot++;
170+
if (++bit_spot >= bitmap_len)
171+
return -1;
171172
bitmask >>= 1;
172173
if (bitmask == 0) {
173174
byte = bitmap[++byte_offset];
@@ -737,7 +738,8 @@ static int cipso_v4_map_lvl_valid(const struct cipso_v4_doi *doi_def, u8 level)
737738
case CIPSO_V4_MAP_PASS:
738739
return 0;
739740
case CIPSO_V4_MAP_TRANS:
740-
if (doi_def->map.std->lvl.cipso[level] < CIPSO_V4_INV_LVL)
741+
if ((level < doi_def->map.std->lvl.cipso_size) &&
742+
(doi_def->map.std->lvl.cipso[level] < CIPSO_V4_INV_LVL))
741743
return 0;
742744
break;
743745
}

0 commit comments

Comments
 (0)