Skip to content

Commit 16a846d

Browse files
committed
Merge: scsi: target: Fix SELinux error when systemd-modules loads the target module
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4035 # Merge Request Required Information Fix a SELinux error when loading the LIO target module JIRA: https://issues.redhat.com/browse/RHEL-21327 Signed-off-by: Maurizio Lombardi <mlombard@redhat.com> ## Summary of Changes ## Approved Development Ticket All submissions to CentOS Stream must reference an approved ticket in [Red Hat Jira](https://issues.redhat.com/). Please follow the CentOS Stream [contribution documentation](https://docs.centos.org/en-US/stream-contrib/quickstart/) for how to file this ticket and have it approved. Approved-by: Ming Lei <ming.lei@redhat.com> Approved-by: Ewan D. Milne <emilne@redhat.com> Approved-by: John Meneghini <jmeneghi@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Lucas Zampieri <lzampier@redhat.com>
2 parents c644b7e + e7c1df0 commit 16a846d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/target/target_core_configfs.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3672,6 +3672,8 @@ static int __init target_core_init_configfs(void)
36723672
{
36733673
struct configfs_subsystem *subsys = &target_core_fabrics;
36743674
struct t10_alua_lu_gp *lu_gp;
3675+
struct cred *kern_cred;
3676+
const struct cred *old_cred;
36753677
int ret;
36763678

36773679
pr_debug("TARGET_CORE[0]: Loading Generic Kernel Storage"
@@ -3748,11 +3750,21 @@ static int __init target_core_init_configfs(void)
37483750
if (ret < 0)
37493751
goto out;
37503752

3753+
/* We use the kernel credentials to access the target directory */
3754+
kern_cred = prepare_kernel_cred(&init_task);
3755+
if (!kern_cred) {
3756+
ret = -ENOMEM;
3757+
goto out;
3758+
}
3759+
old_cred = override_creds(kern_cred);
37513760
target_init_dbroot();
3761+
revert_creds(old_cred);
3762+
put_cred(kern_cred);
37523763

37533764
return 0;
37543765

37553766
out:
3767+
target_xcopy_release_pt();
37563768
configfs_unregister_subsystem(subsys);
37573769
core_dev_release_virtual_lun0();
37583770
rd_module_exit();

0 commit comments

Comments
 (0)