git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Buffer overflows

From
RDReece Dunn <msclrhd@googlemail.com>
Date
Aug 30, 2007, 21:35 UTC
Message-ID
<3f4fd2640708301435s7067137cp5db6334af844158a@mail.gmail.com>
In-Reply-To
<7D84F3C7-129D-4197-AAF1-46298E5D0136@iki.fi>
On 30/08/2007, Timo Sirainen <tss@iki.fi> wrote:
Show 17 quoted lines
> On 30.8.2007, at 23.46, Linus Torvalds wrote:
>
> > On Thu, 30 Aug 2007, Timo Sirainen wrote:
> >>
> >> Looks like nothing has happened since my last mail about this
> >> (http://marc.info/?l=git&m=117962988804430&w=2).
>
> > If you were to send in a patch that simply just fixed some random case
> > without introducing the other stuff in forms that nobody is used to,
> > people would probably react more.
>
> The problem is that the git code is full of these random cases. It's
> simply a huge job to even try to verify the correctness of it. Even
> if someone did that and fixed all the problems, tomorrow there would
> be new ones because noone bothers to even try to avoid them. So there
> really isn't any point in trying to make git secure until the coding
> style changes.

You don't want a manual check to do these kinds of checks. Not only is it a huge job, you have the human factor: people make mistakes. This is (in part) what the review process is for, but understanding how to identify code that is safe from buffer overruns, integer overflows and the like is a complex task. Also, it may work on 32-bit which has been verified, but not on 64-bit.

It would be far better to specify the rules on how to detect these issues into a static analysis tool and have that do the checking for you. Therefore, it is possible to detect when new problems have been added into the codebase. Does sparse support identifying these issues?

> The code should be easy to verify to be secure, and with some kind of
> a safe string API it's a lot easier than trying to figure out corner
> cases where strcpy() calls break.

Why is it easier? If you have a fixed-size buffer, why not use strncpy, which is what a safe string API is essentially doing anyway?

In this case, detecting strcpy usage can be done via grep. This is quick, simple and easy to repeat. Other things are more complicated, which is where automated verification tools help.

- Reece
Previous: Timo SirainenNext: Timo Sirainen
Message 5 of 26 in “Buffer overflows”
  1. Timo SirainenAug 30, 2007
  2. Lukas SandströmAug 30, 2007
  3. Linus TorvaldsAug 30, 2007
  4. Timo SirainenAug 30, 2007
  5. Reece DunnAug 30, 2007
  6. Timo SirainenAug 30, 2007
  7. Reece DunnAug 30, 2007
  8. Wincent ColaiutaAug 31, 2007
  9. Simon 'corecode' SchubertAug 31, 2007
  10. Junio C HamanoAug 30, 2007
  11. Pierre HabouzitAug 30, 2007
  12. Timo SirainenAug 30, 2007
  13. Johan HerlandSep 2, 2007
  14. Reece DunnSep 2, 2007
  15. David KastrupSep 2, 2007
  16. Reece DunnSep 2, 2007
  17. Jakub NarebskiSep 3, 2007
  18. Junio C HamanoSep 3, 2007
  19. René ScharfeSep 2, 2007
  20. Lukas SandströmSep 2, 2007
  21. Linus TorvaldsAug 31, 2007
  22. Timo SirainenAug 31, 2007
  23. Andreas EricssonAug 31, 2007
  24. Johannes SchindelinAug 31, 2007
  25. Temporary fix for stack smashing in mailinfoAlex Riesen, Aug 30, 2007
  26. Junio C HamanoAug 30, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.