Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp376016rdb; Fri, 5 Jan 2024 12:57:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IEPkGImsbfxc2owb/fqmBxnF8iDV1wKJE1Yejfq1GCatmi3lms1Bv7KW+QO26VgU8jLE7ph X-Received: by 2002:a05:6a20:c527:b0:199:1a:dac8 with SMTP id gm39-20020a056a20c52700b00199001adac8mr2119568pzb.123.1704488245641; Fri, 05 Jan 2024 12:57:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704488245; cv=none; d=google.com; s=arc-20160816; b=FyVgSgD4+j9ODYfuwbFVDk/tRtnzUCEfIo7przPaPrdipAxMQK9lwzFdZPFuIMMDZD J6BxSapXb6FGDeVMQqYa90oK6PxKv6BlFAAZp3Lb2C+PBmfmEB4b/I+sdq6pR9SWUGJm b7dV/4DnzsP5whezNL0NQQEJOHicusrd3maenmNtqelzbfoaLjl28q51+zVg65KcaHgj cCkJD1/XtRwSqTIhYZOLMMgswVc0PqFwl3bl72HKwV7jnZmSOChxkEKDCzZv0mxrvkPI VVe6QuhcFqsvVGqR3e5ZE1hENxB9+c5/QxK9nO45B7v1nVwkoIjmz+keyUNjRBPjllUN M6hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=SkZKKOE9n47WldW6B5NecvYoxPfEPs2aOPOG71cpu7M=; fh=u/VSIIc5XXy/Qwikz/LsInh/tLTw9mmc+O9k6N49s8o=; b=lUE0W/6faxFF5hnAXpXWM5KTrMc4LRV4A11E2g7urt4pA779E9w++P53WOeKOfaXik 9QZUFr6lFoTzjx1ktlN9y6vs5Qs7SjClhU/kN0W9b3WhfmiigK8AWiZx4NWHQI2j4nkC 5JVz6lwt0DzfpqGH8SJMRAJglqxjbbcsI/nqsoGvU35MJMmi9dgKtYT3lBqpLOUNV2t+ G9mgO8i2jRbEWdeMtqCNhuviyyYxhD28OrIwMSkZ+3jMAMvqgLEyg4Ei5WK20IO1wcJ/ MheGCMNgl8j1VNtrEceSBMsABfAqUMNjEj6HAUVrtnd9mUg/oaD8EErxgcSCW9VfHJUo jqwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NLbb29Hh; spf=pass (google.com: domain of linux-kernel+bounces-18355-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18355-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d34-20020a631d62000000b005ce0205d0cfsi1845532pgm.306.2024.01.05.12.57.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 12:57:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18355-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NLbb29Hh; spf=pass (google.com: domain of linux-kernel+bounces-18355-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18355-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 503E9284FAE for ; Fri, 5 Jan 2024 20:57:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C02AD224F5; Fri, 5 Jan 2024 20:57:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NLbb29Hh" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFAA621A0D for ; Fri, 5 Jan 2024 20:57:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C30E8C433C7; Fri, 5 Jan 2024 20:57:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704488238; bh=gAD8bxOLE5Ams9cdsSGbh8+d7ypMq1jhYSonntHU1zY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NLbb29Hh0929kqeCl2us54wEX8aRCCWeYJqib0/xcASz3L+bpsRSinR8COEBw76gr PC76G6WeAGQFq9piiWdgkvZTmr6p6saVUSHOoxfyNfTZW6IqN/wvf2wscJKKJwIM/F BsdhUGRz0yIgEKMjEfQwJ683TZPDzGlnbRZrCYHxhQNu3gx5k1YYCPKmPiLZqaLLBC MsV7LJdibxxGn1gKJQFbJNN8LXk7/Cew/qVKq0H3lyAA4ghJII+qPigKEx8BDvfSpd cUKv354IHzPHkIc93FxMYMeZCW3mqYdyZZV1GaCduy1LYje7aLY5U5pMFkqT0f1rqe xqxtCiMMsKNdg== Date: Fri, 5 Jan 2024 13:57:15 -0700 From: Keith Busch To: Arnd Bergmann Cc: Arnd Bergmann , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner , Hannes Reinecke Subject: Re: [PATCH 1/2] nvmet: re-fix tracing strncpy() warning Message-ID: References: <20240103155702.4045835-1-arnd@kernel.org> <20508695-b9e6-4aaa-9c78-84891c1a8f9a@app.fastmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20508695-b9e6-4aaa-9c78-84891c1a8f9a@app.fastmail.com> On Fri, Jan 05, 2024 at 09:36:38PM +0100, Arnd Bergmann wrote: > On Fri, Jan 5, 2024, at 21:24, Keith Busch wrote: > > On Wed, Jan 03, 2024 at 04:56:55PM +0100, Arnd Bergmann wrote: > >> @@ -53,8 +53,7 @@ static inline void __assign_req_name(char *name, struct nvmet_req *req) > >> return; > >> } > >> > >> - strncpy(name, req->ns->device_path, > >> - min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path))); > >> + strscpy_pad(name, req->ns->device_path, DISK_NAME_LEN); > >> } > > > > I like this one, however Daniel has a different fix for this already > > staged in nvme-6.8: > > > > > > https://git.infradead.org/nvme.git/commitdiff/8f6c0eec5fad13785fd53a5b3b5f8b97b722a2a3 > > + snprintf(name, > + min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path) + 1), > + "%s", req->ns->device_path); > > Don't we still need the zero-padding here to avoid leaking > kernel data to userspace? I'm not sure. This potentially leaves trace buffer memory uninitialized after the string, but isn't the trace buffer user accessible when it was initially allocated? For correctness, though, yes, I think you're right so I may just back out this one and replace with yours since we haven't sent a recent 6.8 pull request yet.