Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1637747rdb; Sun, 19 Nov 2023 04:39:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFt82wTEBo0o5uD9huI67bL8NVfrNHFGYGwkW1IE6WO7SxydeJWIsxp3/BEgIpFaMzylpUM X-Received: by 2002:a05:6a00:1402:b0:6c9:79e1:63a4 with SMTP id l2-20020a056a00140200b006c979e163a4mr3537197pfu.34.1700397566582; Sun, 19 Nov 2023 04:39:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700397566; cv=none; d=google.com; s=arc-20160816; b=KAaKqIEzeazgOKBp63GggdB+EfHwSmKRMvj2PM/vvY7gA4abhCd/adp8sJRP1GvTDv ZM8fHRuzVqO0JWKzZ1aWckZ4cGeZN8KqFn/EN1GPc5crd284fy9rlRESPj696gRht1hq QjRAqoKMWHsKwRqCtptnM8lMEEBp/YZt4cwZg5al+8ViNlyyJGUALksUsbandiE4UAo3 h5AultAkPP/ck82J2OcZ83nDyfZfdhoeAiXYSKvUVsXCr7dGZIqqlZrwsP0UDB3lLA8j 5zzoZzemljqvlEdnzo4/myQdtDVGJD0OI3tIwhRxFsgpG5uRMtC6EQw7lFGkfecj+g3V aepg== 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=yOrnK/542Zoh3v/mcdS03rZ1TLbYIVoIRt2JO2cQx5s=; fh=4ZvT1p4slc3rLySzJiyWEWIqJzgy7CN+HWFKI/ZYV1I=; b=mOI8rsOOO4WX9Fgq3T3RiaTj8Un07WbXkXhQKYNUYW1aR05dawXWSSy8sexjKMot+R mcEcexTVozTbe/jzD60IthRUYBKBbcVwijo5H/TuCrg/5anMZ0NWQF7bZQjHL8vLHs3J f6+C1y9QdkFD3KGQ0H1epHQtZqEnxg78b5HPoNYU+gztw5ztxfIjscuPrgKdLSjFrY8C JPv1C41QchhSKxyY6Ox34HUP+nJXMCoOXD2XrPX5ZOyzjo4bwu8ivVbjY2ZMmY8OEKLO aWIWzATkWdTx9vc5Z/7MToCEVJv18zLCNNvtZEeNyMiYiNXm+RdAtRteFm05YZ0UoWuo TeSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=adUOiy62; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id n15-20020a63e04f000000b005b8555564e2si6099389pgj.565.2023.11.19.04.39.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 04:39:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=adUOiy62; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id D01E9805B2C2; Sun, 19 Nov 2023 04:39:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230389AbjKSMjN (ORCPT + 99 others); Sun, 19 Nov 2023 07:39:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjKSMjM (ORCPT ); Sun, 19 Nov 2023 07:39:12 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0249C12D; Sun, 19 Nov 2023 04:39:06 -0800 (PST) Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AJAFYSJ027516; Sun, 19 Nov 2023 12:39:05 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=yOrnK/542Zoh3v/mcdS03rZ1TLbYIVoIRt2JO2cQx5s=; b=adUOiy626HavItD8J1a2aZZyWPKwNOv63ngUtRyDJTGHs9N4++11Iq0tKW6Z8DvBvQlg eM3hrucvled1CXAeXFm+pb0ec+IbkCBnNiWCFWRbI6TeMrMg7TapOTr9TWySDL6WfP4x U5ZRnhJ3TFFRwJbWz+5++nopKRA7KIR5UBrdxzyMEJGwOCvo0F2e8ueaU3E0t50f/T/r nyoapazQyV96+qbWuffjL6ozB+zUs2QA8DaBqf6HNJV9LAaRjUZSWrK8KD09lqkY/Fbd AqyB64HL1nL3fiKMfjVdd3VxJT8PKfpKj3J32NGKAKwuWpc2KJCF8Oikdfq8OWHqbUv3 wQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uf7kh0dyd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 19 Nov 2023 12:39:05 +0000 Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AJCU5gS010116; Sun, 19 Nov 2023 12:39:05 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uf7kh0dx7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 19 Nov 2023 12:39:04 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AJBJMEn007569; Sun, 19 Nov 2023 12:39:03 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ufaa1jacq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 19 Nov 2023 12:39:03 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AJCd0s514222034 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 19 Nov 2023 12:39:00 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AAB3520043; Sun, 19 Nov 2023 12:39:00 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9A53620040; Sun, 19 Nov 2023 12:38:59 +0000 (GMT) Received: from li-008a6a4c-3549-11b2-a85c-c5cc2836eea2.ibm.com (unknown [9.171.64.81]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTPS; Sun, 19 Nov 2023 12:38:59 +0000 (GMT) Date: Sun, 19 Nov 2023 13:38:57 +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: X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: wNX5z6b6QR__cf8Wx-hUwx8zwubhvZl8 X-Proofpoint-GUID: 4jKpwIDzsMaxjwokS--qpWdF1dfYPime 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-19_11,2023-11-17_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 adultscore=0 mlxscore=0 priorityscore=1501 clxscore=1015 bulkscore=0 impostorscore=0 mlxlogscore=684 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311190095 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Sun, 19 Nov 2023 04:39:23 -0800 (PST) On Fri, Nov 17, 2023 at 07:19:48PM +0100, Alexander Gordeev wrote: > > @@ -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? Please, ignore this (stupid Friday evening) quesiton. Although the use of sizeof() is right thing, FC_SYMBOLIC_NAME_SIZE is so ubiquotous in this source that it probably makes sense to address in a separate cleanup. @Steffen, @Benjamin, could you please comment in this and below? > > + /* > > + * 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; Not sure if this check is really needed. It could have been done for strlcpy() also, but as you say - should not ever happen. > > rspn_req->rspn.fr_name_len = len; > > > > sg_init_one(&fc_req->sg_req, rspn_req, sizeof(*rspn_req)); Thanks!