Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp457688lqh; Thu, 28 Mar 2024 07:07:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXGrmj3vrGkQUT3tLw6MPW4F7zQABIAMWDWoMQFb2rBK9vebzBjXRlznGGda4mOZCb1a1HE909vb/I6aW5AlO2a1KxoQgfQR5mg0mZDMg== X-Google-Smtp-Source: AGHT+IGLpb5dTseFAyvAgL5EPinMhoCuCuWVNq805Fzea2w65HFc6TCboyUrjsgnatJx0e1bwNxJ X-Received: by 2002:a17:906:6885:b0:a49:9631:1df with SMTP id n5-20020a170906688500b00a49963101dfmr1933524ejr.77.1711634865787; Thu, 28 Mar 2024 07:07:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711634865; cv=pass; d=google.com; s=arc-20160816; b=JN9atQAZPODQmn+leB2Jd/ACwCP6apaJ6FCP0W43G9fAtM7IK0iO8wJz4spsfrYEn3 Rft7MBirEv1opSaZW4CykxbHSYWKNS47boLmpx5sgC9qp/RqMDzMB2jMChCWMh9qjYg3 OBJj67iXpl7GJJPCsCKK3RZZbZpOk5MVy6tcOgnXJKreHxJcajyAeMHgLarp0QTpLZ8z wSbTEoSD3d5JybZKilkhvWrSkNnwAB1tKDSsttP2AVIJjQ3gwy225J5LdxmYC0eHN45p rXxccenqvpWa45iMKbrNvEVOMvIdH7mdwGiThSaMI27x9vLoYCdY4aV8KxClGai1fu2f p7+A== 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 :date:subject:cc:to:from:dkim-signature; bh=JUQPC+Vzw4R4M+WzG0fc6hIcvkoeikg9LNuuLsFrOt4=; fh=QQdY3NyMQbtdIsgqbDP1535+etGGmCJ+j7yIytNk454=; b=oydEVCxZ9T7riOC24q9cvB/jhibYkkf/kZ87xUhpU+JvMznkHin7kFTHnB3jIddgxZ VRbIEH1Ki4Q1eHrx48gbKR+TZ3EsWmxFHEZ81gaH6zaB8aDtFH+oZP8bzNKzdVNQ9wAr xXdkmJ++ljFKr/GY2IbkLdyfWrRcY/ybtBgiClxweQUWtK7BErHZ1fkWz15rZtWIyeyN yVs47EuQnn71X9DNrlrjpr2mxYCNB1+myWqTFsJI7/40R7zN9haZMzVFw+Wi0IRE8jvf Q88sV4SVrpgaem+IMqBkemHs+28/JXSh9F2RBarPHJV+dzZiek1emQQODLAs5gkmb0gw gDBQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FYCMzsrE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-123023-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123023-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id s25-20020a170906355900b00a4e29b8892bsi199758eja.331.2024.03.28.07.07.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 07:07:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123023-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FYCMzsrE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-123023-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123023-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 256DF1F234DB for ; Thu, 28 Mar 2024 14:07:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C57712A14E; Thu, 28 Mar 2024 14:06:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FYCMzsrE" 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 30E34129E81; Thu, 28 Mar 2024 14:06:54 +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=1711634815; cv=none; b=n9uQjWh+xVopXwWZTLfgiKbBy2OgeDbbqkYLMHF4HWdKtpk5o9E6Mpua/mWZnFUkZ6Tlhp49PeAQCnJ9YdQRbbv8pVcaWk2S6RtmPZfoH8lv07TSZTrpjW3PHf7VWsvSKef7dNWltZ+pNmE29vDcqGwf/5hpnnshH5J0o7dD2p4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634815; c=relaxed/simple; bh=4Sl2+ylJNPrkTlbZJE1y57+3AaBXLpboKEKujg0bFD0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=R8WuLBFMcPJLl6cA4d4KEJJObFirVt7s+YkCpcagp+UqoIijukZQED0AOLENZMDjWjKRuePSNCS7LVR0cwrlBzxKR+RpkaryYcr3aIDsD5Q/3T00pPIgCOtJak4X+0PkpXvgFvyrffzzqPMjuaItXw//X7C7/SecbAPGggJlrzI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FYCMzsrE; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDC22C433C7; Thu, 28 Mar 2024 14:06:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711634814; bh=4Sl2+ylJNPrkTlbZJE1y57+3AaBXLpboKEKujg0bFD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FYCMzsrEVcyxP1XJhQaxTBt5DaBA2wyIYnrE2OsH3WaOj1FvDey9aFrzZt+gSz7k7 z0SUHERlLXNrgM/t0uMzYS8iMEXh9K3FJA+WUPlNG9AuANTMdfHy7G6ObmmlUaEncx g5bFeK3k200QYAg0ehIgZXN1WAcFtAhXEloKn6p8DPumCHxhJzLvdIeOx2pWWjgskr 84m6zeMItrJBAOtuwQRr01nSH6aH8kXra7LQKqhEw53WiqsGNKfIpqx8sQAYUlWPg7 hGDg++GOtZH7XAAAB08NWysoOetgdxL4fJcnq2yDXY6RGd2Pg0B9O+5Tk32VsvtUQD PD90IojI+UJ0Q== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Jens Axboe , Steven Rostedt , Masami Hiramatsu Cc: Arnd Bergmann , Mathieu Desnoyers , linux-block@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH 08/11] blktrace: convert strncpy() to strscpy_pad() Date: Thu, 28 Mar 2024 15:04:52 +0100 Message-Id: <20240328140512.4148825-9-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240328140512.4148825-1-arnd@kernel.org> References: <20240328140512.4148825-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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); /* * some device names have larger paths - convert the slashes -- 2.39.2