Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2076086ybp; Thu, 10 Oct 2019 01:45:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwtM8OTF/Kua4ETBwVRB20XdqjicYJ/VVn3wvM2HicBjoiq1xQl2NHA5yP1rxySHpYUqcoq X-Received: by 2002:a05:6402:13d5:: with SMTP id a21mr7184832edx.242.1570697125387; Thu, 10 Oct 2019 01:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570697125; cv=none; d=google.com; s=arc-20160816; b=X6CGnUmr1bOyEdpt3rKBCaqWO5VZazvTZfqdAxsdckQN6GjBEYu/9D8ug8bj4z5CUC gsYJRJazBYHq5+xPxWwG+1+7tn1vq1RS5oVOVAhUu0lea3nqILNiap9jqL46354ROMxD UJAcro92dbONcI4H1ClJ+bJn5zKqELxa2ukfrDeKX+Nd4SBJDasu50lB0L9wOOxTkIgH K/F6irGpZoss+JjKnvUDfBpN0nj6U0dc/EeUrmEhbSA8bIUKGnBSgrwEONrZs76ywoJb x12adTEaHBC39iIB9MOrfj7Ht65Vn7d/RMs5viLpagb0yD2nXHiTrn5bvcV8ayLM5EkS GwBQ== 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=Mzvx9RR7qzLMbK4aOPZtSl2nbsqHM7Q0D1Pj+YoNJeI=; b=LO1kjoQuG6P1ANPPseztFPZ3B3O9BoCyA2UZgtpEVMq9KCTZ3k8KqtV0KMG1bAqyxi xOj59XClRX/iGjyHYyTqLHdLOLuXAN89KfFXUgAFM7+gZl/GpC7o3WEY4TV+rZrPaL3A vx4uBu6wFknQASb9wsMk1NA5veLKsqeRtAOPmnleSgaSkI2gqYwW56UsnPGN1XFFS9ae 3gzzUvOT1/WnYlt8WpyhLqNuTEEYexl1N1WxZCJj6Kh8Z4l3aHIaJDXoFZWAm5FmSV/q um+dp+Gfk9VZ0o3dlq5hGYW6f/AOyBr2ohv1h37dd+cEovP8g/rCEyexbgTjRkrktavc 0E0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ThLi2d0w; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3si3439190edc.151.2019.10.10.01.45.01; Thu, 10 Oct 2019 01:45:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ThLi2d0w; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387660AbfJJIla (ORCPT + 99 others); Thu, 10 Oct 2019 04:41:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:45858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388342AbfJJIl1 (ORCPT ); Thu, 10 Oct 2019 04:41:27 -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 E8C962054F; Thu, 10 Oct 2019 08:41:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570696887; bh=uOi64M7D10KweumGcEk7pWtgTYT8TAKC8lUsJlYhmAQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ThLi2d0wp4X+T8lrazxv4xx30X2qVZfotrmxuv3n80op3O94BftpIV9Py1/FmFMiJ a4PtTrojpYDsXHnIWYpmYBO1CjI0HdLQJsC0EczyHbfC3BXLMsBjVioVVq0ektmISc tCme/6b+QsZwMr8UA4IaOjoiQtrE5CblvNM2rI08= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sascha Hauer , Mimi Zohar , Sasha Levin Subject: [PATCH 5.3 090/148] ima: fix freeing ongoing ahash_request Date: Thu, 10 Oct 2019 10:35:51 +0200 Message-Id: <20191010083616.787812636@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083609.660878383@linuxfoundation.org> References: <20191010083609.660878383@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: Sascha Hauer [ Upstream commit 4ece3125f21b1d42b84896c5646dbf0e878464e1 ] integrity_kernel_read() can fail in which case we forward to call ahash_request_free() on a currently running request. We have to wait for its completion before we can free the request. This was observed by interrupting a "find / -type f -xdev -print0 | xargs -0 cat 1>/dev/null" with ctrl-c on an IMA enabled filesystem. Signed-off-by: Sascha Hauer Signed-off-by: Mimi Zohar Signed-off-by: Sasha Levin --- security/integrity/ima/ima_crypto.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/security/integrity/ima/ima_crypto.c b/security/integrity/ima/ima_crypto.c index 7532b062be594..73044fc6a9521 100644 --- a/security/integrity/ima/ima_crypto.c +++ b/security/integrity/ima/ima_crypto.c @@ -271,6 +271,11 @@ static int ima_calc_file_hash_atfm(struct file *file, if (rc != rbuf_len) { if (rc >= 0) rc = -EINVAL; + /* + * Forward current rc, do not overwrite with return value + * from ahash_wait() + */ + ahash_wait(ahash_rc, &wait); goto out3; } -- 2.20.1