Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp411473rwd; Tue, 16 May 2023 02:51:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Rms8RJ4o438upo+Y3qwCj0QvOUiQ5Kw1h86/GI6FG4EBYqf2T+dZw4PxPKWX1MNQzZGYy X-Received: by 2002:a17:903:120d:b0:1a5:2993:8aa6 with SMTP id l13-20020a170903120d00b001a529938aa6mr44051967plh.63.1684230700495; Tue, 16 May 2023 02:51:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684230700; cv=none; d=google.com; s=arc-20160816; b=W0oiDhnHAwXRkKiowlFKRMVvlBqA1c5Y843OnrlFGfvxa5oigOuM685dtlZS8Pxy9G oIykk/4ZkwcdZharFCmbyIMD1vA0Ksekp2sLG/uYj3SU0zug3jgvG7UGs2ocPBbQ9j6+ 2c9G+PUJEDz6cZb1Gd5IPgNW2ZOWxEBXnTwFplvmfsTFFGBpPWsvfuWcHyCVv5LI2Jmm sLVtp4d5to+h99rmKv3QGTJFvF73BvriDysjBb2EvKbAy04f6h+dpvLI9nLydDdKhdZ6 2cp7vA+mCS/zYKDUWjZzkJAFD5M6tRgi9SjaS8b9OWHtzs5WA8RwNTnwg6mO/OsVf+M1 EX8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=dD2skorvq6yEpOzG8Joum7LE739pEYqSIFwf93EYdOA=; b=o4z06KOTK7JQv3L6uROBLM7VpMsltwDZgIGMzfsQGc2FP4qIS59GPhdReu8SfL+Gb1 UWJIg+m0P8ZaIFNQPfAxPiVGkBu9pnEFm4gpUVIQZrknzb4Js4ZtSdF8tB+WixUEEzp7 URLMaMLl4kkRKPoOIIMKQsAZYiWoSEMAH4dAK3FoYnZyd9KmUIKLxGAIedctSDbw/fgs oXDR60VPud9Ap4bRiK9cQ/Ebg6+agZDzi/oiVX/SYUX0ZKlyJ6PwDAz1GnLOLhY3eA7w KIBaXVZWdPTmSoLiimGOlXS2xvN1VJOxw7WOb6ojo6c38YGQcSgsUlqbBU9LkkJ86Od8 NFlA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s14-20020a17090aad8e00b00252cf7d9c42si1454629pjq.50.2023.05.16.02.51.16; Tue, 16 May 2023 02:51:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231792AbjEPJeF convert rfc822-to-8bit (ORCPT + 99 others); Tue, 16 May 2023 05:34:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231283AbjEPJeF (ORCPT ); Tue, 16 May 2023 05:34:05 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9245F1AE for ; Tue, 16 May 2023 02:34:03 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-135-X5UBcpsYPH-IDE9hxwtcdQ-1; Tue, 16 May 2023 10:34:00 +0100 X-MC-Unique: X5UBcpsYPH-IDE9hxwtcdQ-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 16 May 2023 10:33:58 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Tue, 16 May 2023 10:33:58 +0100 From: David Laight To: 'Azeem Shaikh' , Chuck Lever , Jeff Layton CC: "linux-hardening@vger.kernel.org" , "linux-nfs@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH v3] NFSD: Remove open coding of string copy Thread-Topic: [PATCH v3] NFSD: Remove open coding of string copy Thread-Index: AQHZhtarLR7mMXSOG0mD9inDFwvZGq9cpMAQ Date: Tue, 16 May 2023 09:33:58 +0000 Message-ID: References: <20230515024044.2677124-1-azeemshaikh38@gmail.com> In-Reply-To: <20230515024044.2677124-1-azeemshaikh38@gmail.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,PDS_BAD_THREAD_QP_64, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Azeem Shaikh > Sent: 15 May 2023 03:41 > > Instead of open coding a __dynamic_array(), use the __string() and > __assign_str() helper macros that exist for this kind of use case. Is this actually a dynamic array, or just a char[8] ? On 64 bit copying a short fixed-length string is far better than any kind of dynamic sized allocation. David > > Part of an effort to remove deprecated strlcpy() [1] completely from the > kernel[2]. > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy > [2] https://github.com/KSPP/linux/issues/89 > > Fixes: 3c92fba557c6 ("NFSD: Enhance the nfsd_cb_setup tracepoint") > Signed-off-by: Azeem Shaikh > --- > fs/nfsd/trace.h | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h > index 4183819ea082..72a906a053dc 100644 > --- a/fs/nfsd/trace.h > +++ b/fs/nfsd/trace.h > @@ -1365,19 +1365,19 @@ TRACE_EVENT(nfsd_cb_setup, > __field(u32, cl_id) > __field(unsigned long, authflavor) > __sockaddr(addr, clp->cl_cb_conn.cb_addrlen) > - __array(unsigned char, netid, 8) > + __string(netid, netid) > ), > TP_fast_assign( > __entry->cl_boot = clp->cl_clientid.cl_boot; > __entry->cl_id = clp->cl_clientid.cl_id; > - strlcpy(__entry->netid, netid, sizeof(__entry->netid)); > + __assign_str(netid, netid); > __entry->authflavor = authflavor; > __assign_sockaddr(addr, &clp->cl_cb_conn.cb_addr, > clp->cl_cb_conn.cb_addrlen) > ), > TP_printk("addr=%pISpc client %08x:%08x proto=%s flavor=%s", > __get_sockaddr(addr), __entry->cl_boot, __entry->cl_id, > - __entry->netid, show_nfsd_authflavor(__entry->authflavor)) > + __get_str(netid), show_nfsd_authflavor(__entry->authflavor)) > ); > > TRACE_EVENT(nfsd_cb_setup_err, > -- > 2.40.1.606.ga4b1b128d6-goog > - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)