Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp139746rdb; Wed, 18 Oct 2023 22:47:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFxfEwEzgMVtShe1HIjgINhfhjogHErdATxfjxooitRFZ4eOx2A1llCSpvwNU6rky9DU5E X-Received: by 2002:a05:6a20:1448:b0:17a:e981:8078 with SMTP id a8-20020a056a20144800b0017ae9818078mr1240947pzi.8.1697694443607; Wed, 18 Oct 2023 22:47:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697694443; cv=none; d=google.com; s=arc-20160816; b=uTWW67mCPebEoGICuD8uNQX0um1uhmL6aEaeQYcNUBYLxIoaKaf0pSeGLq1MgTco7h Ct6K+Z/GIIDmv5ofUiubPv/AoK3lCKMTVYF9RSnsJ54jXrUyonMBKnO2qHCuoZg7OdQW 4+1YCIttjqiMnBg2hR7KKNs7MMap+cvxYFRMuUEOhrgJCi+fn6OYaDsI5jenKVvB03RR fg4mG24AZPVBmI0Mvq04Q2SDGlUIwYr5DjUf3fqZUhiWHR+g8vMc1oGl64C+HhN2d4dA DEkRqyVy0kk2l2qyzA8BVA/zagzMVgCj2EiODWE6D1LqWZLJB8ydrdGlQWZtUF7Yl3Qr UiyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=gz4WxdHg0yOA78LQ9E8qvB8+vJd/o8HVajBV1ttHgtE=; fh=2KwY/LaLV1V/mofixkWoahuHm7yQLIc32XrLc4LJZ2g=; b=TWSzWdIm7qLZlRuZWWkpBYybWHjN9vHAq2D05DKsV2TxWaS7w34/dHB3GzPzwiHmXc 7LX9B4ZU9+Bgi4TrMHaPN35sCmmfgRaOwZNFvkmrMfvSwgXR5fnFt2PGP6cogom5rIzE w9Lbrmnz9MWR4Hs4e9Y3DSSeRWItb34tPVwRNQVTVJqJaMqpbHPWna3NGjOeHBRF2+cN /95gyUTJqbvxd1HjWufF+g1cy1KVm1d3426XM324cDWexMQVmjIdWNh9f2FK+RXj6az8 L0RNuwr3Z4ql4nXMz4xj/Xr25jrvGXCxGy28Lb75F1ufoE7EyVDjW+ZQVHnp05Q0KQJK WB0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id bv68-20020a632e47000000b00578c9144913si3581300pgb.364.2023.10.18.22.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 22:47:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E574F826E74D; Wed, 18 Oct 2023 22:47:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232814AbjJSFrL (ORCPT + 99 others); Thu, 19 Oct 2023 01:47:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232771AbjJSFq6 (ORCPT ); Thu, 19 Oct 2023 01:46:58 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26098D76; Wed, 18 Oct 2023 22:46:47 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id D960F67373; Thu, 19 Oct 2023 07:46:42 +0200 (CEST) Date: Thu, 19 Oct 2023 07:46:42 +0200 From: Christoph Hellwig To: Justin Stitt Cc: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, ksummit@lists.linux.dev Subject: the nul-terminated string helper desk chair rearrangement, was: Re: [PATCH] nvme-fabrics: replace deprecated strncpy with strscpy Message-ID: <20231019054642.GF14346@lst.de> References: <20231018-strncpy-drivers-nvme-host-fabrics-c-v1-1-b6677df40a35@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231018-strncpy-drivers-nvme-host-fabrics-c-v1-1-b6677df40a35@google.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 fry.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 (fry.vger.email [0.0.0.0]); Wed, 18 Oct 2023 22:47:21 -0700 (PDT) On Wed, Oct 18, 2023 at 10:48:49PM +0000, 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. If we want that we need to stop pretendening direct manipulation of nul-terminate strings is a good idea. I suspect the churn of replacing one helper with another, maybe slightly better, one probably introduces more bugs than it fixes. If we want to attack the issue for real we need to use something better. lib/seq_buf.c is a good start for a lot of simple cases that just append to strings including creating complex ones. Kent had a bunch of good ideas on how to improve it, but couldn't be convinced to contribute to it instead of duplicating the functionality which is a bit sad, but I think we need to switch to something like seq_buf that actually has a counted string instead of all this messing around with the null-terminated strings.