Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp536062pxx; Wed, 28 Oct 2020 10:31:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycJmquWEQu48UYdYQg8VEjmMgQHDMgFtCzZE6GaVjle8sQkeyUIYwaBBL9eK+QDbSXdqWx X-Received: by 2002:a17:906:f9d1:: with SMTP id lj17mr167055ejb.280.1603906313386; Wed, 28 Oct 2020 10:31:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603906313; cv=none; d=google.com; s=arc-20160816; b=JIqxWn1KovOtZPQ71DnLEyjWRT4TZbfoAhdvKLOLcXbQpRE9L89Hxz6rEXOiyJSnmp IIe9Rnaho9+AHLESVToPFlafh1KxR64KFqQwB2zXSWq9uWXsZk8yikrzt44uHReeQqsl cZVm9kbJiAE6oZVeqlABIdH5KzyDq+RbVWMzegSMW+p56DOWcqDLFyRkdm52PR6Q/HhO nV4takEM8wWla85/c5kMc/NJm72UyRrVL4pLhCMS1kru1G+VqZnL5xIR2Rt6BlPnceQO U2r0KKxy42FJunB08B0SFTATAEsLQRzj99eDe/irxmefysr/+lsTOrypKwAo1mB1+cyY znzw== 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=tZ5+sx90/akyiMdqB1rr98Qt6babWxGvLpBFodKMhAc=; b=BL8qBJbnW0kkr8UFhE0VaJrLwj73KzQEMJs05acqhJtFI9WMou9eRXhNsh4FUF0yKh hRZQD7SPo0qc6BJqFQcSUxggZjqz7GUjeFNoY71tNIu6b2+8fefAyuw7VUSz0tuGpKco y9tyRasSXADjUOVqUidLp7voymAWhg9h3xKzdNZrGB8zL+qV8skEVVrGDQz8SCj9c2ow UIc/X2fHVu5yOTPy+hxSsCSwKGkpkuDiXwjWImjuNja6XJFtBlWdPgGmeyMYG47Klwvy C99eKNhOwA2Yw6MtY1ZaX2TiyAI0G6MmzThgK7TgwDzTsBCHT9upcN1/q2q7UfvjWTxM Zy9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1KUX6+fF; 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 i5si3856525ejx.656.2020.10.28.10.31.30; Wed, 28 Oct 2020 10:31: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=1KUX6+fF; 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 S1821410AbgJ0Rn3 (ORCPT + 99 others); Tue, 27 Oct 2020 13:43:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:58812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2902281AbgJ0OcA (ORCPT ); Tue, 27 Oct 2020 10:32:00 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 87C2820754; Tue, 27 Oct 2020 14:31:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809120; bh=c8wDAXu4cH/SVSFcKyJJjTYM7/BaI6/wMP+Z9tPj/Fw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1KUX6+fFyVwrmDtkIy9r/WF0UTe0H/vHbdwM8GlfSzEGNCgYJgh2B3x1xd4q1kTY0 h0qe7NX0HQGRKpeUUORKsUjkrZbDIHXBm5p7BYcPFgi1x8/xPHhPsEHWYFBAmUfWG4 SlIuPxDBq8msfAjiJodkHMz/tlCXuTTV9gZyB53s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roberto Sassu , Mimi Zohar Subject: [PATCH 5.4 052/408] ima: Dont ignore errors from crypto_shash_update() Date: Tue, 27 Oct 2020 14:49:50 +0100 Message-Id: <20201027135457.485388717@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roberto Sassu commit 60386b854008adc951c470067f90a2d85b5d520f upstream. Errors returned by crypto_shash_update() are not checked in ima_calc_boot_aggregate_tfm() and thus can be overwritten at the next iteration of the loop. This patch adds a check after calling crypto_shash_update() and returns immediately if the result is not zero. Cc: stable@vger.kernel.org Fixes: 3323eec921efd ("integrity: IMA as an integrity service provider") Signed-off-by: Roberto Sassu Signed-off-by: Mimi Zohar Signed-off-by: Greg Kroah-Hartman --- security/integrity/ima/ima_crypto.c | 2 ++ 1 file changed, 2 insertions(+) --- a/security/integrity/ima/ima_crypto.c +++ b/security/integrity/ima/ima_crypto.c @@ -688,6 +688,8 @@ static int ima_calc_boot_aggregate_tfm(c /* now accumulate with current aggregate */ rc = crypto_shash_update(shash, d.digest, crypto_shash_digestsize(tfm)); + if (rc != 0) + return rc; } if (!rc) crypto_shash_final(shash, digest);