Security modules and sending signals within the same process
Subsystems (3)
Is it guaranteed that tasks in the same thread group can always send signals to each other, irrespective of their respective credentials structs?
It's not clear to me whether this is always possible based on the security_task_kill implementations I've examined.
I want to support per-thread setresuid/setresgid, but we also use signals for inter-thread communication. This is mainly for thread cancellation; the setxgid stuff isn't needed for threads with private credentials. I wonder if I need to disable cancellation for threads with such credentials.
Thanks,
Florian
Signature · 3 lines
AppArmor mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
A message that is not in the archive (sent off-list or not yet received): 87lg5asilo.fsf-fjB847h8rq0pB0kWxzfTigCJwEvxM/[email protected]
Quoted 4 lines · Florian Weimer
Is it guaranteed that tasks in the same thread group can always send signals to each other, irrespective of their respective credentials structs?
Quoted 8 lines
It's not clear to me whether this is always possible based on the
security_task_killimplementations I've examined.I want to support per-thread setresuid/setresgid, but we also use signals for inter-thread communication. This is mainly for thread cancellation; the setxgid stuff isn't needed for threads with private credentials. I wonder if I need to disable cancellation for threads with such credentials.
(fixed selinux list address, which moved to vger)
Looks like commit 065add3941bd ("signals: check_kill_permission(): don't check creds if same_thread_group()") skipped the uid-based checks if the sender and target were in the same thread group, but not the security hook call. One could argue that the security hook call ought to be skipped in that case as well using the same rationale given in that commit. Nothing appears to guarantee the property you state above for security_task_kill implementations, although none of the in-tree users are based on uids or gids so setresuid/setresgid shouldn't affect them.
A message that is not in the archive (sent off-list or not yet received): e754fa24-899b-f77e-f226-0f070ebad132-+05T5uksL2qpZYMLLGbcSA@public.gmane.org
* Stephen Smalley:
Quoted 9 lines
Looks like commit
065add3941bd("signals:check_kill_permission():
don't check creds ifsame_thread_group()") skipped the uid-based checks if the sender and target were in the same thread group, but not the security hook call. One could argue that the security hook call ought to be skipped in that case as well using the same rationale given in that commit. Nothing appears to guarantee the property you state above forsecurity_task_killimplementations, although none of the in-tree users are based on uids or gids so setresuid/setresgid shouldn't affect them.
Okay, thanks, so it looks like I don't have to do anything special to support thread cancellation.
Florian
Signature · 3 lines
AppArmor mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
Quoted 3 lines · Florian Weimer
Is it guaranteed that tasks in the same thread group can always send signals to each other, irrespective of their respective credentials structs?
No. An LSM may chose to disallow this based on just about any criteria it desires.
Quoted 2 lines
It's not clear to me whether this is always possible based on the
security_task_killimplementations I've examined.
SELinux, Smack and AppArmor make their decisions based on the task_struct credential, so if it's possible to change the LSM attributes at the task granularity, it's possible to have a process that can't always talk to itself.
Quoted 1 line
I want to support per-thread setresuid/setresgid,
That's pretty dangerous in its own right. Effectively the process containing the threads has multiple UIDs. That complicates the DAC model significantly.
Quoted 2 lines
but we also use
signals for inter-thread communication.
It's unfortunate that no one has seriously proposed mode bits on processes for signal delivery. The UID matching policy is inconvenient in a lot of cases. Hmmm...
Quoted 8 lines
This is mainly for thread
cancellation; the setxgid stuff isn't needed for threads with private credentials. I wonder if I need to disable cancellation for threads with such credentials.Thanks,
Florian
Signature · 3 lines
AppArmor mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
A message that is not in the archive (sent off-list or not yet received): 2c3e813c-f56a-3354-1299-30b0646f40e1-iSGtlc1asvQWG2LlvL+J4A@public.gmane.org
* Casey Schaufler:
Quoted 7 lines · Florian Weimer
Quoted 3 lines
Is it guaranteed that tasks in the same thread group can always send signals to each other, irrespective of their respective credentials structs?
No. An LSM may chose to disallow this based on just about any criteria it desires.
Hmm.
Quoted 7 lines
Quoted 2 lines
It's not clear to me whether this is always possible based on the
security_task_killimplementations I've examined.SELinux, Smack and AppArmor make their decisions based on the
task_structcredential, so if it's possible to change the LSM attributes at the task granularity, it's possible to have a process that can't always talk to itself.
Yes, we already have this today for LSM attributes. We only paper over this for the UIDs/GIDs, using a really awkward mechanism. Maybe we will get rid of that one day, when the kernel supports a proper per-process attribute, but I don't count on it.
Quoted 5 lines
Quoted 1 line
I want to support per-thread setresuid/setresgid,
That's pretty dangerous in its own right. Effectively the process containing the threads has multiple UIDs. That complicates the DAC model significantly.
Sure. But I think it's better to do this explicitly in glibc, rather than file server authors calling the system calls directly. And it only exposes what the kernel does anyway.
Thanks,
Florian
Signature · 3 lines
AppArmor mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
Quoted 8 lines · Casey Schaufler
Quoted 3 lines · Florian Weimer
Is it guaranteed that tasks in the same thread group can always send signals to each other, irrespective of their respective credentials structs?
No. An LSM may chose to disallow this based on just about any criteria it desires.
And apparmor is in fact doing this a few limited situations, userspace has to request the profile change via an api, and regular policy enforcement based on credentials mediates the signals. Its not something we recommend but it has been used.
Signature · 3 lines
AppArmor mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor