linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selinux: fixed parse warning Using plain integer as NULL pointer
@ 2019-03-24 10:10 Hariprasad Kelam
  2019-03-24 10:57 ` Ondrej Mosnacek
  0 siblings, 1 reply; 2+ messages in thread
From: Hariprasad Kelam @ 2019-03-24 10:10 UTC (permalink / raw)
  To: paul, sds, eparis, omosnace, keescook, rgb, jannh, adobriyan,
	sgrover, peter.enderborg, kent.overstreet, selinux, linux-kernel

Changed  0 --> NULL to avoid sparse warning

Sparse warning below:

sudo make C=2 CF=-D__CHECK_ENDIAN__ M=security

 CHECK   security/selinux/ss/services.c
security/selinux/ss/services.c:1323:32: warning: Using plain integer as
NULL pointer

Signed-off-by: Hariprasad Kelam <hariprasad.kelam@gmail.com>
---
 security/selinux/ss/services.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index ec62918..30cea59 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -1320,7 +1320,7 @@ static int security_sid_to_context_core(struct selinux_state *state,
 	}
 	if (only_invalid && !context->len) {
 		scontext = NULL;
-		scontext_len = 0;
+		scontext_len = NULL;
 		rc = 0;
 	} else {
 		rc = context_struct_to_string(policydb, context, scontext,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] selinux: fixed parse warning Using plain integer as NULL pointer
  2019-03-24 10:10 [PATCH] selinux: fixed parse warning Using plain integer as NULL pointer Hariprasad Kelam
@ 2019-03-24 10:57 ` Ondrej Mosnacek
  0 siblings, 0 replies; 2+ messages in thread
From: Ondrej Mosnacek @ 2019-03-24 10:57 UTC (permalink / raw)
  To: Hariprasad Kelam
  Cc: Paul Moore, Stephen Smalley, Eric Paris, Kees Cook,
	Richard Guy Briggs, jannh, Alexey Dobriyan, sgrover,
	peter.enderborg, Kent Overstreet, selinux,
	Linux kernel mailing list

On Sun, Mar 24, 2019 at 11:10 AM Hariprasad Kelam
<hariprasad.kelam@gmail.com> wrote:
> Changed  0 --> NULL to avoid sparse warning
>
> Sparse warning below:
>
> sudo make C=2 CF=-D__CHECK_ENDIAN__ M=security
>
>  CHECK   security/selinux/ss/services.c
> security/selinux/ss/services.c:1323:32: warning: Using plain integer as
> NULL pointer
>
> Signed-off-by: Hariprasad Kelam <hariprasad.kelam@gmail.com>
> ---
>  security/selinux/ss/services.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
> index ec62918..30cea59 100644
> --- a/security/selinux/ss/services.c
> +++ b/security/selinux/ss/services.c
> @@ -1320,7 +1320,7 @@ static int security_sid_to_context_core(struct selinux_state *state,
>         }
>         if (only_invalid && !context->len) {
>                 scontext = NULL;
> -               scontext_len = 0;
> +               scontext_len = NULL;
>                 rc = 0;

The warning is correct, but this patch is the wrong fix. I intended to
set the values to the objects pointed to by the pointers, not the
pointers themselves. As is, the assignments have no effect, because
they only modify the local variables, which are not used further in
the function. Fortunately, *scontext and *scontext_len are already set
to NULL/0 at the beginning of the function, so the code is technically
correct even without them.

The correct fix is actually to remove the assignments entirely. I'll
send a patch that does that tomorrow.

>         } else {
>                 rc = context_struct_to_string(policydb, context, scontext,
> --
> 2.7.4
>

Anyway, thank you for catching the mistake! One more reminder for me
to finally install sparse and add C=1 to my kernel build command
line...


--
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-24 10:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-24 10:10 [PATCH] selinux: fixed parse warning Using plain integer as NULL pointer Hariprasad Kelam
2019-03-24 10:57 ` Ondrej Mosnacek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).