LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH -next] selinux: correct the return value when loads initial sids
@ 2021-07-28 6:31 Xiu Jianfeng
2021-07-28 15:56 ` Paul Moore
0 siblings, 1 reply; 3+ messages in thread
From: Xiu Jianfeng @ 2021-07-28 6:31 UTC (permalink / raw)
To: paul, stephen.smalley.work, eparis; +Cc: selinux, linux-kernel, wangweiyang2
It should not return 0 when SID 0 is assigned to isids.
This patch fixes it.
Fixes: e3e0b582c321a ("selinux: remove unused initial SIDs and improve handling")
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
security/selinux/ss/policydb.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index defc5ef35c66..ad1183e18ce0 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -884,6 +884,7 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s)
if (sid == SECSID_NULL) {
pr_err("SELinux: SID 0 was assigned a context.\n");
+ rc = -EINVAL;
sidtab_destroy(s);
goto out;
}
--
2.17.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -next] selinux: correct the return value when loads initial sids
2021-07-28 6:31 [PATCH -next] selinux: correct the return value when loads initial sids Xiu Jianfeng
@ 2021-07-28 15:56 ` Paul Moore
2021-07-31 3:57 ` xiujianfeng
0 siblings, 1 reply; 3+ messages in thread
From: Paul Moore @ 2021-07-28 15:56 UTC (permalink / raw)
To: Xiu Jianfeng
Cc: Stephen Smalley, Eric Paris, selinux, linux-kernel, wangweiyang2
On Wed, Jul 28, 2021 at 2:30 AM Xiu Jianfeng <xiujianfeng@huawei.com> wrote:
>
> It should not return 0 when SID 0 is assigned to isids.
> This patch fixes it.
>
> Fixes: e3e0b582c321a ("selinux: remove unused initial SIDs and improve handling")
> Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
> ---
> security/selinux/ss/policydb.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
> index defc5ef35c66..ad1183e18ce0 100644
> --- a/security/selinux/ss/policydb.c
> +++ b/security/selinux/ss/policydb.c
> @@ -884,6 +884,7 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s)
>
> if (sid == SECSID_NULL) {
> pr_err("SELinux: SID 0 was assigned a context.\n");
> + rc = -EINVAL;
> sidtab_destroy(s);
> goto out;
> }
Hi Xiu Jianfeng,
Thanks for the patch, but since you are fixing the error handling in
policydb_load_isids(), would you mind respinning this patch to get rid
of the "out" label and just have all of the associated callers return
directly instead? I generally dislike jump targets that do nothing
else other than return a value; those 'goto X;' statements can easily
be converted into 'return Y;' statements.
Thanks.
--
paul moore
www.paul-moore.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -next] selinux: correct the return value when loads initial sids
2021-07-28 15:56 ` Paul Moore
@ 2021-07-31 3:57 ` xiujianfeng
0 siblings, 0 replies; 3+ messages in thread
From: xiujianfeng @ 2021-07-31 3:57 UTC (permalink / raw)
To: Paul Moore
Cc: Stephen Smalley, Eric Paris, selinux, linux-kernel, wangweiyang2
在 2021/7/28 23:56, Paul Moore 写道:
> On Wed, Jul 28, 2021 at 2:30 AM Xiu Jianfeng <xiujianfeng@huawei.com> wrote:
>> It should not return 0 when SID 0 is assigned to isids.
>> This patch fixes it.
>>
>> Fixes: e3e0b582c321a ("selinux: remove unused initial SIDs and improve handling")
>> Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
>> ---
>> security/selinux/ss/policydb.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
>> index defc5ef35c66..ad1183e18ce0 100644
>> --- a/security/selinux/ss/policydb.c
>> +++ b/security/selinux/ss/policydb.c
>> @@ -884,6 +884,7 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s)
>>
>> if (sid == SECSID_NULL) {
>> pr_err("SELinux: SID 0 was assigned a context.\n");
>> + rc = -EINVAL;
>> sidtab_destroy(s);
>> goto out;
>> }
> Hi Xiu Jianfeng,
>
> Thanks for the patch, but since you are fixing the error handling in
> policydb_load_isids(), would you mind respinning this patch to get rid
> of the "out" label and just have all of the associated callers return
> directly instead? I generally dislike jump targets that do nothing
> else other than return a value; those 'goto X;' statements can easily
> be converted into 'return Y;' statements.
no problem, please check the v2 patch.
>
> Thanks.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-31 3:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-28 6:31 [PATCH -next] selinux: correct the return value when loads initial sids Xiu Jianfeng
2021-07-28 15:56 ` Paul Moore
2021-07-31 3:57 ` xiujianfeng
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).