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 X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B9B9C43331 for ; Tue, 12 Nov 2019 17:33:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1BC6621925 for ; Tue, 12 Nov 2019 17:33:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="ihsqak0b" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727450AbfKLRdP (ORCPT ); Tue, 12 Nov 2019 12:33:15 -0500 Received: from linux.microsoft.com ([13.77.154.182]:54742 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727409AbfKLRdO (ORCPT ); Tue, 12 Nov 2019 12:33:14 -0500 Received: from [10.137.112.111] (unknown [131.107.147.111]) by linux.microsoft.com (Postfix) with ESMTPSA id E33CE20B7192; Tue, 12 Nov 2019 09:33:13 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E33CE20B7192 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1573579994; bh=xx3ca2mXIh+U41lW7vrWoqUfcbvWxR0SGNsgcT5S7rQ=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=ihsqak0bLJndwzANhp76UsG97Hw8N5zkHSYUgQNSBqH5uaKe4zhsSGhcTI4aSzrfZ llZhqlHI/ZBf3975h27sna5oO6Quw6VZYGw7q3jlajWWtvl3dHgNCyTs5PDK34s0I9 F0cKkM52WI/odNdT07zuS7tw5BcpqtoMn3CTp5ZI= Subject: Re: [PATCH] ima: avoid appraise error for hash calc interrupt To: Mimi Zohar , Patrick Callaghan , linux-integrity@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Sascha Hauer References: <20191111192348.30535-1-patrickc@linux.ibm.com> <1573578841.17949.48.camel@linux.ibm.com> From: Lakshmi Ramasubramanian Message-ID: Date: Tue, 12 Nov 2019 09:33:34 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <1573578841.17949.48.camel@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/12/2019 9:14 AM, Mimi Zohar wrote: > On Mon, 2019-11-11 at 14:29 -0800, Lakshmi Ramasubramanian wrote: >> On 11/11/19 11:23 AM, Patrick Callaghan wrote: >> >>> - if (rbuf_len == 0) >>> + if (rbuf_len == 0) { /* unexpected EOF */ >>> + rc = -EINVAL; >>> break; >>> + } >>> offset += rbuf_len; >> >> Should there be an additional check to validate that (offset + rbuf_len) >> is less than i_size before calling cypto_shash_update (since rbuf_len is >> one of the parameters for this call)? > > The "while" statement enforces that. > > Mimi Yes - but that check happens after the call to crypto_shash_update(). Perhaps integrity_kernel_read() will never return (rbuf_len) that will => violate the check in the "while" statement. => number of bytes read that is greater than the memory allocated for rbuf even in error conditions. Just making sure. thanks, -lakshmi > >> >> if ((rbuf_len == 0) || (offset + rbuf_len >= i_size)) { >> rc = -EINVAL; >> break; >> } >> offset += rbuf_len; >> >>> rc = crypto_shash_update(shash, rbuf, rbuf_len);