selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selinux: fix sparse warnings in policydb.c
@ 2020-01-16 13:19 Ondrej Mosnacek
  2020-01-16 16:08 ` Stephen Smalley
  0 siblings, 1 reply; 4+ messages in thread
From: Ondrej Mosnacek @ 2020-01-16 13:19 UTC (permalink / raw)
  To: selinux, Paul Moore; +Cc: Stephen Smalley

Two places used u32 where there should have been __le32.

Fixes sparse warnings:
  CHECK   [...]/security/selinux/ss/services.c
[...]/security/selinux/ss/policydb.c:2669:16: warning: incorrect type in assignment (different base types)
[...]/security/selinux/ss/policydb.c:2669:16:    expected unsigned int
[...]/security/selinux/ss/policydb.c:2669:16:    got restricted __le32 [usertype]
[...]/security/selinux/ss/policydb.c:2674:24: warning: incorrect type in assignment (different base types)
[...]/security/selinux/ss/policydb.c:2674:24:    expected unsigned int
[...]/security/selinux/ss/policydb.c:2674:24:    got restricted __le32 [usertype]
[...]/security/selinux/ss/policydb.c:2675:24: warning: incorrect type in assignment (different base types)
[...]/security/selinux/ss/policydb.c:2675:24:    expected unsigned int
[...]/security/selinux/ss/policydb.c:2675:24:    got restricted __le32 [usertype]
[...]/security/selinux/ss/policydb.c:2676:24: warning: incorrect type in assignment (different base types)
[...]/security/selinux/ss/policydb.c:2676:24:    expected unsigned int
[...]/security/selinux/ss/policydb.c:2676:24:    got restricted __le32 [usertype]
[...]/security/selinux/ss/policydb.c:2681:32: warning: incorrect type in assignment (different base types)
[...]/security/selinux/ss/policydb.c:2681:32:    expected unsigned int
[...]/security/selinux/ss/policydb.c:2681:32:    got restricted __le32 [usertype]
[...]/security/selinux/ss/policydb.c:2701:16: warning: incorrect type in assignment (different base types)
[...]/security/selinux/ss/policydb.c:2701:16:    expected unsigned int
[...]/security/selinux/ss/policydb.c:2701:16:    got restricted __le32 [usertype]
[...]/security/selinux/ss/policydb.c:2706:24: warning: incorrect type in assignment (different base types)
[...]/security/selinux/ss/policydb.c:2706:24:    expected unsigned int
[...]/security/selinux/ss/policydb.c:2706:24:    got restricted __le32 [usertype]
[...]/security/selinux/ss/policydb.c:2707:24: warning: incorrect type in assignment (different base types)
[...]/security/selinux/ss/policydb.c:2707:24:    expected unsigned int
[...]/security/selinux/ss/policydb.c:2707:24:    got restricted __le32 [usertype]

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
---
 security/selinux/ss/policydb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index e369b0092cdf..2aa7f2e1a8e7 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -2659,7 +2659,7 @@ static int role_trans_write(struct policydb *p, void *fp)
 {
 	struct role_trans *r = p->role_tr;
 	struct role_trans *tr;
-	u32 buf[3];
+	__le32 buf[3];
 	size_t nel;
 	int rc;
 
@@ -2691,7 +2691,7 @@ static int role_trans_write(struct policydb *p, void *fp)
 static int role_allow_write(struct role_allow *r, void *fp)
 {
 	struct role_allow *ra;
-	u32 buf[2];
+	__le32 buf[2];
 	size_t nel;
 	int rc;
 
-- 
2.24.1


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

* Re: [PATCH] selinux: fix sparse warnings in policydb.c
  2020-01-16 13:19 [PATCH] selinux: fix sparse warnings in policydb.c Ondrej Mosnacek
@ 2020-01-16 16:08 ` Stephen Smalley
  2020-01-16 16:10   ` Stephen Smalley
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Smalley @ 2020-01-16 16:08 UTC (permalink / raw)
  To: Ondrej Mosnacek, selinux, Paul Moore

On 1/16/20 8:19 AM, Ondrej Mosnacek wrote:
> Two places used u32 where there should have been __le32.
> 
> Fixes sparse warnings:
>    CHECK   [...]/security/selinux/ss/services.c
> [...]/security/selinux/ss/policydb.c:2669:16: warning: incorrect type in assignment (different base types)
> [...]/security/selinux/ss/policydb.c:2669:16:    expected unsigned int
> [...]/security/selinux/ss/policydb.c:2669:16:    got restricted __le32 [usertype]
> [...]/security/selinux/ss/policydb.c:2674:24: warning: incorrect type in assignment (different base types)
> [...]/security/selinux/ss/policydb.c:2674:24:    expected unsigned int
> [...]/security/selinux/ss/policydb.c:2674:24:    got restricted __le32 [usertype]
> [...]/security/selinux/ss/policydb.c:2675:24: warning: incorrect type in assignment (different base types)
> [...]/security/selinux/ss/policydb.c:2675:24:    expected unsigned int
> [...]/security/selinux/ss/policydb.c:2675:24:    got restricted __le32 [usertype]
> [...]/security/selinux/ss/policydb.c:2676:24: warning: incorrect type in assignment (different base types)
> [...]/security/selinux/ss/policydb.c:2676:24:    expected unsigned int
> [...]/security/selinux/ss/policydb.c:2676:24:    got restricted __le32 [usertype]
> [...]/security/selinux/ss/policydb.c:2681:32: warning: incorrect type in assignment (different base types)
> [...]/security/selinux/ss/policydb.c:2681:32:    expected unsigned int
> [...]/security/selinux/ss/policydb.c:2681:32:    got restricted __le32 [usertype]
> [...]/security/selinux/ss/policydb.c:2701:16: warning: incorrect type in assignment (different base types)
> [...]/security/selinux/ss/policydb.c:2701:16:    expected unsigned int
> [...]/security/selinux/ss/policydb.c:2701:16:    got restricted __le32 [usertype]
> [...]/security/selinux/ss/policydb.c:2706:24: warning: incorrect type in assignment (different base types)
> [...]/security/selinux/ss/policydb.c:2706:24:    expected unsigned int
> [...]/security/selinux/ss/policydb.c:2706:24:    got restricted __le32 [usertype]
> [...]/security/selinux/ss/policydb.c:2707:24: warning: incorrect type in assignment (different base types)
> [...]/security/selinux/ss/policydb.c:2707:24:    expected unsigned int
> [...]/security/selinux/ss/policydb.c:2707:24:    got restricted __le32 [usertype]
> 
> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>

Reviewed-by: Stephen Smalley <sds@tycho.nsa.gov>

> ---
>   security/selinux/ss/policydb.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
> index e369b0092cdf..2aa7f2e1a8e7 100644
> --- a/security/selinux/ss/policydb.c
> +++ b/security/selinux/ss/policydb.c
> @@ -2659,7 +2659,7 @@ static int role_trans_write(struct policydb *p, void *fp)
>   {
>   	struct role_trans *r = p->role_tr;
>   	struct role_trans *tr;
> -	u32 buf[3];
> +	__le32 buf[3];
>   	size_t nel;
>   	int rc;
>   
> @@ -2691,7 +2691,7 @@ static int role_trans_write(struct policydb *p, void *fp)
>   static int role_allow_write(struct role_allow *r, void *fp)
>   {
>   	struct role_allow *ra;
> -	u32 buf[2];
> +	__le32 buf[2];
>   	size_t nel;
>   	int rc;
>   
> 


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

* Re: [PATCH] selinux: fix sparse warnings in policydb.c
  2020-01-16 16:08 ` Stephen Smalley
