From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935175AbcIUTK0 (ORCPT ); Wed, 21 Sep 2016 15:10:26 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51088 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751449AbcIUTKX (ORCPT ); Wed, 21 Sep 2016 15:10:23 -0400 Subject: Re: [PATCH] ima: fix off-by-one comparison on template name length From: Mimi Zohar To: Colin King Cc: James Morris , "Serge E . Hallyn" , linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Morton Date: Wed, 21 Sep 2016 15:10:11 -0400 In-Reply-To: <20160920172527.23849-1-colin.king@canonical.com> References: <20160920172527.23849-1-colin.king@canonical.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.11 (3.12.11-1.fc21) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16092119-0004-0000-0000-0000019D79F3 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16092119-0005-0000-0000-000008BC4ED0 Message-Id: <1474485011.14532.134.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-09-21_10:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609020000 definitions=main-1609210348 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Colin, On Tue, 2016-09-20 at 18:25 +0100, Colin King wrote: > From: Colin Ian King > > The comparison of dr_v1->template_name_len is off-by-one, so > currently if the length is MAX_TEMPLATE_NAME_LEN we end up > with an out-of-bounds write on template_name when the terminating > zero character is written. Fix the comparison. > > Signed-off-by: Colin Ian King Thank you for the bug report. The patch that introduces this bug is in the -mm tree. The next posting will include this bug fix. Thanks! Mimi > --- > security/integrity/ima/ima_template.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c > index 24775f3..004723c 100644 > --- a/security/integrity/ima/ima_template.c > +++ b/security/integrity/ima/ima_template.c > @@ -395,7 +395,7 @@ int ima_restore_measurement_list(loff_t size, void *buf) > hdr_v1->template_name_len = > le32_to_cpu(hdr_v1->template_name_len); > > - if ((hdr_v1->template_name_len > MAX_TEMPLATE_NAME_LEN) || > + if ((hdr_v1->template_name_len >= MAX_TEMPLATE_NAME_LEN) || > ((bufp + hdr_v1->template_name_len) > bufendp)) { > pr_err("attempting to restore a template name \ > that is too long\n");