public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Martin Doucha <mdoucha@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 2/2] Add test for ASLRn't bug
Date: Tue, 30 Jan 2024 12:29:53 +0100	[thread overview]
Message-ID: <20240130112953.GB753541@pevik> (raw)
In-Reply-To: <20240117173006.31521-2-mdoucha@suse.cz>

Hi Martin,

Very nice work.
Reviewed-by: Petr Vorel <pvorel@suse.cz>

...
> +++ b/runtest/kernel_misc
> @@ -15,3 +15,4 @@ zram01 zram01.sh
>  zram02 zram02.sh
>  zram03 zram03
>  umip_basic_test umip_basic_test
> +aslr01 aslr01

I wonder, don't we want to run also with strict mode?
Do you want to avoid failure:
aslr01.c:241: TFAIL: Large lib base address has less than 28 random bits

> +static void find_large_lib(void)
> +{
> +	size_t hpsize, libsize = 0;
> +
> +	read_shared_libraries(find_large_lib_callback, &libsize);
> +
> +	if (!libsize) {
> +		tst_brk(TCONF,
> +			"No dynamic libraries loaded, please use LD_PRELOAD");
> +	}
> +
> +	hpsize = tst_get_hugepage_size();
> +	tst_res(TINFO, "Largest loaded library: %s (%zu bytes)", lib_path,
> +		libsize);
> +
> +	if (!hpsize) {
> +		tst_res(TCONF, "Hugepage support appears to be missing");
> +	} else if (libsize < hpsize) {
> +		tst_res(TCONF, "The largest dynamic library is smaller than "
> +			"hugepage size");

very nit: I would not split the string (better for grep).

> +		tst_res(TCONF, "Please use LD_PRELOAD to add larger library");
> +	}
> +}

...
> +	if (strict_check) {
> +		if (compat) {
> +			kconf_minbits = aslr_kconfigs[ASLR_COMPAT_MINBITS].val;
> +			minbits_path = "/proc/sys/vm/mmap_rnd_compat_bits";
> +		} else {
> +			kconf_minbits = aslr_kconfigs[ASLR_MINBITS].val;
> +			minbits_path = "/proc/sys/vm/mmap_rnd_bits";
> +		}
> +
> +		/*
> +		 * Reading mmap_rnd_bits usually requires root privileges.
> +		 * Fall back to kernel config values if unprivileged.
> +		 */
+1. So this require either only root or working kconfig.

> +		if (!access(minbits_path, R_OK))
> +			SAFE_FILE_SCANF(minbits_path, "%d", &minbits);
> +		else if (!kconf_minbits)
> +			tst_brk(TBROK, "Cannot determine kernel ASLR min bits");
> +		else if (tst_parse_int(kconf_minbits, &minbits, 1, 64))
> +			tst_brk(TBROK, "Invalid kernel ASLR min bits value");
> +	}
> +
> +	find_large_lib();
> +}

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2024-01-30 11:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-17 17:30 [LTP] [PATCH 1/2] Add tst_is_compat_mode() helper function Martin Doucha
2024-01-17 17:30 ` [LTP] [PATCH 2/2] Add test for ASLRn't bug Martin Doucha
2024-01-30 11:29   ` Petr Vorel [this message]
2024-01-30 12:19     ` Martin Doucha
2024-01-30 12:31       ` Petr Vorel
2024-01-30 16:30   ` Petr Vorel
2024-01-30 16:32     ` Martin Doucha
2024-01-30 16:53       ` Petr Vorel
2024-01-30 10:30 ` [LTP] [PATCH 1/2] Add tst_is_compat_mode() helper function Petr Vorel

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=20240130112953.GB753541@pevik \
    --to=pvorel@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=mdoucha@suse.cz \
    /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