Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A use-after-free in the concurrent environment on ucthread[i] #166

Closed
ycaibb opened this issue Oct 1, 2020 · 1 comment
Closed

A use-after-free in the concurrent environment on ucthread[i] #166

ycaibb opened this issue Oct 1, 2020 · 1 comment

Comments

@ycaibb
Copy link

ycaibb commented Oct 1, 2020

Dear Developers:

Our static analysis tool reports a concurrency use-after-free due to race conditions in stream.c#L1865 and stream.c#L1515.

The code snippets are as follows.

static void *ucompthread(void *data)
{
          ...;
	dealloc(data);
	uci = &ucthread[i]; // alreadly freed
         ...;
	if (uci->c_type != CTYPE_NONE) {
		switch (uci->c_type) {
			case CTYPE_LZMA:
				ret = lzma_decompress_buf(control, uci);  //use site
				break;
			case CTYPE_LZO:
				ret = lzo_decompress_buf(control, uci);  //use site
				break;
			case CTYPE_BZIP2: 
				ret = bzip2_decompress_buf(control, uci);  //use site
				break;
			case CTYPE_GZIP:
				ret = gzip_decompress_buf(control, uci);  //use site
				break;
			case CTYPE_ZPAQ:
				ret = zpaq_decompress_buf(control, uci, i);  //use site
				break;
			default:
				failure_return(("Dunno wtf decompression type to use!\n"), NULL);
				break;
		}
	}
} 
int close_stream_in(rzip_control *control, void *ss)
{
	....;
	output_thread = 0;
	dealloc(ucthread);   // line1865
	dealloc(threads); 
	dealloc(sinfo->s);
	dealloc(sinfo);

	return 0;
}

Thank you.

@ckolivas
Copy link
Owner

Fixed in git master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants