Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4451624imw; Tue, 19 Jul 2022 06:55:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v2Jjy5bBBXvvCd2F/nDir1+4akk5y7JLZ0vMxZXzF5QE86+NLCGKA41B18MrenKi1gVpfB X-Received: by 2002:a05:6402:5001:b0:437:8918:8dbe with SMTP id p1-20020a056402500100b0043789188dbemr43456213eda.70.1658238920239; Tue, 19 Jul 2022 06:55:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658238920; cv=none; d=google.com; s=arc-20160816; b=fXPpO4vinHH92BQyupD059o41Yr4lH7G9fjEKFd5Nr9q8o4HuiQHg6CSMPzA55+5k6 OluFNLb1FwDZSRVUyUCmQjWx8p9m4mxNq2YQBLxU3C6nLXkAFrIpphu0JMF3EA2x6mat g5C85rF7ppJuavb7i89pBNuyZBaqBPjJaerGEJHElEYAoAlqp9qh+HO/g2Py6ffdfGVV vRVMK4EZQZiYwKQjA8YN+9irryrq5BDYkTVkBvXpEjsd4LocZQjca9zyx4ZIieCbtGLJ 1d8Cv9RW4zvHZ5fUyxfF6CppjwRYn4wSQ6DkwCzg/eq48S2NcMFJFJ9oTewfGEC2TU+T GdLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YhI00JQlFOIIysbmWvCHNyKwY4NjJfoJx5GiaYjbTNk=; b=NHeprJ7a16t9DgUQtB1fcPginnlsv5F0HsNB+EP8GcZZuLrhYSdQRL/kg6bMS6nTbZ nhmUIv5jYMyFacLIM1kuFpO+fJeUEcQLk7e763tt0i92c2opl15EMq/VwVps5B5f9/Rh u3CJaiXns43v7TkBb87F4YcXOMRcPY7ASH49Idk87v26zQnPyV2/P8ipJHnaj4Lakm4/ EA/JE/H/7ZX29sfn+rQBCMsIdSvVe5C+K4g+m314gjzcEKRuvF5iY5n2zuTYSA6lVjC+ UdLK9Kv2f4oJzz4Kf/y/NLaiGRK4XGAQ/rGwLFCC0pHWBb+J4dGplZZURVGKwtSG0s7i 2kGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zMpGDTp2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cr2-20020a170906d54200b006ff278107bbsi22982141ejc.597.2022.07.19.06.54.55; Tue, 19 Jul 2022 06:55:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zMpGDTp2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240268AbiGSMcS (ORCPT + 99 others); Tue, 19 Jul 2022 08:32:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240110AbiGSMbr (ORCPT ); Tue, 19 Jul 2022 08:31:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00FC06EE9F; Tue, 19 Jul 2022 05:12:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AECE6B81B88; Tue, 19 Jul 2022 12:12:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1824CC341C6; Tue, 19 Jul 2022 12:11:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232719; bh=/foHS7/bjJySprsx0ogSWiKEnqYEL4JPTOYDgaRIPao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zMpGDTp2+vsFUIIYjc+fPRMxEPtArX/HnIBEv4M/GiXKeM4uuHszBnJ5vkdAMBNWd +lng+PN/zTyf4COZaQyRD6CyDEilso3BUsu0+diAl6Hg53+yKgbQSVfQeq8iyglpOd PvK1QfomU0aCel+FuEeGxxtJlo1So+gDEut2onkQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Huaxin Lu , Mimi Zohar , Sasha Levin Subject: [PATCH 5.15 041/167] ima: Fix a potential integer overflow in ima_appraise_measurement Date: Tue, 19 Jul 2022 13:52:53 +0200 Message-Id: <20220719114700.650088221@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114656.750574879@linuxfoundation.org> References: <20220719114656.750574879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huaxin Lu [ Upstream commit d2ee2cfc4aa85ff6a2a3b198a3a524ec54e3d999 ] When the ima-modsig is enabled, the rc passed to evm_verifyxattr() may be negative, which may cause the integer overflow problem. Fixes: 39b07096364a ("ima: Implement support for module-style appended signatures") Signed-off-by: Huaxin Lu Signed-off-by: Mimi Zohar Signed-off-by: Sasha Levin --- security/integrity/ima/ima_appraise.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c index dbba51583e7c..ed04bb7c7512 100644 --- a/security/integrity/ima/ima_appraise.c +++ b/security/integrity/ima/ima_appraise.c @@ -408,7 +408,8 @@ int ima_appraise_measurement(enum ima_hooks func, goto out; } - status = evm_verifyxattr(dentry, XATTR_NAME_IMA, xattr_value, rc, iint); + status = evm_verifyxattr(dentry, XATTR_NAME_IMA, xattr_value, + rc < 0 ? 0 : rc, iint); switch (status) { case INTEGRITY_PASS: case INTEGRITY_PASS_IMMUTABLE: -- 2.35.1