Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1979974imm; Thu, 24 May 2018 03:59:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpWRYo3TZm4nqzJcwvA31PE3b90QpdvzYwp8rvIjholKGiuvcdCk9zaFLznBjV4cXtQGA8r X-Received: by 2002:a17:902:7c03:: with SMTP id x3-v6mr6650265pll.237.1527159549803; Thu, 24 May 2018 03:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527159549; cv=none; d=google.com; s=arc-20160816; b=t0tmgLDJ9XjHOfrVmdF00OV6DN5pXwKKG13hcrBW04G2RviftLBPbi0z5Zteci+n+r RAUIv+jBv3JZ/acflPTD3LTnQuc43KVJKtI+7P9kNCTuPeHrWyhYmroti6V7toTAEFnK xWd7XmQFcQDpZvZcCqMjK2pHMSrR4MseAeeur2cTTf7N0zzM+w0gpnKFnSq3Gt0GCk6o jQVhQqcr9hS+ZvJjmu/KwPYk6R1Dy6XpCgcT6WAkAqFNvAOSJPp2obpcBGUBqqii4gRo RULASc3D9AOXg8pP2HfMHwgww2vSsn4y3Vxmfnh9NKWfv1ilBXPueWFyNOhJrFcQ9We0 C7Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=J+KvaMfLGOndurC+NYzXDw0zTxD6+8WZ0u0Gp9CfSOo=; b=h/eupeA0Sh2f6sbQ+PoFzws9Nwr2mWtBXyKHb4MP4sjg2XW/5mXrA2FF8caTD8a34X JKoDcXf53hhyO508Bp/s7bSRVGVsK60EEtks1gK0Fe/8OA5us+ohS9ooiEQgTVdbSl2Q NIk5oAQZ/M3+t2IhNb/B92MgiFQqNoWE3cJRXaPIiwXwjvxL3z52qp+lLuVh7RiZdcPi lLCDfjyBbrxCr3NTnOVL+w3IX/pE1439MCPFyrjIlLGDiy0DgzPbr5UtUtOT8onHlDYJ BfMc9TvNZDvfmRSemfvZdCVpwdrZ8eCizKp4O9YmrR0N41IHQZvyMy/Gf5KLHFkFumaX RY5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XrSjE3Io; 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 r7-v6si21376426ple.585.2018.05.24.03.58.55; Thu, 24 May 2018 03:59:09 -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=XrSjE3Io; 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 S1032628AbeEXK6F (ORCPT + 99 others); Thu, 24 May 2018 06:58:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:36052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030236AbeEXJ4F (ORCPT ); Thu, 24 May 2018 05:56:05 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 C427C20893; Thu, 24 May 2018 09:56:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155765; bh=0tCB8K6POzQgxBrJ2WvKs6p7k0YMowRmB9BB1vhJX9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XrSjE3IoJzVy1WBGCv7LeIvo0O+qDB9WHAVdcLcMzqVXm9PSE93sY2YWowMZLZSuz feOWAaCV3uM1qUGaAp0ldOODxDKBkJ5zHpUVSfokq+HTfOqQ5GteQpHvyjWKVE+rkC ehZ1WmCBKt0mcTHw0EX+NY9SDKBa1fts9jSHPI80= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrew Vasquez , Nilesh Javali , Bart Van Assche , Chris Leech , Lee Duncan , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.14 107/165] scsi: qedi: Fix truncation of CHAP name and secret Date: Thu, 24 May 2018 11:38:33 +0200 Message-Id: <20180524093626.345592797@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093621.979359379@linuxfoundation.org> References: <20180524093621.979359379@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andrew Vasquez [ Upstream commit 1683ce57f568c7c92d53e9234624a53554a29cd5 ] The data in NVRAM is not guaranteed to be NUL terminated. Since snprintf expects byte-stream to accommodate null byte, the CHAP secret is truncated. Use sprintf instead of snprintf to fix the truncation of CHAP name and secret. Signed-off-by: Andrew Vasquez Signed-off-by: Nilesh Javali Reviewed-by: Bart Van Assche Acked-by: Chris Leech Acked-by: Lee Duncan Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/qedi/qedi_main.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c @@ -1840,8 +1840,8 @@ static ssize_t qedi_show_boot_ini_info(v switch (type) { case ISCSI_BOOT_INI_INITIATOR_NAME: - rc = snprintf(str, NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, "%s\n", - initiator->initiator_name.byte); + rc = sprintf(str, "%.*s\n", NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, + initiator->initiator_name.byte); break; default: rc = 0; @@ -1908,8 +1908,8 @@ qedi_show_boot_tgt_info(struct qedi_ctx switch (type) { case ISCSI_BOOT_TGT_NAME: - rc = snprintf(str, NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, "%s\n", - block->target[idx].target_name.byte); + rc = sprintf(str, "%.*s\n", NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, + block->target[idx].target_name.byte); break; case ISCSI_BOOT_TGT_IP_ADDR: if (ipv6_en) @@ -1930,20 +1930,20 @@ qedi_show_boot_tgt_info(struct qedi_ctx block->target[idx].lun.value[0]); break; case ISCSI_BOOT_TGT_CHAP_NAME: - rc = snprintf(str, NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, "%s\n", - chap_name); + rc = sprintf(str, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, + chap_name); break; case ISCSI_BOOT_TGT_CHAP_SECRET: - rc = snprintf(str, NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN, "%s\n", - chap_secret); + rc = sprintf(str, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, + chap_secret); break; case ISCSI_BOOT_TGT_REV_CHAP_NAME: - rc = snprintf(str, NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, "%s\n", - mchap_name); + rc = sprintf(str, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, + mchap_name); break; case ISCSI_BOOT_TGT_REV_CHAP_SECRET: - rc = snprintf(str, NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN, "%s\n", - mchap_secret); + rc = sprintf(str, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, + mchap_secret); break; case ISCSI_BOOT_TGT_FLAGS: rc = snprintf(str, 3, "%hhd\n", SYSFS_FLAG_FW_SEL_BOOT);