All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Doucha <mdoucha@suse.cz>
To: Petr Vorel <pvorel@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 2/2] Add test for ASLRn't bug
Date: Tue, 30 Jan 2024 13:19:12 +0100	[thread overview]
Message-ID: <d05e5314-05c1-448a-9cbf-9e8a98a4dc55@suse.cz> (raw)
In-Reply-To: <20240130112953.GB753541@pevik>

On 30. 01. 24 12:29, Petr Vorel wrote:
> 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

The distro developers' decision so far seems to be to mitigate the issue 
by increasing ASLR random bit count to maximum instead of fixing the 
bug. That's enough to make the test pass in normal mode but strict mode 
will keep failing, possibly forever.

>> +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).

Feel free to join the string during merge.

> 
>> +		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

-- 
Martin Doucha   mdoucha@suse.cz
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


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

  reply	other threads:[~2024-01-30 12:19 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
2024-01-30 12:19     ` Martin Doucha [this message]
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=d05e5314-05c1-448a-9cbf-9e8a98a4dc55@suse.cz \
    --to=mdoucha@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=pvorel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.