Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5765508pxv; Wed, 28 Jul 2021 20:16:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqRJgjYDpqztCM6Z7Bbe4tl/4+KT414ebjelCow6Da4PpdiV3xOncQ6ayrM3+19Nr59kPe X-Received: by 2002:a02:c8d0:: with SMTP id q16mr2562403jao.110.1627528602492; Wed, 28 Jul 2021 20:16:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627528602; cv=none; d=google.com; s=arc-20160816; b=uMtshwwpmctgUhuGEGJNUOGhyy2+SuyD2GNoNFq0t4Vu1iNfCofgSmEzz+F9JXxlHw TchZyzSndqu0Lk+7cIhz24ThSMRege978m2s4+cabQdkf/h1rkTI9Yvnl2RCFvF6p3CX oCHRCPE91AJS8OTpdaFKwrvT657odWLCWjAb1VHSXJRvW5H+Y1tLxT6mwbFAUzyg2jSY U1eWEv35jhhQvxTnk0jOK0bVWtlFGA9nwkdnJdYOBDrO7atW1aOD/YyUpwGs2d8HQjQn ZxGlQ99VH5Uw2h9NTSeVoBRA4bx9IkNCbQhsEBYikcOxAl2Q4bj/LoJq3omCDbvkBPP8 h/tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=MZQyTtofbUyBz7Zf4L75cncKd20Mm+pvnAkDhBBoB3U=; b=LCf5GUKKOsiQg1wmqtiJiukaoPBIfNI3c0cUqlywzKuf+7lnnkGlnfXNiwYRagIh1L Yj71E/YbUCnzJceX+zyUdltwiUA17VCyI6TnNiotYaDjNVzK0syHMcV06TNi1GNfGOMR MvaARP+KND0tjLsWIFJSc0wpgKDb4o37Ng0dbc7vTRXtLClvDpPjIFsMA6l4YUEmovpt izRa9DbDC7f6Atm8KrmVm0aReCMogpLHzIHjNkX372geMIxY2UoyJUCfcGfCToqwT3OV 3SgdI7gf6PiEC0se6EMgQ0yPGQ/Pb/4PEja4rIBhAtn67xhNvMlK7a0pVT/MkOpofibS 2U/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o14si1814651ioo.4.2021.07.28.20.16.31; Wed, 28 Jul 2021 20:16:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233507AbhG2DPj (ORCPT + 99 others); Wed, 28 Jul 2021 23:15:39 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:7765 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233297AbhG2DPh (ORCPT ); Wed, 28 Jul 2021 23:15:37 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GZwVm4ggHzYh8R; Thu, 29 Jul 2021 11:09:36 +0800 (CST) Received: from dggpeml500023.china.huawei.com (7.185.36.114) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 29 Jul 2021 11:15:33 +0800 Received: from ubuntu1804.huawei.com (10.67.174.58) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 29 Jul 2021 11:15:29 +0800 From: Xiu Jianfeng To: , , CC: , , Subject: [PATCH -next, v2] selinux: correct the return value when loads initial sids Date: Thu, 29 Jul 2021 11:16:44 +0800 Message-ID: <20210729031644.47679-1-xiujianfeng@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.58] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500023.china.huawei.com (7.185.36.114) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It should not return 0 when SID 0 is assigned to isids. This patch fixes it. v2: remove the "out" label and return directly. Fixes: e3e0b582c321a ("selinux: remove unused initial SIDs and improve handling") Signed-off-by: Xiu Jianfeng --- security/selinux/ss/policydb.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c index defc5ef35c66..0ae1b718194a 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c @@ -874,7 +874,7 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s) rc = sidtab_init(s); if (rc) { pr_err("SELinux: out of memory on SID table init\n"); - goto out; + return rc; } head = p->ocontexts[OCON_ISID]; @@ -885,7 +885,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"); sidtab_destroy(s); - goto out; + return -EINVAL; } /* Ignore initial SIDs unused by this kernel. */ @@ -897,12 +897,10 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s) pr_err("SELinux: unable to load initial SID %s.\n", name); sidtab_destroy(s); - goto out; + return rc; } } - rc = 0; -out: - return rc; + return 0; } int policydb_class_isvalid(struct policydb *p, unsigned int class) -- 2.17.1