Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp461653lqh; Thu, 28 Mar 2024 07:12:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWJc1+gc0HClbZKqVXPvcl1iOIW9RtMXKVGt18Fq2BWgRX3SgXJPZgyuCjJo4Jov7v4MEJTgeaBymYdT48aTElUFXx2IUyzpbTJG4LdIQ== X-Google-Smtp-Source: AGHT+IGwcTTxMgqV2TIIcgNlNJcbiaCi9S6qp1gyRL7uoy80tgrZDDnK22jiVJcw0aTllvSCiX49 X-Received: by 2002:a50:d5c8:0:b0:56b:a017:10e with SMTP id g8-20020a50d5c8000000b0056ba017010emr1980388edj.42.1711635135302; Thu, 28 Mar 2024 07:12:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711635135; cv=pass; d=google.com; s=arc-20160816; b=hBOeXrEZorCQ3dOHzuWs42/jZtx8TSE5qZaFDDLA72xQY0R5orTCI5tfqd1bfEM/LC gyzFKOK4fDbLoGH2uWoSMwDfblBFHo56EygzzUzAuVfPGPWbVwqipyeyIXhzeS4a/hFj M8hxIrUP6r1q/U8cBB81fhkzCjuVaOV30G4UMfgct/Ud+nM5XhNPzhjQEfjRbwRl/3yy Pi5EtqgWF/4IddqGV0NdBFbOS+gzTa5dE1wXBLSfsgl895Ut8HhjT6ttezAmG0KeV3Gj HV6KgSBMBk3pyRAQF/mjkcTosUCtpxJurcedBaxHo6ClTzGxbl/kfR/RIvhKtmoIbzBS oWHQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date; bh=vB5HaXxmgP3WKxj887AnLyAIqb+rho1LnXkqI1xaUZA=; fh=TrdWWhlStNXRpLtYGlfLuIzwdHtSDvNg8dtm8V8dSdE=; b=pk2xASucxKPU90iZndpnqCoOvUpINqg56L8ou8qf+hDXyqrh+Ug098i5V3gVAfGIgV hwp50UzGp6aM2jaSTML0bDLdf3Ji7cgi9IwWwJ1Yk6mtI6Fc3+Hqjt+3SfsSVdxWZaGS bII5KmzavzHji37sGY2ZLQyxJVsu/0VTfkmFFfqg95ZqN1mSN79I6FT5PsZWCzpXA5RK uuxb+Eas41LO1V57PD8Y3aJZ+LGqVSu6LFlyelovJRUDRKQxV9XRTuVAS2vgWq0gpsn0 WFhYLcIAnH1rCsIItgCXWjRkZFkX9AuwgLlv3pxaJNgrWXV9GDSu8u9Mff5mkpxMhL59 98eg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-123041-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123041-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id c30-20020a50f61e000000b0056c2e8ee2e5si829472edn.117.2024.03.28.07.12.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 07:12:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123041-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-123041-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123041-linux.lists.archive=gmail.com@vger.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0CE921F23A16 for ; Thu, 28 Mar 2024 14:12:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 875BC127B47; Thu, 28 Mar 2024 14:11:41 +0000 (UTC) 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 04C4E14294; Thu, 28 Mar 2024 14:11:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711635101; cv=none; b=h/CXaKqMiEIC4p8e9QFveFjFkh2DGQ3IW/59qxLRygnzTLCxtLsI2XdDcGhz1ra8Ei5YCU3yLyus0MEobecnVUxYeDwHmmtsMgfXEO27EUrDUP+laxoIgJBT9bsZM4tXJN14lbCS00DHTD4VfIhWt77LQfS8xpmTEQsqpedEIkE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711635101; c=relaxed/simple; bh=tQsOJkvXX4/JlxEm1if34+dTH/cbHDaopNV04LTB0NI=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GcWre7txweTUCRZYY6k1CpE66f9Cd/EWhUacVFhgi8jLNve3yl4zye0SPkfaN6Y85hmj9fzhn8BDVQY4j7/6U0gH/hDKgI17VzFQ4V4jpVLcUCAC7MSI5OjgJdLND8ImWhI6DHYEXAHgb5xtrGvY8rkZjLniEdebyMyukKzldLE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9488DC433F1; Thu, 28 Mar 2024 14:11:39 +0000 (UTC) Date: Thu, 28 Mar 2024 10:14:22 -0400 From: Steven Rostedt To: Arnd Bergmann Cc: linux-kernel@vger.kernel.org, Jens Axboe , Masami Hiramatsu , Arnd Bergmann , Mathieu Desnoyers , linux-block@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: Re: [PATCH 08/11] blktrace: convert strncpy() to strscpy_pad() Message-ID: <20240328101422.37e1c4f0@gandalf.local.home> In-Reply-To: <20240328140512.4148825-9-arnd@kernel.org> References: <20240328140512.4148825-1-arnd@kernel.org> <20240328140512.4148825-9-arnd@kernel.org> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Thu, 28 Mar 2024 15:04:52 +0100 Arnd Bergmann wrote: > From: Arnd Bergmann > > gcc-9 warns about a possibly non-terminated string copy: > > kernel/trace/blktrace.c: In function 'do_blk_trace_setup': > kernel/trace/blktrace.c:527:2: error: 'strncpy' specified bound 32 equals destination size [-Werror=stringop-truncation] > > Newer versions are fine here because they see the following explicit > nul-termination. Using strscpy_pad() avoids the warning and > simplifies the code a little. The padding helps give a clean > buffer to userspace. > > Signed-off-by: Arnd Bergmann > --- > kernel/trace/blktrace.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c > index d5d94510afd3..95a00160d465 100644 > --- a/kernel/trace/blktrace.c > +++ b/kernel/trace/blktrace.c > @@ -524,8 +524,7 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, > if (!buts->buf_size || !buts->buf_nr) > return -EINVAL; > > - strncpy(buts->name, name, BLKTRACE_BDEV_SIZE); > - buts->name[BLKTRACE_BDEV_SIZE - 1] = '\0'; > + strscpy(buts->name, name, BLKTRACE_BDEV_SIZE); The commit message says "Using strscpy_pad()" but it doesn't do so in the patch. Rule 12 of debugging: "When the comment and the code do not match, they are probably both wrong" -- Steve > > /* > * some device names have larger paths - convert the slashes