@ 2020-01-16 16:10   ` Stephen Smalley
  2020-01-16 16:21     ` Ondrej Mosnacek
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Smalley @ 2020-01-16 16:10 UTC (permalink / raw)
  To: Ondrej Mosnacek, selinux, Paul Moore

On 1/16/20 11:08 AM, Stephen Smalley wrote:
> On 1/16/20 8:19 AM, Ondrej Mosnacek wrote:
>> Two places used u32 where there should have been __le32.
>>
>> Fixes sparse warnings:
>>    CHECK   [...]/security/selinux/ss/services.c
>> [...]/security/selinux/ss/policydb.c:2669:16: warning: incorrect type 
>> in assignment (different base types)
>> [...]/security/selinux/ss/policydb.c:2669:16:    expected unsigned int
>> [...]/security/selinux/ss/policydb.c:2669:16:    got restricted __le32 
>> [usertype]
>> [...]/security/selinux/ss/policydb.c:2674:24: warning: incorrect type 
>> in assignment (different base types)
>> [...]/security/selinux/ss/policydb.c:2674:24:    expected unsigned int
>> [...]/security/selinux/ss/policydb.c:2674:24:    got restricted __le32 
>> [usertype]
>> [...]/security/selinux/ss/policydb.c:2675:24: warning: incorrect type 
>> in assignment (different base types)
>> [...]/security/selinux/ss/policydb.c:2675:24:    expected unsigned int
>> [...]/security/selinux/ss/policydb.c:2675:24:    got restricted __le32 
>> [usertype]
>> [...]/security/selinux/ss/policydb.c:2676:24: warning: incorrect type 
>> in assignment (different base types)
>> [...]/security/selinux/ss/policydb.c:2676:24:    expected unsigned int
>> [...]/security/selinux/ss/policydb.c:2676:24:    got restricted __le32 
>> [usertype]
>> [...]/security/selinux/ss/policydb.c:2681:32: warning: incorrect type 
>> in assignment (different base types)
>> [...]/security/selinux/ss/policydb.c:2681:32:    expected unsigned int
>> [...]/security/selinux/ss/policydb.c:2681:32:    got restricted __le32 
>> [usertype]
>> [...]/security/selinux/ss/policydb.c:2701:16: warning: incorrect type 
>> in assignment (different base types)
>> [...]/security/selinux/ss/policydb.c:2701:16:    expected unsigned int
>> [...]/security/selinux/ss/policydb.c:2701:16:    got restricted __le32 
>> [usertype]
>> [...]/security/selinux/ss/policydb.c:2706:24: warning: incorrect type 
>> in assignment (different base types)
>> [...]/security/selinux/ss/policydb.c:2706:24:    expected unsigned int
>> [...]/security/selinux/ss/policydb.c:2706:24:    got restricted __le32 
>> [usertype]
>> [...]/security/selinux/ss/policydb.c:2707:24: warning: incorrect type 
>> in assignment (different base types)
>> [...]/security/selinux/ss/policydb.c:2707:24:    expected unsigned int
>> [...]/security/selinux/ss/policydb.c:2707:24:    got restricted __le32 
>> [usertype]
>>
>> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> 
> Reviewed-by: Stephen Smalley <sds@tycho.nsa.gov>

