Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp2001096lqe; Tue, 9 Apr 2024 07:04:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUcXjHLrI4w+Lj4aeoQNQSI+ukhmD1cko7SIFTvJ9evfSU5/RerWd9AZgUlFvE8DFiMZniZq5NkOXTp3JOSi5YBbr13us2ZlA9F+1ovfw== X-Google-Smtp-Source: AGHT+IGYHJS+MtI6HpGXV/3nJactGuq8C3Dpe95i1eBuTD6tKU/s/dVtZiqVtWxd4mmu2xgh5pXh X-Received: by 2002:a50:a451:0:b0:56d:fdb3:bcc0 with SMTP id v17-20020a50a451000000b0056dfdb3bcc0mr11191806edb.11.1712671461881; Tue, 09 Apr 2024 07:04:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712671461; cv=pass; d=google.com; s=arc-20160816; b=WDQDPPcqw0m2OMmRDkIvBNZzGYjLnkFpwHigGJCUvgcjD6rsDwJUMcFIa7VwmK/tJ0 4KYvIbI3LKOda5TmgqcmHMReMiYCGtTVJks15/HqQWQnAX5VpZAI0O5QHJltB0kCV1I4 rUSXr+6uESF467UuqRJyce5I4Amr8s3yYfFjsjNCm+HiB79YjfM78PzNCQ+wlz9ToCPB Zdzh+Y81jnhTWFjq8lS57up3BKwUCiRF6DcCWlmPwXIeUxEMhBh5A9vnJ3hImW8gNQQR iRGL3D/L4WZtpuzLFP8YQ1iCJiR+emH6KixZAt48IjChZGP6YE0kgLKGfXYD9/M53Svu ZBHw== 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=+c5210IpZH8fBO4nm+TwWSxP/ttebKKGwb5/KKGmKQg=; fh=VehPt3IvrE8vXpZWN3ctklQQrgU7z6S4VQ7yLo5FDXM=; b=oKgG6UMS5MGY84I3tRPPTil3CBNBwydUxbNdYh3SydSeV9RP9+2+gfFamkk4w8rnE7 Tn4btCRMCEwDb73cdnfXh2h4UmJf13whyzUNEE1m8ghDUs3DzC7RgwBmZd+XoAN04xmh 0zQNTaQ7SZmCORQvHy+o+crtR6ChPasFheHckoEzMNVURgWNrYNKW1TC6BNTYgioMmeJ a7tKfxSxK/Q5Y/iD/7ZfIno+x2spVhPZEs/PTaRPffxyxvbJ8A7wbeGYlUWUYtWfdr98 20eoOe8Go+VWZdRyCGbVM63nKDjuxpDt3KFZ24ftxH4Fev9iiyxDdg9swbLBidDK81Ee KcxA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kROJxz2H; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-137050-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137050-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 e8-20020a056402190800b0056e71cf8b1bsi848455edz.557.2024.04.09.07.04.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 07:04:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137050-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=kROJxz2H; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-137050-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137050-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 152641F2407C for ; Tue, 9 Apr 2024 14:03:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B06D13328B; Tue, 9 Apr 2024 14:01:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kROJxz2H" 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 8E6551311B9; Tue, 9 Apr 2024 14:01:28 +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=1712671288; cv=none; b=pvQFcG8Bf6egaWtiHSbYfIaOtEiE74K54QyPfN+SY1ToQ3ZY0aKLnOFBrJfiXdMJBauFjO0xQSxjOSGFp/Q+vcWAZou9rdppscriwelBFT8IweUJ8Nth8ykaL6h4eTFAptAtQVntsrsXFuax6zFt7l1vtqxSfq96hnulINbyo78= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712671288; c=relaxed/simple; bh=pzK3De1dss+tVtAMUbtIdEjmw37wYh3hyKahO2Wukx4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=K8Ya5jHkE2TEDUcs4dF2eOgVrp1d/e+4IQxQaeT234MgMEJU+6zRGRH8bXKQhoB/v+hs4WYA5GmyDIntR75lF4gZMBa80bl6QyqSe//YxXWIAHQuk2HKTXICcoibRpu4Ce7ty81o19THA+oSZmp1oKF65GSKaDAdUX78gdc+8mY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kROJxz2H; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7EB6C433C7; Tue, 9 Apr 2024 14:01:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712671288; bh=pzK3De1dss+tVtAMUbtIdEjmw37wYh3hyKahO2Wukx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kROJxz2HYgYmtGzuLOF1DPUe3tsYi9DEJ86893KsN4RG8ZJ2ez8cLLlpXAt1q+/Kl qsw9cy559op7Gxv7hDeh2gK/p4ba26iuHzPTC7VRjy8fdJqsEeWuiV5tQ46ZllP7S9 ZbUqQqTcngs3Ytvsbwu6cLLEvXW7Nxt/JPx3GQl+ZFB1AvwyGc2YMLAo/hvg8tvBen 9+cEIqTiHYc4GkmUn3bcMfpPwm+rwip2PT02QzrvVG9nPIOB5mO9PSmbiNRWl9VXLs FleNYGV2Q6GW30vC1shIToVxt1l6zXaHmiQ47V5iFp8JJYeekoGWzq1qZ5bqNjGgJK yhlh3nw+JpfcQ== From: Arnd Bergmann To: linux-kbuild@vger.kernel.org Cc: Arnd Bergmann , "Richard Russon" , Jens Axboe , Robert Moore , "Rafael J. Wysocki" , Len Brown , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Andrew Morton , Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Lin Ming , Alexey Starikovskiy , linux-ntfs-dev@lists.sourceforge.net, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev, linux-trace-kernel@vger.kernel.org Subject: [PATCH 4/5] [v2] blktrace: convert strncpy() to strscpy_pad() Date: Tue, 9 Apr 2024 16:00:57 +0200 Message-Id: <20240409140059.3806717-5-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240409140059.3806717-1-arnd@kernel.org> References: <20240409140059.3806717-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 --- v2: actually use padding version of strscpy. --- 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..8fd292d34d89 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_pad(buts->name, name, BLKTRACE_BDEV_SIZE); /* * some device names have larger paths - convert the slashes -- 2.39.2