Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp120404pxv; Fri, 30 Jul 2021 20:58:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEPwiKjwb0bMFnedO8pHASrDOEer3at8CMoYlKHZVb8tSMn0u6OoV96dCP0P90q7kL4ILc X-Received: by 2002:a05:6638:381e:: with SMTP id i30mr4774685jav.17.1627703892832; Fri, 30 Jul 2021 20:58:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627703892; cv=none; d=google.com; s=arc-20160816; b=EXmbxyxThtmnaCXL6JWPK2j6HTKNo3CtkKf4dhg8/mk7rgK+uFxgFNWSOxZpS7AMOr prY+3JfkmmugoI/H+0yrDcRQWF4E/pOrTTJFjNq7haJaAgWfUW/K8PJ/89C2RE1XUVr2 lTevrqkeuA2pU6q8c4DnkuLQt8Gs5uZDCC3dXdLovoTvh4uZiSqB6fYP58F5nc0lSh0J sJw9HtzSoiA8XPWTqaUA1n6GfU6gL3LNUran83QtwldQGck0iDUVkaiuawIu2481YaHa g2vj30GH60x3TwAVL3t4Y8np38hkzJDWTANWGSsHABNE2h/IqWQp7qUKilEe+W67l4mP 5a7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=myJvcPS+4IH9PR/ObNkuPydxQZEzVf7HAtbXbRkwFbg=; b=KWUQ4/dXczHMOMKpzycIdJS5lHPUF1oRfhB/BryK9Mby9wt0swgUumSOEcbcwIqpZO 86Sh4JJDrOWQprwkd1Tg+k6378sMmPGWJp7lFBgjKGGu6eIdR3VuF8g8170g3Pd2wAwl PQjO1Pnq4ibnXO21ScgPpfhOD1L9/VNSyWxIIFnJecA+zNCV9VzVJXBO7JStk1ZWtgHr zSGWr45fQYWckZjWUJLS/SyqV9hWrihHGnieDAd4tmOosAoBEolcQvYpvy6zo+lZ2bMC n1atkDYtvrlRLA28zeFi+uXGzvUJYf8Fi8CHQIZL8yicu1ydMO4uPIFCw5h+kNDaRSG2 SeMA== 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 t5si4511776ile.92.2021.07.30.20.57.59; Fri, 30 Jul 2021 20:58:12 -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 S231643AbhGaD5R (ORCPT + 99 others); Fri, 30 Jul 2021 23:57:17 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:12433 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231491AbhGaD5Q (ORCPT ); Fri, 30 Jul 2021 23:57:16 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Gc9Nf39Hnzcjxq; Sat, 31 Jul 2021 11:53:38 +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; Sat, 31 Jul 2021 11:57:05 +0800 Received: from [10.67.110.112] (10.67.110.112) 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; Sat, 31 Jul 2021 11:57:04 +0800 Subject: Re: [PATCH -next] selinux: correct the return value when loads initial sids To: Paul Moore CC: Stephen Smalley , Eric Paris , , , References: <20210728063110.3652-1-xiujianfeng@huawei.com> From: xiujianfeng Message-ID: <8e53b6ba-2528-1509-71ec-b6ff8dad1e18@huawei.com> Date: Sat, 31 Jul 2021 11:57:04 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.110.112] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) 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 在 2021/7/28 23:56, Paul Moore 写道: > On Wed, Jul 28, 2021 at 2:30 AM Xiu Jianfeng 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 >> --- >> 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. >