Security and Malloc
Norm and Ira,
Thanks for the discussion on external supplied malloc, realloc and free
yesterday. The use of supplied memory functions was only intended for the
case of static/dynamic libraries since the client/service and application would internal solve the memory function issue. I believe your security case was that someone could send "harmful" memory function pointers (pointer to function) that would allow "break into" or cause a security breach. I understand this to a point but would like to understand more. Since in either case the library must be used with a main application and if the intent of the main application was to implement a security breach or have "harmful code"; then I contend that the main application could do this independent of any FSG library. Or they could modify the source that we supply for our libraries (we are an open-source activity) or they created
their own library (with "harmful code") based on the API. I don't believe
you could ever protect against this; so there is no solution to this specific security risk. So this only leaves the situation of proprietary library instantiation in which source is "never" supplied. That is, the main wants to send "harmful code" to a proprietary library instantiation. But again since the main can contain the "harmful code" is this case (of proprietary library instantiation) really a risk case?
A compromise to this situation is to use #defines for the memory function in the open source distributions. For example,
#define fsgMalloc malloc
#define fsgRemalloc realloc
#define . . . .
Now before compiling the developer could change the malloc, realloc, etc to there specific memory functions. If this is more agreeable that sending pointers to functions; then what is the complete list of memory functions needed?
I not think this can be optional; we need to make it mandatory or not implement it at all.
-----------------------
Although I am still in favor of the InitializeAPI and ReleaseAPI, I believe that for open-source versions of the API libraries, this capability can be
integrated independent of the any FSG specification. The problem arises
for proprietary library implementations or in services where it would not be possible to integration the additional control. If you truly want or it is a requirement for a library to be stateless (i.e. no check if it has been initialized or other state conditions) then I see no way to implement these two functions. The solution using proprietary library implementations and needing this functionality is to not use static libraries, load/remove dlls went needed and/or start/kill services. More restrictive but would "meet the need".
I not think this can be optional; we need to make it mandatory or not implement it at all.
Rgds,
Glen W. Petrie
Epson Imaging Technology Center
150 River Oaks Parkway, Suite 200
San Jose, CA, 95134
Voice: 408.576.4131 Fax: 408.474.0511