Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp1185707rdb; Fri, 20 Oct 2023 10:41:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH279szspyJd7PXaTlMWGPF7Svz/3BmkfwVkmyPGg8pMH28FrokS2mALNhyJdn8cvXYgUs/ X-Received: by 2002:a17:903:41cc:b0:1c3:9928:7b28 with SMTP id u12-20020a17090341cc00b001c399287b28mr8258468ple.6.1697823704609; Fri, 20 Oct 2023 10:41:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697823704; cv=none; d=google.com; s=arc-20160816; b=GsDryrg8nXtpkFm6Fg5MCLjjSxf8ogYuu6wm0LfP5fCxrWVxT2LutzbFWatu98TskO oFsqPnK7cj/9zojsyh82qEMX0e4QrfDnhOw1Yz6JZSeD2MOfdTg4FHCGzgPLXV2WSRl9 olhcLvF1fCiVg7MF3x15G+2iVVZf9kYTbjdW80rwIMvkNsc64I4FxOegu32El0VMOXTs /BJ12EzHbLlQdRnZWlBIOiPzjsPuSpsn+Un6/azQPOEvqL5aO9l3hQjUcXVPWIQD3I4a APBjUlk1BocLz91no2vX8xwoBJJrhCEob5rRH1m5+RfV+hSoSv6hQen2oOuqd6uNDFaN R1PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=mF0w62trqYcHCfLDfzhxkaTZFMEm0P6zCkg1/3Jkv8s=; fh=vxK/RMz+ZwxBQf1SpfyIisoLlT3LIhXTB6YyDN4FFaM=; b=ak9EzeX1lEYWdSD8uOLBc8ge23dOm4lc5XSFvcpbmvhJ0ENWu2zLI7h+6qPimFrrCW /VW+nLSY/ZYAxvicrkrJ0+Krw2fbvtcwCfzeofwqba4+tW8CHuaEJqdP32QYqcxVTh5t id8kjIKuZYNqAr81laZevsjUP4gMPEoBOdTu1rLbLG96ZAeZbCOcaJsDizjp9ksoM0F0 GB7woo2yBeuG6kYcEekSqAx43Q7Mb4pPGNtnqwbJsPUDaprHiVc41w0Vr0pvULzP8jUw dKlVHUTx5mo/tcSN2feUiJiEnsoBPUMBmQIRbrNDafT3n+dugCf9gkuv0LXIk7ktdcB5 OUYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=U6HVdGER; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id bw22-20020a056a02049600b00577f7bc56absi2609932pgb.100.2023.10.20.10.41.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 10:41:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=U6HVdGER; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id D6D9480A3114; Fri, 20 Oct 2023 10:40:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377895AbjJTRke (ORCPT + 99 others); Fri, 20 Oct 2023 13:40:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377702AbjJTRkc (ORCPT ); Fri, 20 Oct 2023 13:40:32 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 361F1FA for ; Fri, 20 Oct 2023 10:40:27 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-507962561adso1518187e87.0 for ; Fri, 20 Oct 2023 10:40:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697823625; x=1698428425; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=mF0w62trqYcHCfLDfzhxkaTZFMEm0P6zCkg1/3Jkv8s=; b=U6HVdGERQBUwTjwgHPHRCTgtRZk6v0bM6gVi76tzanFxli2DE+r7O3vvMgSx7UO4N/ SNeJgQner9QeEZHZBIGseSlcf5r8bFdP+QHL1xhckgb+R0vVmdoJsuYokOvWl5eERsrL 0R/IXc+oXnA/XLtjPk5M3uo4xAn8wdBi+uZDpokfi4A4Tsw+QBDn5hU9L5zKsBrQL7Kt mztkXAZ4JaWSqwYbjG9B3NZZCwYA9rGJchDuf3/LUHyOzsiA+yXwahrb02LWxZyxrpr3 a64hkVDoFRugBqRvzdepROzc1LEs7jjvaLoF9UhhG1kgbZfSNKF/xz23qGnTre0V9DtK 0u4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697823625; x=1698428425; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mF0w62trqYcHCfLDfzhxkaTZFMEm0P6zCkg1/3Jkv8s=; b=PyiiZCqBMVndYhH/3xZS2RhX3Q3MdWMOFCzGs8UR3J/O3B99TzxESICDLJUajxkqFI 58ykfCDYdAbTYCCz2NqbEVAmdyNzPK6LVoD009f3cKO4hk65W6i2D52eTobcItgpnZey H8L5is0x4UeiUWoHTEKIDw19HooIygP9y18S5s0qea8Y1lWUeq4D0PxNIfU8PvuHVADI ioqEfwjLfjFgkgQh+rs4W3Z0q+t0cQul4QuaZ0tfg27Z6voE2UZCXAG2o4sSRZcrmK6D duORisxMwgKlWaxlObX3a7qUDNNMc5uT3ew0Oikj5umiKO5WXa3w+jvvQRFTXqgBSFUo +4Cw== X-Gm-Message-State: AOJu0YwX6/VptbPsR70xprU4Gn41l0FNSdOKpaH0VSjkcHk/70MvEIQq QWVOyaKmtwHuH2igaDTx6KXQV+0RRD4l9WanATFFZA== X-Received: by 2002:ac2:4573:0:b0:504:3807:22a4 with SMTP id k19-20020ac24573000000b00504380722a4mr1925746lfm.23.1697823625262; Fri, 20 Oct 2023 10:40:25 -0700 (PDT) MIME-Version: 1.0 References: <20231018-strncpy-drivers-nvme-host-fabrics-c-v1-1-b6677df40a35@google.com> <20231019054642.GF14346@lst.de> <202310182248.9E197FFD5@keescook> <20231020044645.GC11984@lst.de> In-Reply-To: <20231020044645.GC11984@lst.de> From: Justin Stitt Date: Fri, 20 Oct 2023 10:40:12 -0700 Message-ID: Subject: Re: the nul-terminated string helper desk chair rearrangement To: Christoph Hellwig Cc: Kees Cook , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 20 Oct 2023 10:40:49 -0700 (PDT) On Thu, Oct 19, 2023 at 9:46=E2=80=AFPM Christoph Hellwig wrot= e: > > 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 particula= r > 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. There's some docs at [1]. Perhaps there could be more? [1]: https://elixir.bootlin.com/linux/v6.6-rc6/source/include/linux/fortify= -string.h#L292