Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp312845rdh; Thu, 26 Oct 2023 03:02:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFP1B+nZEgzVB82vK7/HqCRWTiC1NstOsKx++mnb9KeUy/cjb4uzvGsQtovmlkNH4C3vL8F X-Received: by 2002:a0d:e843:0:b0:5a7:dac8:440c with SMTP id r64-20020a0de843000000b005a7dac8440cmr18510407ywe.23.1698314558121; Thu, 26 Oct 2023 03:02:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698314558; cv=none; d=google.com; s=arc-20160816; b=qQHflwTMS1KUEfBW/tNvu7rG45Trj59ZxgEQpStNlux47fYVTitJGG6a8QSpKd5936 L0NrpYi9CDqrArBKLviMGLuciBgBeq10c0b8G9LAhN8YK0tFk3OKY9jCSHqImJW38Yrs vkPfdYogKbLIjXiHIm7JsNAqdZvBMPvXzqIA6jB3X6ytf5frvObkiXuiqZ6Sns9kvZm0 QOB4luue3ExwzhDzhqQZFnwdWbWHB+vocWdRPyjG/8AVLsyQ0KxsJ9Eo3OfLWmDxWOlX PTSRe9MZhQxpR3MQz/k1qAI8B9Vkiw6pE2WyHlidzFwHx2NTVsUHzlJcoED26dR6m9rO E5xg== 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=OYvhj3NsRwxf9LMmZ5qla14Lm3aJRVjqWShJ7+elEfI=; fh=EfSMxHt5EA7zoTRA+lwqEmb0Vi5TW+g7iMSfDZ8B610=; b=p1da21cmCVSVC4rnDw8UlrwLcmiXamSK+yCqunkzy1xMEzU9vxvgIokffp0I3/BZ9A hAH7EWs/O2IwbHSb7o6O7y9jeOzd0YMoXaJckhjzbA5oq8bq3JJBkmHPq17NjeA+urUY Qijuc+qmW5jtM5t+e4GiD0+5HKL/1oS3kATfiqLAfRw6QEEyyyJ16PNXQVPSX6zSFJyj IcKncfuUxemUAQpHTvFZ4hsLz/zp0+gocbJMylaV0rez4ZWqZvxcJpnJYYfUZ/w0iWxY XZdf28Yt+bW3rQ8LBwF1LBPR7M57SHQmzLGHRpIwLB76nJDVg3djKIuHz/rzt4ktRpg6 tSfw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id h74-20020a816c4d000000b005a7af20beb6si15608877ywc.417.2023.10.26.03.02.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 03:02:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 9EA3180D6E70; Thu, 26 Oct 2023 03:02:06 -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 S229821AbjJZKB6 (ORCPT + 99 others); Thu, 26 Oct 2023 06:01:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjJZKB5 (ORCPT ); Thu, 26 Oct 2023 06:01:57 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B6CC18F; Thu, 26 Oct 2023 03:01:54 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id 3711867373; Thu, 26 Oct 2023 12:01:49 +0200 (CEST) Date: Thu, 26 Oct 2023 12:01:48 +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: <20231026100148.GA26941@lst.de> References: <20231018-strncpy-drivers-nvme-host-fabrics-c-v1-1-b6677df40a35@google.com> <20231019054642.GF14346@lst.de> <202310182248.9E197FFD5@keescook> <20231020044645.GC11984@lst.de> <202310201127.DA7EDAFE4D@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202310201127.DA7EDAFE4D@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,URIBL_BLOCKED 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, 26 Oct 2023 03:02:06 -0700 (PDT) On Fri, Oct 20, 2023 at 11:30:49AM -0700, Kees Cook wrote: > I'm curious where you looked and didn't find documentation -- perhaps > there is an improvement to be made to aim one to where the existing > documentation lives? My order was the following: - look for kernel doc on the main function implementation in lib/string.c (as found by a grep for an EXPORT_SYMBOL for it) - after not finding it there, but seeing that it has an ifdef for an arch override, which turns out to be unused - then I grepped the Documentation/ directory for it, and while there are quite a few matches for strscpy, they are largely in examples, with the only text referring to strscpy being Documentation/process/deprecated.rst that tells you to use it instead of strcpy, but not how it actually works - after that I realized that some people put the kerneldoc on the declaration, so I looked at that in string.h, but couldn't find it. > > 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 > > Right, And it's even valid kern-doc, which gets rendered in the kernel > API docs, along with all the other string functions: > https://docs.kernel.org/core-api/kernel-api.html#c.strscpy Well, I never use the generated kerneldoc because it's much harder than just grepping the tree, but indeed it exists even if it's hidden in the most obsfucated way. But at least I know now!