From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 D9E9240E8D1 for ; Tue, 9 Jun 2026 13:39:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781012382; cv=none; b=iMGvp9eqPn7gNRgpBjrVxA4xfPgN8ts/HN52MFC9fTKi52v3J8651+iBYhl2HlGivY9km1uwwCWRkTM4LutkTi1pMoXx/ZRcSDE8IBE6+mz+RtTMv+TL3BnFlnZrZzCsxJQDBShjjjuUrdx9dhUXrRVdPghhONkbJwQzuLPzAz4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781012382; c=relaxed/simple; bh=wtjPJAnglYI9Dj7GB9EESnje7qeI4+zON/gDJ4GXSSI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=P4L/tEkVuYdjUfGBxJdoxFk8+P6oMaEBIVXd7lVrwLFiDYnCav+IbQ6YFJS+VGnipJ0K5z9nqDVyptNcCDj2mN7ZMBHsJ/0Aila3/ZLZyJ0MGQAODjmkNYUrlEX93TGgqaNcITpovolGJXqBOA5K6OYIlUmow3wOS69i0Jv7MwI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=eN1SA366; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=bWmDiR65; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eN1SA366"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="bWmDiR65" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781012379; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=midNIA+cjqOgSDgw/FW1wAANg34nkC9zllETKh3Fse0=; b=eN1SA366aFYm+84xKYEh+ClxPJWFDmXHDVY1gCk+/aY2YiYjlYsHlAq/l/HkhyvME/153N Ae5K+Ys07dMVEx439LVSwOEVtfPZbbCde+l6iPpLBm9/OOuQBXtAA2yjJRQ0UVPRj0L52i pLDKZ10Scx7kcbNCMSFTw5RHxpL3ipg= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-696-jiGBiCsLNiKFy6pBRW7Qdg-1; Tue, 09 Jun 2026 09:39:38 -0400 X-MC-Unique: jiGBiCsLNiKFy6pBRW7Qdg-1 X-Mimecast-MFC-AGG-ID: jiGBiCsLNiKFy6pBRW7Qdg_1781012377 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-45eec2badc4so2755505f8f.2 for ; Tue, 09 Jun 2026 06:39:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781012377; x=1781617177; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=midNIA+cjqOgSDgw/FW1wAANg34nkC9zllETKh3Fse0=; b=bWmDiR65oxjrzYfYB9/K6Cgwjn/lGEhXG+AGZD2LGMnkPoh86/qlSAxVs6DOGJfHLd gSwRryUxlZj1Nx3zVXbESQ6nph9YIfRxGnjJNWWNvnQcDrjdk5hYnlE9PbrBaP+nDTEj RSqsYV8ewQ3AGJ35JmaEGcT0HP4qQLe/jvCWSZJDYZH5S4A6Cvsv+aGufSpPKTh/cmcj 6k8M/YVqYUguE9OMZicIj2rMJ36KiAe+WBWEp/it1gTlyeUsNGjozIuKmZGL0KvmwTVM CPUyx2ZW5Qx+iwqZEyNr5GyEZtHI/lWNV39zcAxaz+4P28fYvPieXnkbSf8FnwRaVWOy aRaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781012377; x=1781617177; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=midNIA+cjqOgSDgw/FW1wAANg34nkC9zllETKh3Fse0=; b=jZWVK/ywKH90994S17rFPrwqLU6rCegjA+zIIvSP6+u19yTmlct1hgd0/uPk//NxA2 Wqh24JG523GYfQoRVlnG1PmkuS+Sitr6FnXJfgfem6ivpi1FwWhTl2n/YoANbbJtS4QI +7pWAlwpnCGFgjpsXTTt5QM+g4Mgxh6UAxKt/TBdFH25Mdw7pw1hM58cvMLgxDAQlTI+ onKTQ4sXx5GBc36vfK9Ky5QFuN1tv0mLQxvwQ+yuwJB5VMe8ULmHmlh7hEneLSs6ERpF q+Sfo4PR64GwsKkPR6Dj+dZ3XLQRXp7qZUEuIAtoUJ7RDm6ALKDtuVIg7XUWwaZu/TXq c65g== X-Forwarded-Encrypted: i=1; AFNElJ/QEr6YVsOHk98OHnZvmHcEs669DVq1TQZyhXI442bd2QmhAkDDWisXM6fAMEFKhwfQabOjFoNstN5xbmE=@vger.kernel.org X-Gm-Message-State: AOJu0Yy6I8snLNjKPw2yUli8w4FgRxOi+hYsmcyGlys/H9D3E+JzVraY YdejHlu5xrEMuby3ux+8jnfQfYX+pQECtVrKc6pFJC5+OXeQZj1YPdGKcb2cA/sbL/sJfmi9npy nok5Zd59P7tFHbt/X5niTgtOkHEYbnOwgC2AtEZVOfdvEA+aCcQ6vfkDQu3CVjdPaZQ== X-Gm-Gg: Acq92OFo2AwkivvqO6O0622uZZmdeiFLza3du5PdkoK6RFaEjd0O1Jgm1JOxhV8W0tO vxY2LD+4Cp5vEvVKsXCIJ+IOCSDm+KVScgCq5sYxFBf4PC9gem6J8mXfEkZkMyEmvpc7M5ZWO12 zCcn417nDMn4nWfhwLAYqiuCAQlm+yAvW7uFOK2593rWg+nKfTmBcdUboRNRo8cmLMffTMQvM4A YolLfuFji6wdo/Rz/i1X8ZQVJG8ycS3ohYO7JrbDFq/v/CMTQQ+oe0/y47GJKOpB6lhbxIe7ExP RjGy0wiGggwHTWdPd85AjrsJdpjpij67M5GivRVE6f3U7y3WpUW1EFWdVZMyPp7RVfY3y1Y+V88 xVp4QZhd9/gpvURqbANEI8GQ2n9jl9h4CQyUHFc+i5EWS1blR/zvT0RR81PEDl/x9dQ== X-Received: by 2002:a5d:5270:0:b0:460:edd:ca89 with SMTP id ffacd0b85a97d-460306091e6mr24183886f8f.26.1781012377336; Tue, 09 Jun 2026 06:39:37 -0700 (PDT) X-Received: by 2002:a5d:5270:0:b0:460:edd:ca89 with SMTP id ffacd0b85a97d-460306091e6mr24183842f8f.26.1781012376909; Tue, 09 Jun 2026 06:39:36 -0700 (PDT) Received: from [192.168.88.32] ([150.228.93.44]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f344762sm67110899f8f.23.2026.06.09.06.39.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Jun 2026 06:39:36 -0700 (PDT) Message-ID: Date: Tue, 9 Jun 2026 15:39:35 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next] net/devlink: Use strscpy() to copy strings into arrays To: david.laight.linux@gmail.com, Kees Cook , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Arnd Bergmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jiri Pirko References: <20260608095523.2606-13-david.laight.linux@gmail.com> Content-Language: en-US From: Paolo Abeni In-Reply-To: <20260608095523.2606-13-david.laight.linux@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 6/8/26 11:54 AM, david.laight.linux@gmail.com wrote: > From: David Laight > > Replacing strcpy() with strscpy() ensures that overflow of the target > buffer cannot happen. > > Signed-off-by: David Laight > --- > This is one of a group of patches that remove potentially unbounded > strcpy() calls. > > They are mostly replaced by strscpy() or, when strlen() has just been > called, with memcpy() (usually including the '\0'). > > Calls with copy string literals into arrays are left unchanged. > They are safe and easily detected as such. > > The changes were made by getting the compiler to detect the calls and > then fixing the code by hand. > > Note that all the changes are only compile tested. > > Some Makefiles were changed to allow files to contain strcpy(). > As well as 'difficult to fix' files, this included 'show' functions > as they really need to use sysfs_emit() or seq_printf(). > > All the patches are being sent individually to avoid very long cc lists. > Apologies for the terse commit messages and likely unexpected tags. > (There are about 100 patches in total.) > > net/devlink/port.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/devlink/port.c b/net/devlink/port.c > index 485029d43428..108926d3f899 100644 > --- a/net/devlink/port.c > +++ b/net/devlink/port.c > @@ -1222,7 +1222,7 @@ static void __devlink_port_type_set(struct devlink_port *devlink_port, > devlink_port->type_eth.ifindex = netdev->ifindex; > BUILD_BUG_ON(sizeof(devlink_port->type_eth.ifname) != > sizeof(netdev->name)); > - strcpy(devlink_port->type_eth.ifname, netdev->name); > + strscpy(devlink_port->type_eth.ifname, netdev->name); Given the above BUILD_BUG, I don't see how this change can help?!? Generally speaking, I suggest restricting this kind of tool-assisted changes to real problems (if any). Thanks, Paolo