Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2634506pxa; Mon, 17 Aug 2020 15:02:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFQO1U0jU3IFxA/5g41L+8HhWEH4sdzry7Xqu647GMLpUFdOeCn9KA990/gFoCwEYWDmLz X-Received: by 2002:a17:907:208e:: with SMTP id pv14mr18269659ejb.438.1597701773802; Mon, 17 Aug 2020 15:02:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597701773; cv=none; d=google.com; s=arc-20160816; b=lnVQeIKvbVo5R9yG3N3hA4Ec30IF/ZW7+zyl/ASwUDLAp/2p37T2GK/prafVhVD0YX glDG3nlDr+pQgG2ele0cT0kjVWdoA/km+psmlU1JJS6KbpO7vIAE/9ffwk4nm0p8cyHE aSB8wKt53WVqRAgpmAZfeTQSN2xNEWATqjmjLKgYcS0YqNOTMcaVdvcfRy2rSzHN3v+o emOCcmddv4vyyh7kDCMHvA93SHPmfnXHqMxVNra2hxhlGCzHz6N/bYZ708/14vey3Lp8 sAICa91n9FikUmT4lWPPwGZVdxW15I0w5tK6BqdPLJ6MM8C1VY/Yc1BwFIFHCYzq76ab HR2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=I8FUcUUM8QVGnG6T/lOVAUzezeQheSrwiSaljBPDT6c=; b=CQ/k+kgmzpPA6sSojrkzqX8dHhLAFt+nqywyVvvKBED5SrKtcaNEqegIQJsrRb1Gwt R/K/pQPjt1fkSvxi/sZCATBZEGTXCUUjuM5YBZ9BgCc67fdxdH7Qk6xl2XhcTrR44saM kXNtxhXrXP+rwUx3D2t0OAQw5X5HPEN/pOPevDPqoO45ZiiMp9Bl9bEmBHb5I0iUPnNs DVYoA0R1DG1sD2nN9QyJnF2NWWS+YtWi/4CVfn6CdzeC29jmgPiARIVU9vde8mNF9LED bGT2UvjXi0uCBOG5AxUtER9FQa3pDXxA1qlQKZ9hTS9OaLXjbb+QtYuILaRLC1tf774n afZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="A/HOCqVF"; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dd10si12077333edb.66.2020.08.17.15.02.30; Mon, 17 Aug 2020 15:02:53 -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; dkim=pass header.i=@kernel.org header.s=default header.b="A/HOCqVF"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730606AbgHQPif (ORCPT + 99 others); Mon, 17 Aug 2020 11:38:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:60116 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730082AbgHQPcb (ORCPT ); Mon, 17 Aug 2020 11:32:31 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 71221207DA; Mon, 17 Aug 2020 15:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678351; bh=bN7E5iG/RTgo3CgEpGacs6B2YD4jqwur/wMV2RNafec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A/HOCqVFqxkR7Nd8GbsRN9TOMED9l3WePPa6L2C29PjJMBKLzL9tFmiHYYlVW3hSu SScwp+FMQjYN1YhSooPE2cX84UFLZW/O3Il+pIu6tG8aQ0kPE4eGLk5r63KenT4l0U zPicJXlOeXl0BVTtfYd8v3MlQOcg2u3ykGAstPYk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Casey Schaufler , Sasha Levin Subject: [PATCH 5.8 303/464] Smack: prevent underflow in smk_set_cipso() Date: Mon, 17 Aug 2020 17:14:16 +0200 Message-Id: <20200817143848.319245665@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit 42a2df3e829f3c5562090391b33714b2e2e5ad4a ] We have an upper bound on "maplevel" but forgot to check for negative values. 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 2bae1fc493d16..9c4308077574c 100644 --- a/security/smack/smackfs.c +++ b/security/smack/smackfs.c @@ -884,7 +884,7 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf, } ret = sscanf(rule, "%d", &maplevel); - if (ret != 1 || maplevel > SMACK_CIPSO_MAXLEVEL) + if (ret != 1 || maplevel < 0 || maplevel > SMACK_CIPSO_MAXLEVEL) goto out; rule += SMK_DIGITLEN; -- 2.25.1