Bug 497429

Summary: pwritev writes ramdom junk
Product: [Fedora] Fedora Reporter: Gerd Hoffmann <kraxel>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: urgent Docs Contact:
Priority: high    
Version: rawhideCC: jakub, markmc, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-04-27 20:13:27 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 446452    
Attachments:
Description Flags
/usr/src/debug/glibc-20090416T1610/sysdeps/posix/pwritev.c
none
glibc-pwritev.patch none

Description Gerd Hoffmann 2009-04-23 20:49:26 UTC
Created attachment 341009 [details]
/usr/src/debug/glibc-20090416T1610/sysdeps/posix/pwritev.c

Description of problem:
__atomic_pwritev_replacement is broken.

Version-Release number of selected component (if applicable):
glibc-2.9.90-19

How reproducible:
Grab a qemu git checkout, build it, try to use it.
Don't use a valuable guest image.

Actual results:
pwritev writes random data.

Expected results:
pwritev acts as documented.

Comment 1 Gerd Hoffmann 2009-04-23 20:54:07 UTC
Just look at the source code, it is obvious.

pwritev was copyed from preadv with a simple s/read/write/.  That isn't correct though, the buffer copying must be adjusted.

preadv has to do (and does that correctly):
  * alloc buffer
  * pread()
  * copy data to iovec
  * free buffer

pwritev has to do:
  * alloc buffer
  * copy data from iovec
  * pwrite()
  * free buffer.

pwritev actually does:
  * alloc buffer
  * pwritev()             <= writes random data
  * copy data to iovec    <= fills iovec with random data
  * free buffer.

Comment 2 Jakub Jelinek 2009-04-23 21:25:26 UTC
Created attachment 341021 [details]
glibc-pwritev.patch

Patch I'm about to test.

Comment 3 Gerd Hoffmann 2009-04-23 21:48:36 UTC
Patch looks good to me.

Comment 4 Mark McLoughlin 2009-04-24 08:49:19 UTC
Nice catch

Adding to F11Blocker - it doesn't affect F11 qemu, but we still shouldn't ship with a completely broken pwritev()

Comment 5 Mark McLoughlin 2009-04-27 15:33:03 UTC
Fix is in rpms/glibc/F-11 but not yet dist-f11:

* Fri Apr 24 2009 Jakub Jelinek <jakub> 2.9.90-20
- update from trunk
  - fix p{read,write}v{,64} (#497429, #497434)
  - fix strfmon (#496386)

Comment 6 Jakub Jelinek 2009-04-27 20:13:27 UTC
Should be fixed in glibc-2.9.90-22.