mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Nick Orlov <bugfixer@list.ru>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	Nick Piggin <nickpiggin@yahoo.com.au>
Subject: Re: 2.6.19-rc4-mm1: writev() _functional_ regression
Date: Sun, 12 Nov 2006 15:45:53 -0800	[thread overview]
Message-ID: <20061112154553.459d6a63.akpm@osdl.org> (raw)
In-Reply-To: <20061112223024.GA4104@nickolas.homeunix.com>

On Sun, 12 Nov 2006 17:30:24 -0500
Nick Orlov <bugfixer@list.ru> wrote:

> Andrew,
> 
> Somewhere in between 2.6.18-mm3 and 2.6.19-rc4-mm1 writev() got screwed.
> It does not accept zero-length segments anymore.
> 
> Bad thing that it is extremely easy to trigger (even w/o explicit writev calls).
> For example the following innocent program will fail with 2.6.19-rc4-mm1:
> 
> ======================
> #include <string.h>
> #include <fstream>
> 
> int main()
> {
>   char buf[1024];
>   memset(buf, 'A', sizeof(buf));
>   std::ofstream ofs("test");
>   //ofs << 1 << '\n';
>   ofs.write(buf, sizeof(buf));
>   return 0;
> }
> ======================
> 
> 
> Here is the corresponding part if strace:
> 
> ======================
> open("test", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
> writev(3, [{NULL, 0}, {"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"..., 1024}], 2) = -1 EFAULT (Bad address)
> close(3)                                = 0
> ======================
> 
> 
> With 2.6.18-mm3 it works
> 
> ======================
> open("test", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
> writev(3, [{NULL, 0}, {"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"..., 1024}], 2) = 1024
> close(3)                                = 0
> ======================
> 
> 
> It works with 2.6.19-rc4-mm1 _if_ zero-length segments are eliminated
> (by uncommenting ofs << 1 << '\n'):
> 
> ======================
> open("test", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
> writev(3, [{"1\n", 2}, {"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"..., 1024}], 2) = 1026
> close(3)                                = 0
> ======================
> 
> 
> Given that _all_ applications using C++ streams are potentially affected
> I think it's better to preserve the previous behavior even if it is
> something from "undefined behavior world" (or a plain bug).
> 
> The bug is quite dangerous (I was really close to wipe out my mp3 collection).
> 

OK, thanks.  Those patches do need more work.  I'll shelve them for a while.

  reply	other threads:[~2006-11-12 23:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-12 22:30 Nick Orlov
2006-11-12 23:45 ` Andrew Morton [this message]
2006-11-27  7:17   ` Nick Piggin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061112154553.459d6a63.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=bugfixer@list.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nickpiggin@yahoo.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome