Re: [PATCH] lkdtm: no need to check return value of debugfs_create functions

From: Greg Kroah-Hartman
Date: Tue Jun 11 2019 - 15:01:32 EST


On Tue, Jun 11, 2019 at 11:44:53AM -0700, Kees Cook wrote:
> On Tue, Jun 11, 2019 at 08:32:13PM +0200, Greg Kroah-Hartman wrote:
> > When calling debugfs functions, there is no need to ever check the
> > return value. The function can work or not, but the code logic should
> > never do something different based on this.
>
> What is the user-visible feedback when, say, debugfs_create_file()
> fails?

All of the memory in your system is now gone and it would have long
locked up a while before this call ever happened :)

And no user functionality should ever change if a debugfs call fails, or
succeeds, this is debugging only.

> And what happens when debugfs_create_file() passes in a NULL root?

The file ends up in the root of debugfs. But as this can only happen if
the system is dead, I wouldn't worry about it.

thanks,

greg k-h