diff mbox

selinux: Remove unnecessary check of array base in selinux_set_mapping()

Message ID 20170316222652.125702-1-mka@chromium.org (mailing list archive)
State New, archived
Headers show

Commit Message

Matthias Kaehlcke March 16, 2017, 10:26 p.m. UTC
'perms' will never be NULL since it isn't a plain pointer but an array
of u32 values.

This fixes the following warning when building with clang:

security/selinux/ss/services.c:158:16: error: address of array
'p_in->perms' will always evaluate to 'true'
[-Werror,-Wpointer-bool-conversion]
                while (p_in->perms && p_in->perms[k]) {

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
 security/selinux/ss/services.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Grant Grundler March 23, 2017, 12:30 a.m. UTC | #1
[resending as plain text only - sorry]

Ping? Any feedback on this patch?

LGTM.

cheers,
grant

On Thu, Mar 16, 2017 at 3:26 PM, Matthias Kaehlcke <mka@chromium.org> wrote:
> 'perms' will never be NULL since it isn't a plain pointer but an array
> of u32 values.
>
> This fixes the following warning when building with clang:
>
> security/selinux/ss/services.c:158:16: error: address of array
> 'p_in->perms' will always evaluate to 'true'
> [-Werror,-Wpointer-bool-conversion]
>                 while (p_in->perms && p_in->perms[k]) {
>
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
>  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 082b20c78363..2f20b5f974f4 100644
> --- a/security/selinux/ss/services.c
> +++ b/security/selinux/ss/services.c
> @@ -155,7 +155,7 @@ static int selinux_set_mapping(struct policydb *pol,
>                 }
>
>                 k = 0;
> -               while (p_in->perms && p_in->perms[k]) {
> +               while (p_in->perms[k]) {
>                         /* An empty permission string skips ahead */
>                         if (!*p_in->perms[k]) {
>                                 k++;
> --
> 2.12.0.367.g23dc2f6d3c-goog
>
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paul Moore March 23, 2017, 12:08 p.m. UTC | #2
On Wed, Mar 22, 2017 at 8:28 PM, Grant Grundler <grundler@chromium.org> wrote:
> Ping? Any feedback on this patch?

It's on my list of patches to review, patience please.

> On Thu, Mar 16, 2017 at 3:26 PM, Matthias Kaehlcke <mka@chromium.org> wrote:
>>
>> 'perms' will never be NULL since it isn't a plain pointer but an array
>> of u32 values.
>>
>> This fixes the following warning when building with clang:
>>
>> security/selinux/ss/services.c:158:16: error: address of array
>> 'p_in->perms' will always evaluate to 'true'
>> [-Werror,-Wpointer-bool-conversion]
>>                 while (p_in->perms && p_in->perms[k]) {
>>
>> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
>> ---
>>  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 082b20c78363..2f20b5f974f4 100644
>> --- a/security/selinux/ss/services.c
>> +++ b/security/selinux/ss/services.c
>> @@ -155,7 +155,7 @@ static int selinux_set_mapping(struct policydb *pol,
>>                 }
>>
>>                 k = 0;
>> -               while (p_in->perms && p_in->perms[k]) {
>> +               while (p_in->perms[k]) {
>>                         /* An empty permission string skips ahead */
>>                         if (!*p_in->perms[k]) {
>>                                 k++;
>> --
>> 2.12.0.367.g23dc2f6d3c-goog
>>
>
Grant Grundler March 23, 2017, 5:34 p.m. UTC | #3
On Thu, Mar 23, 2017 at 5:08 AM, Paul Moore <paul@paul-moore.com> wrote:
> On Wed, Mar 22, 2017 at 8:28 PM, Grant Grundler <grundler@chromium.org> wrote:
>> Ping? Any feedback on this patch?
>
> It's on my list of patches to review, patience please.

No problem! Thank you!

just wanted confirmation it wasn't overlooked.

cheers,
grant

>
>> On Thu, Mar 16, 2017 at 3:26 PM, Matthias Kaehlcke <mka@chromium.org> wrote:
>>>
>>> 'perms' will never be NULL since it isn't a plain pointer but an array
>>> of u32 values.
>>>
>>> This fixes the following warning when building with clang:
>>>
>>> security/selinux/ss/services.c:158:16: error: address of array
>>> 'p_in->perms' will always evaluate to 'true'
>>> [-Werror,-Wpointer-bool-conversion]
>>>                 while (p_in->perms && p_in->perms[k]) {
>>>
>>> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
>>> ---
>>>  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 082b20c78363..2f20b5f974f4 100644
>>> --- a/security/selinux/ss/services.c
>>> +++ b/security/selinux/ss/services.c
>>> @@ -155,7 +155,7 @@ static int selinux_set_mapping(struct policydb *pol,
>>>                 }
>>>
>>>                 k = 0;
>>> -               while (p_in->perms && p_in->perms[k]) {
>>> +               while (p_in->perms[k]) {
>>>                         /* An empty permission string skips ahead */
>>>                         if (!*p_in->perms[k]) {
>>>                                 k++;
>>> --
>>> 2.12.0.367.g23dc2f6d3c-goog
>>>
>>
>
>
>
> --
> paul moore
> www.paul-moore.com
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paul Moore March 29, 2017, 10:59 p.m. UTC | #4
On Thu, Mar 23, 2017 at 1:34 PM, Grant Grundler <grundler@chromium.org> wrote:
> On Thu, Mar 23, 2017 at 5:08 AM, Paul Moore <paul@paul-moore.com> wrote:
>> On Wed, Mar 22, 2017 at 8:28 PM, Grant Grundler <grundler@chromium.org> wrote:
>>> Ping? Any feedback on this patch?
>>
>> It's on my list of patches to review, patience please.
>
> No problem! Thank you!
>
> just wanted confirmation it wasn't overlooked.

Merged, thanks for your patience.
diff mbox

Patch

diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index 082b20c78363..2f20b5f974f4 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -155,7 +155,7 @@  static int selinux_set_mapping(struct policydb *pol,
 		}
 
 		k = 0;
-		while (p_in->perms && p_in->perms[k]) {
+		while (p_in->perms[k]) {
 			/* An empty permission string skips ahead */
 			if (!*p_in->perms[k]) {
 				k++;