Re: [PATCH 1/3] LSM: add security_bprm_aborting_creds() hook

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2024/01/29 13:10, Eric W. Biederman wrote:
>> @@ -1519,6 +1519,7 @@ static void free_bprm(struct linux_binprm *bprm)
>>  	}
>>  	free_arg_pages(bprm);
>>  	if (bprm->cred) {
>> +		security_bprm_aborting_creds(bprm);
>>  		mutex_unlock(&current->signal->cred_guard_mutex);
>>  		abort_creds(bprm->cred);
> 
> Why isn't abort_creds calling security_free_cred enough here?

Because security_cred_free() from put_cred_rcu() is called from RCU callback
rather than from current thread doing execve().
TOMOYO wants to restore attributes of current thread doing execve().

> The fact that somewhere Tomoyo is modifying a credential that the rest
> of the kernel sees as read-only, and making it impossible to just
> restore that credential is very concerning from a maintenance
> perspective.

TOMOYO does not use "struct cred"->security.
TOMOYO uses only "struct task_struct"->security.

  struct lsm_blob_sizes tomoyo_blob_sizes __ro_after_init = {
      .lbs_task = sizeof(struct tomoyo_task),
  };

TOMOYO uses security_task_alloc() for allocating "struct task_struct"->security,
security_task_free() for releasing "struct task_struct"->security,
security_bprm_check() for updating "struct task_struct"->security,
security_bprm_committed_creds() for erasing old "struct task_struct"->security,
security_bprm_aborting_creds() for restoring old "struct task_struct"->security.

Commit a6f76f23d297 ("CRED: Make execve() take advantage of copy-on-write
credentials") made TOMOYO impossible to do above. current->in_execve flag was a
hack for emulating security_bprm_aborting_creds() using security_prepare_creds().

> Can't Tomoyo simply allow reading of files that have __FMODE_EXEC
> set when allow_execve is set, without needing to perform a domain
> transition, and later back out that domain transition?

No. That does not match TOMOYO's design.

allow_execve keyword does not imply "allow opening that file for non-execve() purpose".

Also, performing a domain transition before execve() reaches point of no return is
the TOMOYO's design, but COW credentials does not allow such behavior.





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux