From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F8682E63B for ; Wed, 20 Sep 2023 12:12:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4714CC433CA; Wed, 20 Sep 2023 12:12:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1695211966; bh=/X0ZS88Om5kBqibCwbggwdQtP6p1baytKPFP9YCMk54=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D62udtvZyV5Py11CsjA6baYZoZTkmkAD6SSuMxtSdVc0sLbgShnt6awh6KJsgkqbj /+Zk3Aoo1hgfc4EspKHK6YC4eDaXa16V8wQoYCBt1rAJuXGG/zRz5oq6sOoTOszwTI lV2Me6oFkWkX4INkRjuGJ/jRKog6iA0bxnja/eEE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Casey Schaufler , Sasha Levin Subject: [PATCH 4.19 102/273] smackfs: Prevent underflow in smk_set_cipso() Date: Wed, 20 Sep 2023 13:29:02 +0200 Message-ID: <20230920112849.603114144@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230920112846.440597133@linuxfoundation.org> References: <20230920112846.440597133@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter [ Upstream commit 3ad49d37cf5759c3b8b68d02e3563f633d9c1aee ] There is a upper bound to "catlen" but no lower bound to prevent negatives. I don't see that this necessarily causes a problem but we may as well be safe. Fixes: e114e473771c ("Smack: Simplified Mandatory Access Control Kernel") Signed-off-by: Dan Carpenter Signed-off-by: Casey Schaufler Signed-off-by: Sasha Levin --- security/smack/smackfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c index a9c516362170a..61e734baa332a 100644 --- a/security/smack/smackfs.c +++ b/security/smack/smackfs.c @@ -923,7 +923,7 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf, } ret = sscanf(rule, "%d", &catlen); - if (ret != 1 || catlen > SMACK_CIPSO_MAXCATNUM) + if (ret != 1 || catlen < 0 || catlen > SMACK_CIPSO_MAXCATNUM) goto out; if (format == SMK_FIXED24_FMT && -- 2.40.1