Re: Does uaccess_kernel() work for detecting kernel thread?

From: Christoph Hellwig
Date: Wed Dec 23 2020 - 02:53:52 EST


On Tue, Dec 22, 2020 at 11:39:08PM +0900, Tetsuo Handa wrote:
> For example, if uaccess_kernel() is "false" due to CONFIG_SET_FS=n,
> isn't sg_check_file_access() failing to detect kernel context?

sg_check_file_access does exactly the right thing - fail for all kernel
threads as those can't support the magic it does.

> For another example, if uaccess_kernel() is "false" due to CONFIG_SET_FS=n,
> isn't TOMOYO unexpectedly checking permissions for socket operations?

Can someone explain WTF TOMOYO is even doing there? A security module
has absolutely no business checking what context it is called from, but
must check the process credentials instead.