Ronald,
Can you give some more details as to the specific scenario you want to
disable these checks for? <
Yes. Call gates seem to trip the buffer security code. This is true even
if the ring0 code does nothing more than save registers and flags and
restore them. Here is some pseudo-code.
template<class _TYPE1, class _TYPE2>
static bool __stdcall call_ring0(WORD wSegment, _TYPE1 Arg1, _TYPE2 Arg2 =
(_TYPE2)0)
{
bool bResult;
WORD farcall[3];
_ASSERTE(wSegment !=0);
farcall[2] = wSegment;
STATIC_CHECK(sizeof(Arg1) <= sizeof(int),
Argument_is_not_an_integral_type);
STATIC_CHECK(sizeof(Arg2) <= sizeof(int),
Argument_is_not_an_integral_type);
_asm mov edx, Arg1
_asm mov ecx, Arg2
_asm call fword ptr [farcall]
_asm mov eax, edx
_asm mov bResult, al
return bResult;
} <-- Buffer security warning here.
void __declspec(naked) ring0_func()
{
_asm {
pushad
pushf
cli
popf
popad
sti
retf
}
}
Note that this is not general use software and yes I know that using call
gates is not generally a good idea. It does seem that it should be
possible for an engineer to turn the feature on or off at compile time
(but not at runtime) in a specific instance to meet special needs.
Regards,
George.
Ronald Laeremans said:
No there is not. That is by design since the reason this feature is there
is because humans aren't good at analyzing what is exploitable in the
first place so /GS offers an additional level of protection when your
source review was flawed.
Can you give some more details as to the specific scenario you want to
disable these checks for?
Ronald Laeremans
Visual C++ team