Commit 3fbb8e7f authored by Pavel Emelyanov's avatar Pavel Emelyanov

proc: Open anon_dev mapped files with O_RDONLY

Commit a3a10c44 made all map_files opens happen with
O_PATH for speed. However some files (sockets and aio
rings) are not detected by this, since kernel's ->open
callback is not called and we don't get the ENXIO code.

Fix this by opening non-regular files with O_RDONLY.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent a20ed3c6
......@@ -177,6 +177,7 @@ static int vma_get_mapfile(char *fname, struct vma_area *vma, DIR *mfd,
struct vma_file_info *vfi, struct vma_file_info *prev_vfi)
{
char path[32];
int flags;
if (prev_vfi->vma && vfi_equal(vfi, prev_vfi)) {
struct vma_area *prev = prev_vfi->vma;
......@@ -214,7 +215,18 @@ static int vma_get_mapfile(char *fname, struct vma_area *vma, DIR *mfd,
* so later we might refer to it via /proc/self/fd/vm_file_fd
* if needed.
*/
vma->vm_file_fd = openat(dirfd(mfd), path, O_PATH);
flags = O_PATH;
if (vfi->dev_maj == 0)
/*
* Opening with O_PATH omits calling kernel ->open
* method, thus for some special files their type
* detection might be broken. Thus we open those with
* the O_RDONLY to potentially get ENXIO and check
* it below.
*/
flags = O_RDONLY;
vma->vm_file_fd = openat(dirfd(mfd), path, flags);
if (vma->vm_file_fd < 0) {
if (errno == ENOENT)
/* Just mapping w/o map_files link */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment