Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Mon, 15 Mar 2021 17:39:43 -0400
From: Dominic Chen <>
Subject: Issue with fread() and unaligned readv()

Not sure this counts as a problem in musl or the application, but I've 
been debugging a return error of EINVAL from `fread(&buf, 8, 16, f)`, 
where `f = fopen("/proc/self/pagemap", "r")`. Internally, musl converts 
this into a call to `readv(f->fd, iov, 2)`, where `iov = {{iov_base = 
buf, iov_len = 127}, {iov_base = f->buf, iov_len = 1024}}`. However, it 
turns out that the kernel VFS read implementation inside `pagemap_read` 
checks that both the file position and count are divisible by 
PM_ENTRY_BYTES (8 on x86_64), otherwise it rejects the read with EINVAL. 
In comparison, glibc's `_IO_file_xsgetn` does appear to try to maintain 
read alignment, although I haven't looked at it in detail.



Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.