SVF-tools / SVF

Static Value-Flow Analysis Framework for Source Code
http://svf-tools.github.io/SVF/
Other
1.41k stars 437 forks source link

ExtAPI: dubious handling of some POSIX functions #1078

Open adriaanjacobs opened 1 year ago

adriaanjacobs commented 1 year ago

Debugging an unsound points-to set led me on a wild goose chase of ExtAPI functions that do not seem to be modeled entirely according to the semantics of the man pages.

Unsoundly modeled dynamic allocations

Pointers to static buffers modeled as EFT_NOSTRUCT_ALLOC

Many functions in the ExtAPI that are modeled as EFT_NOSTRUCT_ALLOC return a pointer to a statically allocated buffer instead. The return values of multiple calls to these functions should alias, but, if my understanding is right, they currently don't. If I understand correctly, EFT_STAT would be more appropriate? Examples include:

Missing ExtAPI entries

Methodology

There's more than the ones I listed here. I obtained some by just stumbling on them, but others by systematically scanning the man pages for tell-tale terminology. Most man pages of functions that dynamically allocate memory mention that the returned pointer can be "passed to free". Most man pages of functions that deal with statically allocated buffers mention "statically allocated" or "static buffer". I've found these queries to produce pretty precise results, with little noise.

Happy to supply pull requests for these if need be, just wanted to check if my understanding of the "new" ExtAPI is correct and whether it's desirable to update the handling of these functions.

yuleisui commented 1 year ago

Thanks for pointing them out. Your findings all make sense to me. Please go ahead with pull request. @shuangxiangkan could you please also check the above issues for external APIs?

yuleisui commented 1 year ago

I believe it is good to make a pull request @adriaanjacobs