Re: [PATCH 5/5] selinux: drop unnecessary NULL check

From: Paul Moore
Date: Tue Jun 07 2022 - 22:46:50 EST


On Thu, Feb 17, 2022 at 9:22 AM Christian Göttsche
<cgzones@xxxxxxxxxxxxxx> wrote:
>
> Commit e3489f8974e1 ("selinux: kill selinux_sb_get_mnt_opts()")
> introduced a NULL check on the context after a successful call to
> security_sid_to_context(). This is on the one hand redundant after
> checking for success and on the other hand insufficient on an actual
> NULL pointer, since the context is passed to seq_escape() leading to a
> call of strlen() on it.
>
> Reported by Clang analyzer:
>
> In file included from security/selinux/hooks.c:28:
> In file included from ./include/linux/tracehook.h:50:
> In file included from ./include/linux/memcontrol.h:13:
> In file included from ./include/linux/cgroup.h:18:
> ./include/linux/seq_file.h:136:25: warning: Null pointer passed as 1st argument to string length function [unix.cstring.NullArg]
> seq_escape_mem(m, src, strlen(src), flags, esc);
> ^~~~~~~~~~~
>
> Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx>
> ---
> security/selinux/hooks.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

I was waiting for Nick to reply, but he never did, and this looks good
to me so I just merged it into selinux/next. Thanks for your patience
Christian.

--
paul-moore.com