| 1377 | } |
| 1378 | |
| 1379 | static int |
| 1380 | mls_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, |
| 1381 | struct label *pplabel, struct label *newlabel) |
| 1382 | { |
| 1383 | struct mac_mls *subj, *obj, *new; |
| 1384 | int error; |
| 1385 | |
| 1386 | new = SLOT(newlabel); |
| 1387 | subj = SLOT(cred->cr_label); |
| 1388 | obj = SLOT(pplabel); |
| 1389 | |
| 1390 | /* |
| 1391 | * If there is an MLS label update for a pipe, it must be a effective |
| 1392 | * update. |
| 1393 | */ |
| 1394 | error = mls_atmostflags(new, MAC_MLS_FLAG_EFFECTIVE); |
| 1395 | if (error) |
| 1396 | return (error); |
| 1397 | |
| 1398 | /* |
| 1399 | * To perform a relabel of a pipe (MLS label or not), MLS must |
| 1400 | * authorize the relabel. |
| 1401 | */ |
| 1402 | if (!mls_effective_in_range(obj, subj)) |
| 1403 | return (EPERM); |
| 1404 | |
| 1405 | /* |
| 1406 | * If the MLS label is to be changed, authorize as appropriate. |
| 1407 | */ |
| 1408 | if (new->mm_flags & MAC_MLS_FLAG_EFFECTIVE) { |
| 1409 | /* |
| 1410 | * To change the MLS label on a pipe, the new pipe label must |
| 1411 | * be in the subject range. |
| 1412 | */ |
| 1413 | if (!mls_effective_in_range(new, subj)) |
| 1414 | return (EPERM); |
| 1415 | |
| 1416 | /* |
| 1417 | * To change the MLS label on a pipe to be EQUAL, the subject |
| 1418 | * must have appropriate privilege. |
| 1419 | */ |
| 1420 | if (mls_contains_equal(new)) { |
| 1421 | error = mls_subject_privileged(subj); |
| 1422 | if (error) |
| 1423 | return (error); |
| 1424 | } |
| 1425 | } |
| 1426 | |
| 1427 | return (0); |
| 1428 | } |
| 1429 | |
| 1430 | static int |
| 1431 | mls_pipe_check_stat(struct ucred *cred, struct pipepair *pp, |
nothing calls this directly
no test coverage detected