From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC9FECA0EC1 for ; Mon, 11 Sep 2023 21:21:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344793AbjIKVOr (ORCPT ); Mon, 11 Sep 2023 17:14:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240450AbjIKOof (ORCPT ); Mon, 11 Sep 2023 10:44:35 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4CC112A for ; Mon, 11 Sep 2023 07:44:30 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 138F0C433C8; Mon, 11 Sep 2023 14:44:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1694443470; bh=kuN/VM9N/3+XyiciTfQO12oHAN+oeUm1hXyVN/Emmls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bbh9qBlS4THe/kLIKzo5UhOWaK/gIX6Yh7A4BNijHSzeVA9Opb+K1UzenfXyNPgXZ aXP2aUhFXrpmS8tk4zdqoUKi6iNTrXMBTae2heb/RhbZN4X162/PqduxjfEHVKtdQz YTqMX7xwQBXYBv/AgSwPyzHA9xAKby8uLdMBxv+0= 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 6.4 361/737] smackfs: Prevent underflow in smk_set_cipso() Date: Mon, 11 Sep 2023 15:43:40 +0200 Message-ID: <20230911134700.615059686@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230911134650.286315610@linuxfoundation.org> References: <20230911134650.286315610@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 6.4-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 5590eaad241bb..25f67d1b5c73e 100644 --- a/security/smack/smackfs.c +++ b/security/smack/smackfs.c @@ -896,7 +896,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