[PATCH] linux-user/syscall.c: fix missed flag for shared memory in open_self_maps

Andrey Kazmin posted 1 patch 2 years, 4 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20211227125048.22610-1-a.kazmin@partner.samsung.com
Maintainers: Laurent Vivier <laurent@vivier.eu>
linux-user/syscall.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] linux-user/syscall.c: fix missed flag for shared memory in open_self_maps
Posted by Andrey Kazmin 2 years, 4 months ago
The possible variants for region type in /proc/self/maps are either
private "p" or shared "s". In the current implementation,
we mark shared regions as "-". It could break memory mapping parsers
such as included into ASan/HWASan sanitizers.

Signed-off-by: Andrey Kazmin <a.kazmin@partner.samsung.com>
---
 linux-user/syscall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 56a3e17183..2199a98725 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7790,7 +7790,7 @@ static int open_self_maps(void *cpu_env, int fd)
                             (flags & PAGE_READ) ? 'r' : '-',
                             (flags & PAGE_WRITE_ORG) ? 'w' : '-',
                             (flags & PAGE_EXEC) ? 'x' : '-',
-                            e->is_priv ? 'p' : '-',
+                            e->is_priv ? 'p' : 's',
                             (uint64_t) e->offset, e->dev, e->inode);
             if (path) {
                 dprintf(fd, "%*s%s\n", 73 - count, "", path);
-- 
2.17.1


Re: [PATCH] linux-user/syscall.c: fix missed flag for shared memory in open_self_maps
Posted by Laurent Vivier 2 years, 4 months ago
Le 27/12/2021 à 13:50, Andrey Kazmin a écrit :
> The possible variants for region type in /proc/self/maps are either
> private "p" or shared "s". In the current implementation,
> we mark shared regions as "-". It could break memory mapping parsers
> such as included into ASan/HWASan sanitizers.
> 
> Signed-off-by: Andrey Kazmin <a.kazmin@partner.samsung.com>
> ---
>   linux-user/syscall.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 56a3e17183..2199a98725 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -7790,7 +7790,7 @@ static int open_self_maps(void *cpu_env, int fd)
>                               (flags & PAGE_READ) ? 'r' : '-',
>                               (flags & PAGE_WRITE_ORG) ? 'w' : '-',
>                               (flags & PAGE_EXEC) ? 'x' : '-',
> -                            e->is_priv ? 'p' : '-',
> +                            e->is_priv ? 'p' : 's',
>                               (uint64_t) e->offset, e->dev, e->inode);
>               if (path) {
>                   dprintf(fd, "%*s%s\n", 73 - count, "", path);

Fixes: 01ef6b9e4e4e ("linux-user: factor out reading of /proc/self/maps")
Cc: alex.bennee@linaro.org
Reviewed-by: Laurent Vivier <laurent@vivier.eu>

Re: [PATCH] linux-user/syscall.c: fix missed flag for shared memory in open_self_maps
Posted by Alex Bennée 2 years, 4 months ago
Laurent Vivier <laurent@vivier.eu> writes:

> Le 27/12/2021 à 13:50, Andrey Kazmin a écrit :
>> The possible variants for region type in /proc/self/maps are either
>> private "p" or shared "s". In the current implementation,
>> we mark shared regions as "-". It could break memory mapping parsers
>> such as included into ASan/HWASan sanitizers.
>> Signed-off-by: Andrey Kazmin <a.kazmin@partner.samsung.com>

Acked-by: Alex Bennée <alex.bennee@linaro.org>

-- 
Alex Bennée

Re: [PATCH] linux-user/syscall.c: fix missed flag for shared memory in open_self_maps
Posted by Laurent Vivier 2 years, 4 months ago
Le 27/12/2021 à 13:50, Andrey Kazmin a écrit :
> The possible variants for region type in /proc/self/maps are either
> private "p" or shared "s". In the current implementation,
> we mark shared regions as "-". It could break memory mapping parsers
> such as included into ASan/HWASan sanitizers.
> 
> Signed-off-by: Andrey Kazmin <a.kazmin@partner.samsung.com>
> ---
>   linux-user/syscall.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 56a3e17183..2199a98725 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -7790,7 +7790,7 @@ static int open_self_maps(void *cpu_env, int fd)
>                               (flags & PAGE_READ) ? 'r' : '-',
>                               (flags & PAGE_WRITE_ORG) ? 'w' : '-',
>                               (flags & PAGE_EXEC) ? 'x' : '-',
> -                            e->is_priv ? 'p' : '-',
> +                            e->is_priv ? 'p' : 's',
>                               (uint64_t) e->offset, e->dev, e->inode);
>               if (path) {
>                   dprintf(fd, "%*s%s\n", 73 - count, "", path);


Applied to my linux-user-for-7.0 branch.

Thanks,
Laurent