From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (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 03B5272 for ; Sat, 24 Jul 2021 11:15:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1627125335; bh=EbwSnGgErGioLtZ9SjG8svALcdfgzH3xpEgvBjbS5U4=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:References:In-Reply-To; b=NW4WWrySmiU9reoo2b5sQCrdB5nwVs3zpBCe/qsUaK3AWxAJz1rAxYurXRIC3X10J n2w0USAXFhr3W6/yl8vHNJmEOBksUKyIUu2v4OgB//w4YOWveyhw9PTU9dJKiKid1M sxW5dG6Pklh2dI5LQKRwH1YMCO5h7PklHsRgAas0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from titan ([83.52.228.41]) by mail.gmx.net (mrgmx004 [212.227.17.184]) with ESMTPSA (Nemesis) id 1MqJqD-1lJq7g0veV-00nQM3; Sat, 24 Jul 2021 13:15:35 +0200 Date: Sat, 24 Jul 2021 13:15:32 +0200 From: Len Baker To: Geert Uytterhoeven , Andy Shevchenko Cc: Len Baker , Greg Kroah-Hartman , Phil Reid , dri-devel , "open list:FRAMEBUFFER LAYER" , linux-staging@lists.linux.dev, Linux Kernel Mailing List Subject: Re: [PATCH] staging/fbtft: Remove all strcpy() uses Message-ID: <20210724111532.GB4709@titan> References: <20210718133920.15825-1-len.baker@gmx.com> Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Provags-ID: V03:K1:LGbsxKMon4WHzLQ8n04LauX8j5z6/6dVSMiYxp1Prrj9P7mNSD7 VvrTqT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T3bGxJxU2Pkrmm44x2iyoM1H3hlxzPfEbNJZAjhYJfY7oMXOf 1f8RYE27l5IYbUBlSVjHPXACVY1V2Egq2ZuHMfjEVMG+t9TLzmGKqcuMu6WOXzEeOzndhlmPv uKpTokgohCMEviVcbP75bnPHlu4Cu4BmP6ld0h5dKSWNPcAfmZ1KRMOkqm+L5WvyjSzf1ZU1p W5Gh5AsAOhwZY/8S6XNvap77VLaS2OkTtSKvk+abRN5Ev2X0sre0Cm+DGwSLGOD8srRFN5JVt KGCSqVwTh+ghso4Q+7F9fxlNabiB4laV7nj Content-Transfer-Encoding: quoted-printable On Mon, Jul 19, 2021 at 09:53:29AM +0200, Geert Uytterhoeven wrote: > On Sun, Jul 18, 2021 at 9:43 PM Andy Shevchenko > wrote: > > On Sun, Jul 18, 2021 at 4:43 PM Len Baker wrote: > > > strcpy() performs no bounds checking on the destination buffer. This > > > could result in linear overflows beyond the end of the buffer, leadi= ng > > > to all kinds of misbehaviors. The safe replacement is strscpy() but = in > > > this case it is simpler to add NULL to the first position since we w= ant > > "NULL" is a pointer value, "NUL" is the character with value zero. Ok, understood. Thanks. > > > > to empty the string. > > > > > This is a previous step in the path to remove the strcpy() function. > > > > Any document behind this (something to read on the site(s) more or > > less affiliated with what is going to happen in the kernel) to read > > background? > > > > ... > > > > > case -1: > > > i++; > > > /* make debug message */ > > > - strcpy(msg, ""); > > While this strcpy() is provably safe at compile-time, and will probably > be replaced by an assignment to zero by the compiler... > > > > + msg[0] =3D 0; > > > > Strictly speaking it should be '\0'. > > > > > j =3D i + 1; > > > while (par->init_sequence[j] >=3D 0) { > > > sprintf(str, "0x%02X ", par->init_se= quence[j]); > > ... the real danger is the > > strcat(msg, str); > > on the next line. > Fortunately this whole debug printing block (including the strcpy) > can (and should) be rewritten to just use "%*ph". Ok, I will work on it and I will send a v2 for review. Thanks for the feedback. > > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m= 68k.org > > In personal conversations with technical people, I call myself a hacker.= But > when I'm talking to journalists I just say "programmer" or something lik= e that. > -- Linus Torvalds Regards, Len