From patchwork Wed Feb 19 22:47:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thorsten Blum X-Patchwork-Id: 13983082 Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [95.215.58.186]) (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 C310B1C6FFC for ; Wed, 19 Feb 2025 22:48:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.186 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740005304; cv=none; b=d5OEZgaruG1WeV3C5tyBW50DaVnDC72q5KJAQCmIFR6Zpgf4kmKeyqrOd3jQP9hQshabHM6Q+i4GDIUWSDBbwlSmWPI8cEnXEbcPAGVC1lhkGt0TA1wLkf3+DPM0rduWOI7/qNA4TqG85deHm+WrOU2HLwe3AMc9jHBFPo/tAoY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740005304; c=relaxed/simple; bh=fCP3McsTMgJpNvyO66Y1RDO2PBxT8DfXrv1mDnhT144=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ae7GS53tWBVn8B7iitRItLZNMrD1qIEUdN2OXe45FUGyyjg526ExNAY6bRGQ1Y0oFJoqoj15yt0IjHvmyZVhSvDnRfPJIhD3wprj8H1xyq3l+kPnWjJ9LAMz58OekxvvhtT4SuhXs28aTMAe17cxakHkjuIIieFbfmyNF3yE2II= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=V4ghLR0m; arc=none smtp.client-ip=95.215.58.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="V4ghLR0m" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1740005290; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=FLdeIOJ0cVMGZIjfbYqeq+xUkR3G/JMvqLqXwcOF0l0=; b=V4ghLR0m45eDcc94yDrbhYON7qv99zvqE13vyqGrAiIomZ4mP3PlIEECjP1k4V7Kkt6YSR vppS57+aUj1hrXGxomSeMg7pT9LVl1UQ9/CNY3RHS/m3QHGwNZlEdcvegG4ty1hD3LZhPY bJnCb6ZGbv5BeNeLaofWA/L6uLVZrp8= From: Thorsten Blum To: Allison Henderson , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: Thorsten Blum , linux-hardening@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com, linux-kernel@vger.kernel.org Subject: [PATCH net-next] net/rds: Replace deprecated strncpy() with strscpy_pad() Date: Wed, 19 Feb 2025 23:47:31 +0100 Message-ID: <20250219224730.73093-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT strncpy() is deprecated for NUL-terminated destination buffers. Use strscpy_pad() instead and remove the manual NUL-termination. Compile-tested only. Link: https://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Thorsten Blum Reviewed-by: Kees Cook Reviewed-by: Allison Henderson Tested-by: Allison Henderson --- net/rds/stats.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/rds/stats.c b/net/rds/stats.c index 9e87da43c004..cb2e3d2cdf73 100644 --- a/net/rds/stats.c +++ b/net/rds/stats.c @@ -89,8 +89,7 @@ void rds_stats_info_copy(struct rds_info_iterator *iter, for (i = 0; i < nr; i++) { BUG_ON(strlen(names[i]) >= sizeof(ctr.name)); - strncpy(ctr.name, names[i], sizeof(ctr.name) - 1); - ctr.name[sizeof(ctr.name) - 1] = '\0'; + strscpy_pad(ctr.name, names[i]); ctr.value = values[i]; rds_info_copy(iter, &ctr, sizeof(ctr));