From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752203AbcAFEPA (ORCPT ); Tue, 5 Jan 2016 23:15:00 -0500 Received: from mail-yk0-f175.google.com ([209.85.160.175]:36638 "EHLO mail-yk0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751969AbcAFEO5 (ORCPT ); Tue, 5 Jan 2016 23:14:57 -0500 From: Insu Yun To: brking@us.ibm.com, JBottomley@odin.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: taesoo@gatech.edu, yeongjin.jang@gatech.edu, insu@gatech.edu, changwoo@gatech.edu, Insu Yun Subject: [PATCH] ipr: fix out-of-bounds null overwrite Date: Tue, 5 Jan 2016 23:14:58 -0500 Message-Id: <1452053698-75781-1-git-send-email-wuninsu@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return value of snprintf is not bound by size value, 2nd argument. (https://www.kernel.org/doc/htmldocs/kernel-api/API-snprintf.html). Return value is number of printed chars, can be larger than 2nd argument. Therefore, it can write null byte out of bounds ofbuffer. Since snprintf puts null, it does not need to put additional null byte. Signed-off-by: Insu Yun --- drivers/scsi/ipr.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 536cd5a..b7c3b1a 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -4009,7 +4009,6 @@ static ssize_t ipr_store_update_fw(struct device *dev, return -EACCES; len = snprintf(fname, 99, "%s", buf); - fname[len-1] = '\0'; if (request_firmware(&fw_entry, fname, &ioa_cfg->pdev->dev)) { dev_err(&ioa_cfg->pdev->dev, "Firmware file %s not found\n", fname); -- 1.9.1