Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp787492rdb; Thu, 19 Oct 2023 21:47:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF9rLsF7KiUkSIucvgnzwXkPWBvgOKlnAwMh/GWyll+WQR6IlC7iZHXcVK7INlFTZDoakVF X-Received: by 2002:a05:6a20:8421:b0:14c:910d:972d with SMTP id c33-20020a056a20842100b0014c910d972dmr1048068pzd.12.1697777265958; Thu, 19 Oct 2023 21:47:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697777265; cv=none; d=google.com; s=arc-20160816; b=qnw+GcvLiIrt7PG2YwXT19SvViNoaBRQTl+vTrw+sKPGr4uCb/Nc196x0Nch9US9vj wO0/4bNy9VKp4oXlIEv9qZZT9jVM/2YUp1m1iPn8IdQO1YFxK14x2viD+W+Te2Z4N7U+ Sg6kNICGAVEw/UttLcWAYNIEd8XwC8lsatf+vzVVid2yv8klSSgZFPE/gX3aSkf4/xU2 EfafCVVfDS/+8RgAXRGDRUdDadY/QO5husTI0NCuZ2vOQ8UcpAPZRBtHRVoQbBlnKxfr GxWPoFjibqNcnXGWw/TYBBZrA312EjdW0TVVqyRO5CbHL+HkDL8xCPY/v0GxNT+O+Vbd /Kwg== 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=nKur3i6JgyLSH1tfcJATwzEzft276RmoLHM/DIvByJ8=; fh=EfSMxHt5EA7zoTRA+lwqEmb0Vi5TW+g7iMSfDZ8B610=; b=pdDUCUjuH1lVV/lb6LOxfQA0tmVMRNXBMhk262w8zwYfStus/bFgFKzI57MK06BWjq 18kZbtQhGxyoypBefKw92rjXt49LIHkgxO9rv17m+lpWQq8O4xjNR4rc9TqFI/4vUrfI R1AWOSoIZURoxFwQ1Uzm+yA4eqiOKDrwPPAG3ubNIiXdjwynvUk7KcXoBy3CyrPG6ter 5CiQCZQbdKDZJuiFl482MbJBG+c0njdTTFLFh7YmFAVEZkXZ8lSlLvvmf466R9uoom24 dxPNxYsyrSvTgiFF7+S6Yt3Y74scwhZhDeUPPXrQaaorQ8oYLawZpR+eqhgqw2YWjK6J m/og== 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:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id e7-20020a170902b78700b001c9b129a658si938574pls.122.2023.10.19.21.47.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 21:47:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 1A2C081BBA0F; Thu, 19 Oct 2023 21:47:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232072AbjJTEqy (ORCPT + 99 others); Fri, 20 Oct 2023 00:46:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbjJTEqv (ORCPT ); Fri, 20 Oct 2023 00:46:51 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27758D45; Thu, 19 Oct 2023 21:46:50 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id 3DEE867373; Fri, 20 Oct 2023 06:46:46 +0200 (CEST) Date: Fri, 20 Oct 2023 06:46:45 +0200 From: Christoph Hellwig To: Kees Cook Cc: Christoph Hellwig , Justin Stitt , Keith Busch , Jens Axboe , Sagi Grimberg , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, ksummit@lists.linux.dev Subject: Re: the nul-terminated string helper desk chair rearrangement Message-ID: <20231020044645.GC11984@lst.de> References: <20231018-strncpy-drivers-nvme-host-fabrics-c-v1-1-b6677df40a35@google.com> <20231019054642.GF14346@lst.de> <202310182248.9E197FFD5@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202310182248.9E197FFD5@keescook> User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham 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-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 19 Oct 2023 21:47:12 -0700 (PDT) On Wed, Oct 18, 2023 at 11:01:54PM -0700, Kees Cook wrote: > Almost all of the remaining strncpy() usage is just string to string > copying, but the corner cases that are being spun out that aren't > strscpy() or strscpy_pad() are covered by strtomem(), kmemdup_nul(), > and memcpy(). Each of these are a clear improvement since they remove > the ambiguity of the intended behavior. Using seq_buf ends up being way > more overhead than is needed. I'm really not sure strscpy is much of an improvement. In this particular case in most other places we simply use a snprintf for nqns, which seems useful here to if we don't want the full buf. But switching to a completely undocumented helper like strscpy seems not useful at all.