From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8324EB64DC for ; Tue, 18 Jul 2023 19:31:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229810AbjGRTbR (ORCPT ); Tue, 18 Jul 2023 15:31:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229997AbjGRTbO (ORCPT ); Tue, 18 Jul 2023 15:31:14 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ED76198D; Tue, 18 Jul 2023 12:31:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=4lvrkWb6sfRiU5F2WxbxoLsvFXn2cJ/Sdsc7oIw9b8Y=; b=RxWb4ZqkCJJM4ETLid0VMKIMWf R8wRhiq0A658gKpuMIItkj4B0yqM6ftio+QEER5QhbdX4T4yEVvPTZfgakdg/4+x0nSkmdfr1FRbC ZENuNMykair96x6nZj53SgSp7oYcWGM5LODf9ZgAyXEDefwaH5Ao0Gp4r1nBQ8QqM8KM=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1qLqPY-001ePh-BG; Tue, 18 Jul 2023 21:31:04 +0200 Date: Tue, 18 Jul 2023 21:31:04 +0200 From: Andrew Lunn To: Jakub Kicinski Cc: Kees Cook , justinstitt@google.com, Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kees Cook , Nick Desaulniers Subject: Re: [PATCH] net: dsa: remove deprecated strncpy Message-ID: References: <20230718-net-dsa-strncpy-v1-1-e84664747713@google.com> <316E4325-6845-4EFC-AAF8-160622C42144@kernel.org> <20230718121116.72267fff@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230718121116.72267fff@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 18, 2023 at 12:11:16PM -0700, Jakub Kicinski wrote: > On Tue, 18 Jul 2023 11:05:23 -0700 Kees Cook wrote: > > Honestly I find the entire get_strings API to be very fragile given > > the lack of passing the length of the buffer, instead depending on > > the string set length lookups in each callback, but refactoring that > > looks like a ton of work for an uncertain benefit. > > We have been adding better APIs for long term, and a print helper short > term - ethtool_sprintf(). Should we use ethtool_sprintf() here? I was wondering about that as well. There is no variable expansion in most cases, so the vsnprintf() is a waste of time. Maybe we should actually add another helper: ethtool_name_cpy(u8 **data, unsigned int index, const char *name); Then over the next decade, slowly convert all drivers to it. And then eventually replace the u8 with a struct including the length. The netlink API is a bit better. It is one kAPI call which does everything, and it holds RTNL. So it is less likely the number of statistics will change between the calls into the driver. Andrew