hc
2024-05-11 297b60346df8beafee954a0fd7c2d64f33f3b9bc
kernel/net/netlabel/netlabel_kapi.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * NetLabel Kernel API
34 *
....@@ -6,25 +7,10 @@
67 * as CIPSO and RIPSO.
78 *
89 * Author: Paul Moore <paul@paul-moore.com>
9
- *
1010 */
1111
1212 /*
1313 * (c) Copyright Hewlett-Packard Development Company, L.P., 2006, 2008
14
- *
15
- * This program is free software; you can redistribute it and/or modify
16
- * it under the terms of the GNU General Public License as published by
17
- * the Free Software Foundation; either version 2 of the License, or
18
- * (at your option) any later version.
19
- *
20
- * This program is distributed in the hope that it will be useful,
21
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
23
- * the GNU General Public License for more details.
24
- *
25
- * You should have received a copy of the GNU General Public License
26
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
27
- *
2814 */
2915
3016 #include <linux/init.h>
....@@ -621,7 +607,7 @@
621607 */
622608 int netlbl_catmap_walk(struct netlbl_lsm_catmap *catmap, u32 offset)
623609 {
624
- struct netlbl_lsm_catmap *iter = catmap;
610
+ struct netlbl_lsm_catmap *iter;
625611 u32 idx;
626612 u32 bit;
627613 NETLBL_CATMAP_MAPTYPE bitmap;
....@@ -871,7 +857,8 @@
871857
872858 offset -= iter->startbit;
873859 idx = offset / NETLBL_CATMAP_MAPSIZE;
874
- iter->bitmap[idx] |= bitmap << (offset % NETLBL_CATMAP_MAPSIZE);
860
+ iter->bitmap[idx] |= (NETLBL_CATMAP_MAPTYPE)bitmap
861
+ << (offset % NETLBL_CATMAP_MAPSIZE);
875862
876863 return 0;
877864 }
....@@ -899,6 +886,8 @@
899886 unsigned char bitmask;
900887 unsigned char byte;
901888
889
+ if (offset >= bitmap_len)
890
+ return -1;
902891 byte_offset = offset / 8;
903892 byte = bitmap[byte_offset];
904893 bit_spot = offset;