From patchwork Thu Jun 3 10:14:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javed Hasan X-Patchwork-Id: 454472 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 BF78DC47082 for ; Thu, 3 Jun 2021 10:14:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A92DF613F0 for ; Thu, 3 Jun 2021 10:14:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229850AbhFCKQj (ORCPT ); Thu, 3 Jun 2021 06:16:39 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:16210 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229800AbhFCKQj (ORCPT ); Thu, 3 Jun 2021 06:16:39 -0400 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 153AArYM001204; Thu, 3 Jun 2021 03:14:54 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=PYVCIS/4HtuijguOaQzB/RF7yjuT3rFJkW7Fp9VoyCo=; b=LAY5Jz8KOjiW8iw0mb36zo8Fxowh7eLYMvRdwXFzgin8Br9A7uLJe8qzVFcEShSMaDto nDllag9visqXHSoepCRYzXk7zydK/slwKrJbDkkQXHSXy6/cVs0tbVHoneCDadX/J0Tt nPgBZpAVqmhRPnvhJexVhw5msX7aWuA8NzUf1unYO6tjV9CqinXPB4hO4atk8grvpAjg BSs5bUBfSOtKcOOtzQ9hs/GxNrwwvkgwWLSI4E/xiHm++TbcCgO7T05zLqx59I/SlW1i 9RtoPR29DmiOCibkrlCQZ7usLw/HErS5Z3z8Y63E1KKP+w1EecnGEqD7l6k+U94sEttW rQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com with ESMTP id 38xe7xu6jh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 03 Jun 2021 03:14:54 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 3 Jun 2021 03:14:53 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 3 Jun 2021 03:14:53 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id D7C5E3F7040; Thu, 3 Jun 2021 03:14:52 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id 153AEq0w007881; Thu, 3 Jun 2021 03:14:52 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 153AEqfv007880; Thu, 3 Jun 2021 03:14:52 -0700 From: Javed Hasan To: CC: , , , Subject: [PATCH V2 1/2] scsi: fc: Corrected RHBA attributes length Date: Thu, 3 Jun 2021 03:14:03 -0700 Message-ID: <20210603101404.7841-2-jhasan@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20210603101404.7841-1-jhasan@marvell.com> References: <20210603101404.7841-1-jhasan@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: T4pgjMrBe1ydB4yBrSAlkSfYh0MPk8_M X-Proofpoint-GUID: T4pgjMrBe1ydB4yBrSAlkSfYh0MPk8_M X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-06-03_06:2021-06-02,2021-06-03 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org -As per document of FC-GS-5, attribute lengths of node_name and manufacturer should in range of "4 to 64 Bytes" only. Fixes: e721eb0616f6 ("scsi: scsi_transport_fc: Match HBA Attribute Length with HBAAPI V2.0 definitions") Signed-off-by: Javed Hasan Reviewed-by: Himanshu Madhani CC: stable@vger.kernel.org --- Changes in v2: - Added stable@vger.kernel.org in cc --- include/scsi/fc/fc_ms.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/scsi/fc/fc_ms.h b/include/scsi/fc/fc_ms.h index 9e273fed0a85..800d53dc9470 100644 --- a/include/scsi/fc/fc_ms.h +++ b/include/scsi/fc/fc_ms.h @@ -63,8 +63,8 @@ enum fc_fdmi_hba_attr_type { * HBA Attribute Length */ #define FC_FDMI_HBA_ATTR_NODENAME_LEN 8 -#define FC_FDMI_HBA_ATTR_MANUFACTURER_LEN 80 -#define FC_FDMI_HBA_ATTR_SERIALNUMBER_LEN 80 +#define FC_FDMI_HBA_ATTR_MANUFACTURER_LEN 64 +#define FC_FDMI_HBA_ATTR_SERIALNUMBER_LEN 64 #define FC_FDMI_HBA_ATTR_MODEL_LEN 256 #define FC_FDMI_HBA_ATTR_MODELDESCR_LEN 256 #define FC_FDMI_HBA_ATTR_HARDWAREVERSION_LEN 256 From patchwork Thu Jun 3 10:14:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javed Hasan X-Patchwork-Id: 453743 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 7699EC47082 for ; Thu, 3 Jun 2021 10:15:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 598C461287 for ; Thu, 3 Jun 2021 10:15:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229902AbhFCKRF (ORCPT ); Thu, 3 Jun 2021 06:17:05 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:46472 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229665AbhFCKRE (ORCPT ); Thu, 3 Jun 2021 06:17:04 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 153AAftD011018; Thu, 3 Jun 2021 03:15:20 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=ddVl/R29tkM6ZNpj7fH9z0F9r1phP0HIjU6aSM3ozis=; b=adzKI0LsZBHTivRKl+TjkPW+2mBLi4XLbzTlntE9Dqgt458PmWTv6jTfLcuyZpZD20kK IjuLzFRBOxrVdjqpRlFRa+Cyiaoc2pgx0+IZd8ijXUPeXSmQUgcdA2DSx/Fs10128Zds dVR07R+LAL78YmrPtvf9RkSePfvR2QuJKAQaxviYTzDFaL3UEwHWpGLnVhCcixfpEoGW gelRCCoB57ejc2VtwSamoTeejvvXDWW9D25d3IRRyDwdNmedZbN0xomIGGRlnZg78kgM 5w62wyItb0SEYHxtHrYtSSPKN1rhMxo1GfgGpJMfT15mx6ZwuUNZ++xmAEE/HgtBZeCr WQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 38xhym26cj-11 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 03 Jun 2021 03:15:19 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 3 Jun 2021 03:15:17 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 3 Jun 2021 03:15:17 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id F2C383F7062; Thu, 3 Jun 2021 03:15:16 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id 153AFGWO007893; Thu, 3 Jun 2021 03:15:16 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 153AFGwY007884; Thu, 3 Jun 2021 03:15:16 -0700 From: Javed Hasan To: CC: , , , Subject: [PATCH V2 2/2] libfc: Corrected the condition check and invalid argument passed Date: Thu, 3 Jun 2021 03:14:04 -0700 Message-ID: <20210603101404.7841-3-jhasan@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20210603101404.7841-1-jhasan@marvell.com> References: <20210603101404.7841-1-jhasan@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: pKTO6-LT5VnuWaMsDEnVM4nO4MY9OicS X-Proofpoint-GUID: pKTO6-LT5VnuWaMsDEnVM4nO4MY9OicS X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-06-03_06:2021-06-02,2021-06-03 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org -In correct condition check was leading to data corruption and so the invalid argument. Fixes: 8fd9efca86d0 ("scsi: libfc: Work around -Warray-bounds warning") Signed-off-by: Javed Hasan Reviewed-by: Himanshu Madhani CC: stable@vger.kernel.org --- Changes in v2: - Added stable@vger.kernel.org in cc --- drivers/scsi/libfc/fc_encode.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/libfc/fc_encode.h b/drivers/scsi/libfc/fc_encode.h index 602c97a651bc..9ea4ceadb559 100644 --- a/drivers/scsi/libfc/fc_encode.h +++ b/drivers/scsi/libfc/fc_encode.h @@ -166,9 +166,11 @@ static inline int fc_ct_ns_fill(struct fc_lport *lport, static inline void fc_ct_ms_fill_attr(struct fc_fdmi_attr_entry *entry, const char *in, size_t len) { - int copied = strscpy(entry->value, in, len); - if (copied > 0) - memset(entry->value, copied, len - copied); + int copied; + + copied = strscpy((char *)&entry->value, in, len); + if (copied > 0 && (copied + 1) < len) + memset((entry->value + copied + 1), 0, len - copied - 1); } /**