Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2383323rda; Wed, 25 Oct 2023 00:38:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGA6h2m6ZkbSgIl5+JsdtiSNFdgdBbYcarIfL3AxQH+BFL/HuVGjzWsDY6kHbZOgAzbAa34 X-Received: by 2002:a81:6984:0:b0:5ac:fe2d:5edf with SMTP id e126-20020a816984000000b005acfe2d5edfmr5476005ywc.44.1698219539570; Wed, 25 Oct 2023 00:38:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698219539; cv=none; d=google.com; s=arc-20160816; b=JRULg3syI+8UEi8jO2/ImpWOHVLi923/iMNCee//rM2aIOQZ1+7YhRt9BaUXbathi8 Qisu1hemOLDHmmmtJhiX3kIW5FqFy9eHeewq88Wox24Ws8lnqyn3ZPVMyt+JKq0MlaEm aVy+jTDpC/WK4FNLFH4MLpvyfpWIqGaeTdmqeEMRTV6KHCDJQjHiOlIcXTH0pggaC4+i 2tYCZcghkTOHGGS+gVgXwGJTk5lleQLZ07XX80JusQPG+FWS2Sk2SNvZ/WbUbYcJmBzx mV3hMRvQBxzYJwcNDaLeLtiOawzrB6UmFALNrO4Al64M29FFbW5Zanzz2W1qwFsAjcRT c5tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=zZQJyqYnoH2mzbn59fDX9/iMeNtBFAOOWV3pVH2j/QI=; fh=XiXPQKaYTQZ6rXR4WW348zWp0vskEqTYJXSbHBC09fo=; b=mNMQOGnEJdtos8BJ3XWtjlxdqS8u/5ZlbXeFjHB4bZCX1428bihtRvRvtanltFC5aC ZPV1VRmUztYeqfjQkDmP2QcAXwXgx7GzLVKHbye3zS27ojSJWpa1BDw9jSBvNaXpKC4N QLbP1PzSYcBGQAXfjjq/pB3cYANc/is9aO2Ougg3CijPc8ogoDN+THHvE2HIf40sWQFe 5CB10fcYIf2aZkptAG874WgJomwLjU4WqeGUlfhCnT6EbXcIrYDKMaFCB7UWctqumrBd 0zHv3hKHlm0DbDY2OBW3iJUkMsmApqW1YoMX5s4eAT+T5t56xLqIVu2Ai1eU2uX8m7lE T1Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=nvPQfugp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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. [23.128.96.33]) by mx.google.com with ESMTPS id r68-20020a818147000000b005927a8ccfe9si9868230ywf.283.2023.10.25.00.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 00:38:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=nvPQfugp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 9097E801C367; Wed, 25 Oct 2023 00:38:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234081AbjJYHio (ORCPT + 99 others); Wed, 25 Oct 2023 03:38:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234055AbjJYHhn (ORCPT ); Wed, 25 Oct 2023 03:37:43 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF07B1FCA; Wed, 25 Oct 2023 00:35:50 -0700 (PDT) Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39P5lajh002210; Wed, 25 Oct 2023 07:35:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pp1; bh=zZQJyqYnoH2mzbn59fDX9/iMeNtBFAOOWV3pVH2j/QI=; b=nvPQfugpHLczE4gwcBZCU+aIugpqorc4IuAPjtawzOgw1Ad+8Lq2y9zqptO0kb2SgBXr l5ypbZ28ewhyT56SjqRpVImCHFfQEUHXd6YjfwhSoiNRqFQVGgbrKtqN3oT30cR5qBxs llaQQX9EB3dgiUS/K6yszebzG3g7hoWMFUZSCEOj+pSOX5Rvv02OoH6NJahhRVKPDIS2 WNrFZr+73SlQKFDqfKMBGuFceqecBINvGUWczZEsUyAgqhQKDbDExwcVmxo24r7NrgHw 9ozAbQHVALkf3ubA1Ui4VxsEdztEtjTWittRibPChhvr4mR7XK4hHKE4S2gm5AZv9jJU UQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3txw662spq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Oct 2023 07:35:48 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 39P6eM0s004566; Wed, 25 Oct 2023 07:35:45 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3txw662sgx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Oct 2023 07:35:35 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 39P73fEg010290; Wed, 25 Oct 2023 07:32:51 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3tvsbyn7rj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Oct 2023 07:32:51 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 39P7WluP23003820 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Oct 2023 07:32:47 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C922A20043; Wed, 25 Oct 2023 07:32:47 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4955A20040; Wed, 25 Oct 2023 07:32:47 +0000 (GMT) Received: from [9.171.33.174] (unknown [9.171.33.174]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTPS; Wed, 25 Oct 2023 07:32:47 +0000 (GMT) Message-ID: Date: Wed, 25 Oct 2023 09:32:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH] s390/cio: replace deprecated strncpy with strscpy Content-Language: en-US To: Justin Stitt , Peter Oberparleiter , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org References: <20231023-strncpy-drivers-s390-cio-chsc-c-v1-1-8b76a7b83260@google.com> From: Vineeth Vijayan In-Reply-To: <20231023-strncpy-drivers-s390-cio-chsc-c-v1-1-8b76a7b83260@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: xinD0Af57LbnLx_POYEuKSJBZNjhrwwR X-Proofpoint-GUID: 4BzELyR0UkvbYAYckLgbrc3_9b-I-vLi Content-Transfer-Encoding: 7bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-25_01,2023-10-24_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 bulkscore=0 malwarescore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 impostorscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310170001 definitions=main-2310250064 X-Spam-Status: No, score=-4.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS 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]); Wed, 25 Oct 2023 00:38:56 -0700 (PDT) On 10/23/23 21:24, Justin Stitt wrote: > strncpy() is deprecated for use on NUL-terminated destination strings > [1] and as such we should prefer more robust and less ambiguous string > interfaces. > > We expect both `params` and `id` to be NUL-terminated based on their > usage with format strings: > > format_node_data(iuparams, iunodeid, &lir->incident_node); > format_node_data(auparams, aunodeid, &lir->attached_node); > > switch (lir->iq.class) { > case LIR_IQ_CLASS_DEGRADED: > pr_warn("Link degraded: RS=%02x RSID=%04x IC=%02x " > "IUPARAMS=%s IUNODEID=%s AUPARAMS=%s AUNODEID=%s\n", > sei_area->rs, sei_area->rsid, lir->ic, iuparams, > iunodeid, auparams, aunodeid); > > NUL-padding is not required as both `params` and `id` have been memset > to 0: > > memset(params, 0, PARAMS_LEN); > memset(id, 0, NODEID_LEN); > > Considering the above, a suitable replacement is `strscpy` [2] due to > the fact that it guarantees NUL-termination on the destination buffer > without unnecessarily NUL-padding. > > Note that there's no overread bugs in the current implementation as the > string literal "n/a" has a size much smaller than PARAMS_LEN or > NODEID_LEN. Nonetheless, let's favor strscpy(). > > Link:https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] > Link:https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2] > Link:https://github.com/KSPP/linux/issues/90 > Cc:linux-hardening@vger.kernel.org > Signed-off-by: Justin Stitt LGTM. Thank you. Reviewed-by: Vineeth Vijayan I can push this to s390-tree and Heiko/Vasily will upstream it. ---snip---