[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <202101081147.E1D29E4C8F@keescook>
Date: Fri, 8 Jan 2021 11:48:44 -0800
From: Kees Cook <keescook@...omium.org>
To: Joe Perches <joe@...ches.com>
Cc: Dwaipayan Ray <dwaipayanray1@...il.com>,
Jonathan Corbet <corbet@....net>,
linux-kernel-mentees@...ts.linuxfoundation.org,
linux-kernel <linux-kernel@...r.kernel.org>,
Lukas Bulwahn <lukas.bulwahn@...il.com>,
Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: deprecated.rst: deprecated strcpy ? (was: [PATCH] checkpatch:
add a new check for strcpy/strlcpy uses)
On Thu, Jan 07, 2021 at 04:51:31PM -0800, Joe Perches wrote:
> I still like the stracpy variant I proposed:
>
> https://lore.kernel.org/lkml/24bb53c57767c1c2a8f266c305a670f7@sk2.org/T/#m0627aa770a076af1937cb5c610ed71dab3f1da72
> https://lore.kernel.org/lkml/CAHk-=wgqQKoAnhmhGE-2PBFt7oQs9LLAATKbYa573UO=DPBE0Q@mail.gmail.com/
>
> Linus liked a variant he called copy_string:
>
> https://lore.kernel.org/lkml/CAHk-=wg8vLmmwTGhXM51NpSWJW8RFEAKoXxG0Hu_Q9Uwbjj8kw@mail.gmail.com/
>
> I think the cocci scripts that convert:
>
> strlcpy -> strscpy (only when return value unused)
> str<sln>cpy(array, "string") -> stracpy(foo, "string")
> s[cn]printf -> sysfs_emit
>
> would leave relatively few uses of strcpy and sprintf variants and would
> make it much easier to analyze the remainder uses for potential overflows.
I think that would be lovely; yes. :)
--
Kees Cook
Powered by blists - more mailing lists