[LTP] [PATCH v3 9/9] Test for CVE-2017-2671 on ping sockets

Cyril Hrubis chrubis@suse.cz
Thu Jul 20 14:08:07 CEST 2017


Hi!
> +static void run(void)
> +{
> +	pthread_t thrd;
> +	int i;
> +
> +	sockfd = SAFE_SOCKET(AF_INET, SOCK_DGRAM, IPPROTO_ICMP);
> +	tst_res(TINFO, "Created ping socket, attempting to race...");
> +
> +	for (i = 0; i < ATTEMPTS; i++) {
> +		SAFE_CONNECT(sockfd,
> +			     (struct sockaddr *)&iaddr, sizeof(iaddr));
> +		SAFE_PTHREAD_CREATE(&thrd, 0, connect_b, 0);
> +
> +		tst_fzsync_delay_a(&fzsync_pair);
> +		connect(sockfd, (struct sockaddr *)&uaddr, sizeof(uaddr));
> +		tst_fzsync_time_a(&fzsync_pair);
> +
> +		SAFE_PTHREAD_JOIN(thrd, 0);
> +		tst_fzsync_pair_update(i, &fzsync_pair);
> +
> +		if (!(i & 0x7FFF))
> +			tst_fzsync_pair_info(&fzsync_pair);
> +	}
> +
> +	tst_res(TPASS, "We didn't crash");

Hmm, shouldn't we close the sockfd here?

Or even better cannot we create the socket in the test setup and destroy
it in the test cleanup. That way everything should work fine even with
the -i option.

> +}
> +
> +static struct tst_test test = {
> +	.setup = setup,
> +	.test_all = run,
> +	.cleanup = cleanup,
> +	.needs_root = 1,
> +};
> -- 
> 2.12.2
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list