However, note that checkpatch doesn't like your subject line.
WARNING: A patch subject line should describe the change not the tool 
that found it

> 
>> ---
>>   security/selinux/ss/policydb.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/security/selinux/ss/policydb.c 
>> b/security/selinux/ss/policydb.c
>> index e369b0092cdf..2aa7f2e1a8e7 100644
>> --- a/security/selinux/ss/policydb.c
>> +++ b/security/selinux/ss/policydb.c
>> @@ -2659,7 +2659,7 @@ static int role_trans_write(struct policydb *p, 
>> void *fp)
>>   {
>>       struct role_trans *r = p->role_tr;
>>       struct role_trans *tr;
>> -    u32 buf[3];
>> +    __le32 buf[3];
>>       size_t nel;
>>       int rc;
>> @@ -2691,7 +2691,7 @@ static int role_trans_write(struct policydb *p, 
>> void *fp)
>>   static int role_allow_write(struct role_allow *r, void *fp)
>>   {
>>       struct role_allow *ra;
>> -    u32 buf[2];
>> +    __le32 buf[2];
>>       size_t nel;
>>       int rc;
>>
> 


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

* Re: [PATCH] selinux: fix sparse warnings in policydb.c
  2020-01-16 16:10   ` Stephen Smalley
@ 2020-01-16 16:21     ` Ondrej Mosnacek
  0 siblings, 0 replies; 4+ messages in thread
From: Ondrej Mosnacek @ 2020-01-16 16:21 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: SElinux list, Paul Moore

On Thu, Jan 16, 2020 at 5:10 PM Stephen Smalley <sds@tycho.nsa.gov> wrote:
> On 1/16/20 11:08 AM, Stephen Smalley wrote:
> > On 1/16/20 8:19 AM, Ondrej Mosnacek wrote:
> >> Two places used u32 where there should have been __le32.
> >>
> >> Fixes sparse warnings:
> >>    CHECK   [...]/security/selinux/ss/services.c
> >> [...]/security/selinux/ss/policydb.c:2669:16: warning: incorrect type
> >> in assignment (different base types)
> >> [...]/security/selinux/ss/policydb.c:2669:16:    expected unsigned int
> >> [...]/security/selinux/ss/policydb.c:2669:16:    got restricted __le32
> >> [usertype]
> >> [...]/security/selinux/ss/policydb.c:2674:24: warning: incorrect type
> >> in assignment (different base types)
> >> [...]/security/selinux/ss/policydb.c:2674:24:    expected unsigned int
> >> [...]/security/selinux/ss/policydb.c:2674:24:    got restricted __le32
> >> [usertype]
> >> [...]/security/selinux/ss/policydb.c:2675:24: warning: incorrect type
> >> in assignment (different base types)
> >> [...]/security/selinux/ss/policydb.c:2675:24:    expected unsigned int
> >> [...]/security/selinux/ss/policydb.c:2675:24:    got restricted __le32
> >> [usertype]
> >> [...]/security/selinux/ss/policydb.c:2676:24: warning: incorrect type
> >> in assignment (different base types)
> >> [...]/security/selinux/ss/policydb.c:2676:24:    expected unsigned int
> >> [...]/security/selinux/ss/policydb.c:2676:24:    got restricted __le32
> >> [usertype]
> >> [...]/security/selinux/ss/policydb.c:2681:32: warning: incorrect type
> >> in assignment (different base types)
> >> [...]/security/selinux/ss/policydb.c:2681:32:    expected unsigned int
> >> [...]/security/selinux/ss/policydb.c:2681:32:    got restricted __le32
> >> [usertype]
> >> [...]/security/selinux/ss/policydb.c:2701:16: warning: incorrect type
> >> in assignment (different base types)
> >> [...]/security/selinux/ss/policydb.c:2701:16:    expected unsigned int
> >> [...]/security/selinux/ss/policydb.c:2701:16:    got restricted __le32
> >> [usertype]
> >> [...]/security/selinux/ss/policydb.c:2706:24: warning: incorrect type
> >> in assignment (different base types)
> >> [...]/security/selinux/ss/policydb.c:2706:24:    expected unsigned int
> >> [...]/security/selinux/ss/policydb.c:2706:24:    got restricted __le32
> >> [usertype]
> >> [...]/security/selinux/ss/policydb.c:2707:24: warning: incorrect type
> >> in assignment (different base types)
> >> [...]/security/selinux/ss/policydb.c:2707:24:    expected unsigned int
> >> [...]/security/selinux/ss/policydb.c:2707:24:    got restricted __le32
> >> [usertype]
> >>
> >> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> >
> > Reviewed-by: Stephen Smalley <sds@tycho.nsa.gov>
>
> However, note that checkpatch doesn't like your subject line.
> WARNING: A patch subject line should describe the change not the tool
> that found it

Hm, I run checkpatch.pl from a pre-commit git hook, so it likely only
looks at the diff itself... I'll see if I can tweak the hook to check
a full patch generated from the commit.

It has a good point, though. I'll reword the subject.

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


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

end of thread, other threads:[~2020-01-16 16:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-16 13:19 [PATCH] selinux: fix sparse warnings in policydb.c Ondrej Mosnacek
2020-01-16 16:08 ` Stephen Smalley
2020-01-16 16:10   ` Stephen Smalley
2020-01-16 16:21     ` 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).