From: Cyril Hrubis <chrubis@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v5 2/3] Print prot flag when SAFE_MMAP() fails
Date: Wed, 13 Mar 2024 10:57:57 +0100 [thread overview]
Message-ID: <ZfF4pc0rWhXENvm2@rei> (raw)
In-Reply-To: <20240313092331.18069-3-andrea.cervesato@suse.de>
Hi!
> include/tst_safe_macros.h | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
> index 15f914619..63ad46b85 100644
> --- a/include/tst_safe_macros.h
> +++ b/include/tst_safe_macros.h
> @@ -304,12 +304,18 @@ static inline void *safe_mmap(const char *file, const int lineno,
> int prot, int flags, int fd, off_t offset)
> {
> void *rval;
> + char *prot_buf;
Shouldn't we add the TDEBUG message here?
> rval = mmap(addr, length, prot, flags, fd, offset);
> if (rval == MAP_FAILED) {
> + prot_buf = (char*) safe_malloc(file, lineno, 0, 512);
> + prot_to_str(prot, prot_buf);
> +
> tst_brk_(file, lineno, TBROK | TERRNO,
> - "mmap(%p,%zu,%d,%d,%d,%ld) failed",
> - addr, length, prot, flags, fd, (long) offset);
> + "mmap(%p,%zu,%s(%x),%d,%d,%ld) failed",
> + addr, length, prot_buf, prot, flags, fd, (long) offset);
> +
> + free(prot_buf);
This is fine as long as we switch to an on the stack array.
> }
>
> return rval;
> --
> 2.35.3
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-03-13 10:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-13 9:23 [LTP] [PATCH v5 0/3] SysV IPC bug reproducer Andrea Cervesato
2024-03-13 9:23 ` [LTP] [PATCH v5 1/3] Add SAFE_MPROTECT() macro Andrea Cervesato
2024-03-13 9:56 ` Cyril Hrubis
2024-03-13 9:59 ` Cyril Hrubis
2024-03-13 9:23 ` [LTP] [PATCH v5 2/3] Print prot flag when SAFE_MMAP() fails Andrea Cervesato
2024-03-13 9:57 ` Cyril Hrubis [this message]
2024-03-13 9:23 ` [LTP] [PATCH v5 3/3] Add shmat04 SysV IPC bug reproducer Andrea Cervesato
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=ZfF4pc0rWhXENvm2@rei \
--to=chrubis@suse.cz \
--cc=andrea.cervesato@suse.de \
--cc=ltp@lists.linux.it \
/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