Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp117026lqp; Wed, 20 Mar 2024 15:49:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWB5WW/YlGvF87v0ZWVDJ7aRa+CXfiyYQbJPGVR+TvSVOJ8Xm4Gr3p4ss3qiPkqalR+lJdJFN+wCnymt26b0BKobi5jN67YN6P9VUrjpQ== X-Google-Smtp-Source: AGHT+IHtuYl4KOXwUbS/13Askvs+EC61eF1/7uZhqxxBtNfEAV4L1sKz0cx2jFQ4y+RVXX5DfWum X-Received: by 2002:a25:dc87:0:b0:dcd:5c7:8466 with SMTP id y129-20020a25dc87000000b00dcd05c78466mr229965ybe.44.1710974958159; Wed, 20 Mar 2024 15:49:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710974958; cv=pass; d=google.com; s=arc-20160816; b=XSftpRHCNgBDsgoyRK+l7ov20Jd9fPQ5Oa8vbCqg2+Y3Bhxwv3cHG1GyzIPsfhlaYv vwhS4VvxLxly6qPCWZsYXR4yAbzczlOhVb+ohb7zQSQMChZxIBGn8ZrJC9cbUtDxuKrI smd3GkhIkkW0mCnJ85HFn0IjM4cFwJLhMVkzNqKB8In64W3K2A9nNo9kDWAuRGpjvJ+6 39jVYZivJ1jBDpKRXIgYzdK/RDkRQKwIR6ryMd9nwpnHLKY9QWgJadvZmoWTihERqVnZ kjSykHBRG/F2jMHWBdUpFky9JRq/ylTAs8cS+U5TGf1oLSCv754q0PxMvE7Tt4bo4/EY 9F/Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:in-reply-to:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :date:message-id:dkim-signature; bh=3CJUGRiLft1RVnawiUIsuSDglEUpPDsyNzOM15MSS5k=; fh=jtzSUIHe9I/aXr0EXcQmPFaAa6979gd3Bz962lis+WM=; b=z1WE8uamXIEFrSk1LfAAE4jimlrxh32QTihwifK+g/S6s7SsWZIZEg9OMu7kxtu8xK hiJy7Kjtp+s0lFQr+IQlkUhAsjfHPA9Irgkj5TrcDhVsEI+6crk/FTl17jNQ7KAzkNt3 9jHOGZh7LrAi5vsQJwInc3YpmBD9IHLFZjoV95Ys0k3M2UqpzMeWKWrsPW/wXtQLmLUg EuBGK0oS6BiWEGS+RERCC3PKgGdw0t+V9Pn3H1znJAXw9qmrk+M2iKVGJJ9ujk4PYFbQ Ud40rrC4BnkQUS6CWPnYBc8lH5uncKxJ2fIf0/nbVidV25o43f3qSH+lx+wXoCxQ1Eqo HNHQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=QSEhV8ON; arc=pass (i=1 spf=pass spfdomain=gmx.de dkim=pass dkdomain=gmx.de dmarc=pass fromdomain=gmx.de); spf=pass (google.com: domain of linux-kernel+bounces-109472-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109472-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g20-20020ac87d14000000b00430c09a979bsi9934912qtb.515.2024.03.20.15.49.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 15:49:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109472-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=QSEhV8ON; arc=pass (i=1 spf=pass spfdomain=gmx.de dkim=pass dkdomain=gmx.de dmarc=pass fromdomain=gmx.de); spf=pass (google.com: domain of linux-kernel+bounces-109472-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109472-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id CE4311C2123F for ; Wed, 20 Mar 2024 22:49:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 134238614C; Wed, 20 Mar 2024 22:49:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=deller@gmx.de header.b="QSEhV8ON" Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (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 2C23D3FBBC; Wed, 20 Mar 2024 22:48:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.20 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710974943; cv=none; b=faos45oRE4wqnvPlHElX2a+uIH6S37OyRL+ek1VdUMjcSn8oesb/r/QnUemZ3QWLuT1ATcCS6ZXSYh5ni6LDePMC6yMmFTTu+TyUTi1b3DVdS/+JPxQ55eX5bRyz6TxPTnty9mqvTLxnRzIpkNmwivH0y5PaHAc5/XFwP6Bhs/0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710974943; c=relaxed/simple; bh=bRuqgbXXWWglFMZPwdFOauwbKGXzNnFHTWL8jKD0JRA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=fRh6Uhd368Q3dvYmo0K5sdiLaw86xN0XTno2amezLGTWI7hnxBn1pL4ZaDu+HTWE3wTpR5jbuaz4hPPBpf6suGicT67Cx/5Hr4bnOgZuKwZ4AWBtHvt4AiHUleMmP7nENjyOqdL5gpyMghsYkNHotGhTHGuNDuT1k6fUiPLL9LU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=deller@gmx.de header.b=QSEhV8ON; arc=none smtp.client-ip=212.227.17.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1710974933; x=1711579733; i=deller@gmx.de; bh=3CJUGRiLft1RVnawiUIsuSDglEUpPDsyNzOM15MSS5k=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From: In-Reply-To; b=QSEhV8ONaS6oHkRsdkAQipk66hTrN3gbB6ms3YBI8o8UbUHWsGujy7pQ+mA6pPtv FPSBf3inOKgo4FixtoYVW/6l05bqRP3ONHW3sPMGkufSwGV8Y2K/1OeKZ51xLPxo5 PfYSnHOYoi3fpNTkepdVjThpBzU8mnGG/1tR0pRSSMkmza+s79Lk71JAwIgWF0yjd zbLW1vcUud3kNCRAU4kAZHgdgpuhRLLTAFRWHditiH1N998TKtm/bPWRupcAjsRoY iHB88YDdE8dW3DFb/xYxFapd0uvXm4jK8BpIlaOIB3wNOVv4QmBk/htffytKDSnj1 uquhl3njbkxB3v0DKw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.20.55] ([94.134.145.175]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MuUjC-1qvnKY3QUk-00rZeL; Wed, 20 Mar 2024 23:48:52 +0100 Message-ID: <49ba1e7d-d256-4644-beb9-c84b9feb0052@gmx.de> Date: Wed, 20 Mar 2024 23:48:52 +0100 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] video: fbdev: au1200fb: replace deprecated strncpy with strscpy Content-Language: en-US To: Justin Stitt Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Kees Cook References: <20240318-strncpy-drivers-video-fbdev-au1200fb-c-v1-1-680802a9f10a@google.com> <53670007-edbc-4762-9e57-0b3c29220d9e@gmx.de> From: Helge Deller Autocrypt: addr=deller@gmx.de; keydata= xsFNBF3Ia3MBEAD3nmWzMgQByYAWnb9cNqspnkb2GLVKzhoH2QD4eRpyDLA/3smlClbeKkWT HLnjgkbPFDmcmCz5V0Wv1mKYRClAHPCIBIJgyICqqUZo2qGmKstUx3pFAiztlXBANpRECgwJ r+8w6mkccOM9GhoPU0vMaD/UVJcJQzvrxVHO8EHS36aUkjKd6cOpdVbCt3qx8cEhCmaFEO6u CL+k5AZQoABbFQEBocZE1/lSYzaHkcHrjn4cQjc3CffXnUVYwlo8EYOtAHgMDC39s9a7S90L 69l6G73lYBD/Br5lnDPlG6dKfGFZZpQ1h8/x+Qz366Ojfq9MuuRJg7ZQpe6foiOtqwKym/zV dVvSdOOc5sHSpfwu5+BVAAyBd6hw4NddlAQUjHSRs3zJ9OfrEx2d3mIfXZ7+pMhZ7qX0Axlq Lq+B5cfLpzkPAgKn11tfXFxP+hcPHIts0bnDz4EEp+HraW+oRCH2m57Y9zhcJTOJaLw4YpTY GRUlF076vZ2Hz/xMEvIJddRGId7UXZgH9a32NDf+BUjWEZvFt1wFSW1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EhAbnvMJ2RTx8vGh7PssKaGzAUmNNZiG MB4mPKqvDZ02j1wp7vthQcOEg08z1+XHXb8ZZKST7yTVa5P89JymGE8CBGdQaAXnqYK3/yWf FwRDcGV6nxanxZGKEkSHHOm8jHwvQWvPP73pvuPBEPtKGLzbgd7OOcGZWtq2hNC6cRtsRdDx 4TAGMCz4j238m+2mdbdhRh3iBnWT5yPFfnv/2IjFAk+sdix1Mrr+LIDF++kiekeq0yUpDdc4 ExBy2xf6dd+tuFFBp3/VDN4U0UfG4QJ2fg19zE5Z8dS4jGIbLg== In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:kgmHypMzAwAtxFRQDJkQB7kMzEJKysT3Hkiuf/eetUOw6R7ltDd AwnC1b2e0nWV6oNg6Nxy/Mc85oQ+/mP2Y+mvN0Wyr+7c9Q+HraJDTpo+tI77NSHj4NkjvCt V7RUujZdyQGJUOTKNwRdInqIgQ1+RsTSy5Xa+aq4JLTA7jfN83cl37Z/uQh4WBKWRVri8Kp YzRlC1K74W0ksW3aDAm7g== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:l9UZQg9+1oI=;bHwAX/wZyhzG8DIIHq3sQE952kW 1OLjVe+KK6/eNIMKIRwSpdheF4LRdgEmMJDFJljgKzT69usgD0Cq/Lf93B3rVnOmw+0lTJj+3 RYpJF0klvCjcAezX0aFqF5PSw0NudVWHaqa6rTeP3lwhWuxDW04R8L4SbOTXTO729QByj7eo/ VVrxYwoeX0jKvoyMBVC22WlvLXcJzqXZ0VsrbI5rDQk7MvPoy1OhLI2pxFzSx0OVMJtxWRcmC ElgqwteYzBm9Nfe4NIvGG6f7LI+fhdA29clS+lvW3KUPYNa7M8zOCOObIjI5+XBzlejS6u8Pv PXFCYb+cOSrPhasADdWJLPCLJeq5AGwpwuIrVjLCph6ai/izWf/ghyx7jF4i8+tBDYj2+RqPn PhCpSWHwJEoLnFzFXn1F4DtnoIUVMtvqCbCMZuGrvDwMihNMg5/skGF7AD3Kprt+jdxpCeQ2p +ZDyFbXtmboMvdH+7/BKoh+cVkbcCH6MUJ8v4okQOKIJHj2n9i0D6iaDQaCY9rTOxZxkaXnNL GKFG88pTKaP88hrQXoD5FNGjmEJkQAQiuXlJpFUKbP7+FBI8X/INwQYONE3pEYG9/vMH13nTA jgCfk6PQxX3OqJxGktzfd0ycou20sw/j0R3fg3nUY4BUeSGl1U4aSYvajHR+5ibi8O+6XCQpc e+4IVSw+QmoZDzmEi6B1p0H5FwliKYNejubpfp1yJhXC9paGrHJgJosAGF1VD0ZBCxwPwZNk7 AogzoBhgzPZ/1WpMi/VZEukhlJiruCg6eBCxXDvXPMyiig20Xnx6yfAcHGyGBongjl8JOazW1 BA/0HGVS8qldlPoxKSj4G6i9Bdu+5zoe2iXqIOBfM27lU= On 3/20/24 23:35, Justin Stitt wrote: > Hi, > > On Wed, Mar 20, 2024 at 12:56=E2=80=AFAM Helge Deller wr= ote: >> >> On 3/19/24 00:46, Justin Stitt wrote: >>> strncpy() is deprecated for use on NUL-terminated destination strings >>> [1] and as such we should prefer more robust and less ambiguous string >>> interfaces. >>> >>> Let's use the new 2-argument strscpy() which guarantees NUL-terminatio= n >>> on the destination buffer while also simplifying the syntax. Note that >>> strscpy() will not NUL-pad the destination buffer like strncpy() does. >>> >>> However, the NUL-padding behavior of strncpy() is not required since >>> fbdev is already NUL-allocated from au1200fb_drv_probe() -> >>> frameuffer_alloc(), rendering any additional NUL-padding redundant. >>> | p =3D kzalloc(fb_info_size + size, GFP_KERNEL); >>> >>> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#s= trncpy-on-nul-terminated-strings [1] >>> Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.e= n.html [2] >>> Link: https://github.com/KSPP/linux/issues/90 >>> Cc: linux-hardening@vger.kernel.org >>> Signed-off-by: Justin Stitt >>> --- >>> Note: build-tested only. >>> >>> Found with: $ rg "strncpy\(" >>> --- >>> drivers/video/fbdev/au1200fb.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/drivers/video/fbdev/au1200fb.c b/drivers/video/fbdev/au12= 00fb.c >>> index 6f20efc663d7..e718fea63662 100644 >>> --- a/drivers/video/fbdev/au1200fb.c >>> +++ b/drivers/video/fbdev/au1200fb.c >>> @@ -1557,7 +1557,7 @@ static int au1200fb_init_fbinfo(struct au1200fb_= device *fbdev) >>> return ret; >>> } >>> >>> - strncpy(fbi->fix.id, "AU1200", sizeof(fbi->fix.id)); >>> + strscpy(fbi->fix.id, "AU1200"); >> >> I wonder if you really build-tested this, as this driver is for the mip= s architecture... >> And I don't see a strscpy() function which takes just 2 arguments. >> But I might be wrong.... > > I did build successfully :thumbs_up: > > Commit e6584c3964f2f ("string: Allow 2-argument strscpy()") introduced > this new strscpy() form; it is present in string.h on Linus' tree. Interesting patch. Might give compile problems if patches like yours gets automatically picked up to stable series as long as Kees patch hasn't been backported ye= t... Anyway, thanks for the pointer! I'll apply your patch in the next round for fbdev. Helge