Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp710023rdb; Fri, 17 Nov 2023 10:20:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJWOwaIS+aTSMVtBjXBDuL/IBD6gqpME9E4ThFoSWwmfRczZRvT/taQLofbooOUJVClLJe X-Received: by 2002:a17:902:7442:b0:1cc:e823:c8cc with SMTP id e2-20020a170902744200b001cce823c8ccmr374082plt.41.1700245242023; Fri, 17 Nov 2023 10:20:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700245242; cv=none; d=google.com; s=arc-20160816; b=ELXbnuePFKgopYg7N/jQxrxGlYZ92AsmTzYajq/DXzGrj3TmigbICpsEo31/ENek6X +HXT0NYDCi0TgVaoUPhiTTF3jbk4Fe6IcOgS6QgPd2J0ZeED/wRsy9z+RSkrpMq/mP4R 0Eh1PYvUGkoQmTqszD0xtvt5vlx/x7QFY+0F5wDRpgWHeJxjnE1L7nClGw+DdMeFcn32 DgtW6lznuXREMHGKiTKa4WDnlGTIxQnytZAf7ePeNY9961kZIsmKOYinSrRkh+hWrbX9 Q3ETTcpgx7aeoREZMpdfux6I34TmuqrvNMi91P2pV1E+o5/g3G7ESLt9LVG6MdPz1jRI uToQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1L8Q24kr/qoZtRFffr6tjC4KNExzi4YYSRiTIwu6veo=; fh=4ZvT1p4slc3rLySzJiyWEWIqJzgy7CN+HWFKI/ZYV1I=; b=VRPkagJCpTA2oM4rQOfYPJfvWh8Dky9xkEa0R/ojDjTTt9Sr8VDnw9DM1OyFzZRWRS mIWv1vmRFdAVcumhh4jDDN3fegYFTyXO3HaZmlGnD68Q72xQG2a+BNcVMVpSTa8x5JIN kw5LfOQ5xQwccwgLXp0R7HP4KZcbdVvTYw+M/sPu+xCQPiyhtvEuQIlfJld/fPi8H8NC VXnlBtqTwogACbTX/nJb4E52VCJlOnLcuyDNcAS2sawUV6Vt5kPq0t3/cuybFi5gdX3z Lj/FSBAl5E4Bo/3LPF7lYgUH0znsFyPSoTCWJUrNJtG9e1sFjJninGbcjeJWarAoHQyc olRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=kHmczCcS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id n10-20020a170902d2ca00b001c7249f5e40si1183807plc.469.2023.11.17.10.20.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 10:20:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=kHmczCcS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 73EA88317482; Fri, 17 Nov 2023 10:20:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231430AbjKQST6 (ORCPT + 99 others); Fri, 17 Nov 2023 13:19:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbjKQST5 (ORCPT ); Fri, 17 Nov 2023 13:19:57 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10155AA; Fri, 17 Nov 2023 10:19:54 -0800 (PST) Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AHIEwvQ011834; Fri, 17 Nov 2023 18:19:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=pp1; bh=1L8Q24kr/qoZtRFffr6tjC4KNExzi4YYSRiTIwu6veo=; b=kHmczCcSNffDIrXKSJdlsWgmXNJZaJkkhRlWbt30w8GtKWTwW7ESbR8hQtrnOQPCFRV3 UHe2nC5Hxyc53V3JnwqzZ9mnWk2cpQxeBSASyOm/fuR9h6gZDM0uDKpyOcFNjNE+dlco 74VT51OIy6ILJ/4AW6yO9n9aOH7/OkjU9h2cKT9vTUg41Y2gjxveXQ+4YK5iMS5f23qe 6tTXt7p+xr6cwCwopxhTNtAX1qmFBSM+mpE/q7zm3BBkx11AWQW5ZzySYzwzNGnV35ki WLe2Xn5jBxPqhs+Av+oar7UXLjfwThZVcBTpWIzayNQWIiaTeaCh6HrTDraQxMirVeKm sA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ued9ag415-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Nov 2023 18:19:52 +0000 Received: from m0353722.ppops.net (m0353722.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AHIEvnl011815; Fri, 17 Nov 2023 18:19:52 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ued9ag40w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Nov 2023 18:19:52 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AHG48vs014752; Fri, 17 Nov 2023 18:19:51 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3uap5kqf4m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Nov 2023 18:19:51 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AHIJmlx39191124 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Nov 2023 18:19:48 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 82AA020043; Fri, 17 Nov 2023 18:19:48 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 852FE20040; Fri, 17 Nov 2023 18:19:47 +0000 (GMT) Received: from li-008a6a4c-3549-11b2-a85c-c5cc2836eea2.ibm.com (unknown [9.171.53.3]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTPS; Fri, 17 Nov 2023 18:19:47 +0000 (GMT) Date: Fri, 17 Nov 2023 19:19:45 +0100 From: Alexander Gordeev To: Kees Cook Cc: Steffen Maier , Benjamin Block , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , Azeem Shaikh , linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] scsi: zfcp: Replace strlcpy() with strscpy() Message-ID: References: <20231116191435.work.581-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231116191435.work.581-kees@kernel.org> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: maESwB1EAdoeU8RWF2zU727eC3-w3W6G X-Proofpoint-ORIG-GUID: 1LYYqnlCuehy9DM5_O13BK4b2dszfG4z X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-17_17,2023-11-17_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxscore=0 malwarescore=0 adultscore=0 mlxlogscore=885 spamscore=0 clxscore=1011 suspectscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311170137 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 17 Nov 2023 10:20:07 -0800 (PST) On Thu, Nov 16, 2023 at 11:14:35AM -0800, Kees Cook wrote: Hi Kees, > diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c > index 4f0d0e55f0d4..1a29f10767fc 100644 > --- a/drivers/s390/scsi/zfcp_fc.c > +++ b/drivers/s390/scsi/zfcp_fc.c > @@ -900,8 +900,15 @@ static void zfcp_fc_rspn(struct zfcp_adapter *adapter, > zfcp_fc_ct_ns_init(&rspn_req->ct_hdr, FC_NS_RSPN_ID, > FC_SYMBOLIC_NAME_SIZE); > hton24(rspn_req->rspn.fr_fid.fp_fid, fc_host_port_id(shost)); > - len = strlcpy(rspn_req->rspn.fr_name, fc_host_symbolic_name(shost), > - FC_SYMBOLIC_NAME_SIZE); > + len = strscpy(rspn_req->name, fc_host_symbolic_name(shost), > + sizeof(rspn_req->name)); Could you please explain why do you copy to rspn_req->name instead of rspn_req->rspn.fr_name? > + /* > + * It should be impossible for this to truncate, as > + * sizeof(rspn_req->name) is equal to max size of > + * fc_host_symbolic_name(shost), but check anyway. > + */ > + if (len < 0) > + len = sizeof(rspn_req->name) - 1; > rspn_req->rspn.fr_name_len = len; > > sg_init_one(&fc_req->sg_req, rspn_req, sizeof(*rspn_req)); Thanks!