From patchwork Tue Apr 18 09:55:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maurizio Lombardi X-Patchwork-Id: 9685267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EFB79602C2 for ; Tue, 18 Apr 2017 09:55:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EEFE5283FB for ; Tue, 18 Apr 2017 09:55:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3483283FE; Tue, 18 Apr 2017 09:55:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 787CE283FB for ; Tue, 18 Apr 2017 09:55:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756160AbdDRJz4 (ORCPT ); Tue, 18 Apr 2017 05:55:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51126 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754768AbdDRJzz (ORCPT ); Tue, 18 Apr 2017 05:55:55 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CE5743B71E; Tue, 18 Apr 2017 09:55:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CE5743B71E Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mlombard@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CE5743B71E Received: from manaslu.redhat.com (unknown [10.33.36.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 950B771C20; Tue, 18 Apr 2017 09:55:52 +0000 (UTC) From: Maurizio Lombardi To: james.smart@broadcom.com Cc: dick.kennedy@broadcom.com, linux-scsi@vger.kernel.org, emilne@redhat.com, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com Subject: [PATCH] scsi: lpfc: fix potential buffer overflow. Date: Tue, 18 Apr 2017 11:55:51 +0200 Message-Id: <1492509351-25441-1-git-send-email-mlombard@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 18 Apr 2017 09:55:55 +0000 (UTC) Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes a potential buffer overflow in lpfc_nvme_info_show(). Signed-off-by: Maurizio Lombardi Reviewed-by: Ewan D. Milne Signed-off-by: James Smart --- drivers/scsi/lpfc/lpfc_attr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index 22819af..1ce252f 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c @@ -181,7 +181,7 @@ wwn_to_u64(vport->fc_nodename.u.wwn), phba->targetport->port_id); - len += snprintf(buf + len, PAGE_SIZE, + len += snprintf(buf + len, PAGE_SIZE - len, "\nNVME Target: Statistics\n"); tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private; len += snprintf(buf+len, PAGE_SIZE-len, @@ -326,7 +326,7 @@ } spin_unlock_irq(shost->host_lock); - len += snprintf(buf + len, PAGE_SIZE, "\nNVME Statistics\n"); + len += snprintf(buf + len, PAGE_SIZE - len, "\nNVME Statistics\n"); len += snprintf(buf+len, PAGE_SIZE-len, "LS: Xmt %016llx Cmpl %016llx\n", phba->fc4NvmeLsRequests,