Commit 42a2949
selinux: require a class's permission values to cover its permission count
[ Upstream commit b98a8ac ]
security_get_permissions() sizes an array by the class's permissions.nprim
and fills it at value - 1, from the inherited common's permission table and
then the class's own. A value no permission defines leaves a NULL that
sel_make_perm_files() passes to d_alloc_name(), an oops inside
sel_write_load() that strands selinux_state.policy_mutex and leaves every
later load in uninterruptible sleep; two permissions sharing a value
overwrite the first kstrdup(). Bounding each value by nprim catches
neither, and neither would a count: the symbol table is keyed on the
permission name, so duplicates pass.
Track the values each permission table claims and require them to cover
exactly what its count declares, rejecting a count no value can reach.
Conforming policies are unaffected.
Cc: stable@vger.kernel.org
Fixes: 55fcf09 ("selinux: add support for querying object classes and permissions from the running policy")
Signed-off-by: Bryam Vargas <hexlabsecurity@proton.me>
Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
(cherry picked from commit b98a8ac)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>1 parent 6c2ab7c commit 42a2949
1 file changed
Lines changed: 46 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1127 | 1127 | | |
1128 | 1128 | | |
1129 | 1129 | | |
1130 | | - | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
1131 | 1142 | | |
1132 | 1143 | | |
1133 | 1144 | | |
| |||
1151 | 1162 | | |
1152 | 1163 | | |
1153 | 1164 | | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
1154 | 1169 | | |
1155 | 1170 | | |
1156 | 1171 | | |
| |||
1171 | 1186 | | |
1172 | 1187 | | |
1173 | 1188 | | |
1174 | | - | |
| 1189 | + | |
1175 | 1190 | | |
1176 | 1191 | | |
1177 | 1192 | | |
| |||
1193 | 1208 | | |
1194 | 1209 | | |
1195 | 1210 | | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
1196 | 1215 | | |
1197 | 1216 | | |
1198 | 1217 | | |
1199 | 1218 | | |
1200 | 1219 | | |
1201 | 1220 | | |
1202 | | - | |
| 1221 | + | |
1203 | 1222 | | |
1204 | 1223 | | |
1205 | 1224 | | |
1206 | 1225 | | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
1207 | 1233 | | |
1208 | 1234 | | |
1209 | 1235 | | |
| |||
1339 | 1365 | | |
1340 | 1366 | | |
1341 | 1367 | | |
1342 | | - | |
| 1368 | + | |
1343 | 1369 | | |
1344 | 1370 | | |
1345 | 1371 | | |
| |||
1367 | 1393 | | |
1368 | 1394 | | |
1369 | 1395 | | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
1370 | 1400 | | |
1371 | 1401 | | |
1372 | 1402 | | |
| |||
1401 | 1431 | | |
1402 | 1432 | | |
1403 | 1433 | | |
1404 | | - | |
| 1434 | + | |
1405 | 1435 | | |
1406 | 1436 | | |
1407 | 1437 | | |
1408 | 1438 | | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
1409 | 1450 | | |
1410 | 1451 | | |
1411 | 1452 | | |
| |||
0 commit comments