Re: Generic HDLC interface continued

From: Krzysztof Halasa (khc@pm.waw.pl)
Date: Mon Sep 30 2002 - 18:48:23 EST


Francois Romieu <romieu@cogenit.fr> writes:

> > Not exactly. The caller always knows meaning of the returned value
> > (or it reports error etc). The caller doesn't just know size of the value
> > _in_advance_, as it isn't constant. Still, meaning of the variable portion
> > of the data is defined by the constant part.
>
> The caller doesn't know size in advance but he gets 'type' and 'size' at
> the same time. Why shouldn't 'size' be deduced from 'type' ?

The caller don't know the result size. It mallocs some space which is
long enough for usual things. Now, we have new super protocol with 100 KB
of config data, and the caller requests settings of that protocol.

With "size" variable, the caller signals that there are 500 bytes for
the result, and the kernel tells it that 100 KB are required, and that
it's BTW the super protocol itself. The caller can allocate more space
and try again, or just fail if it doesn't know the protocol.

Without "size" variable, the kernel tries to copy 100 KB to random
space, and we get results ranging from SEGV to mysterious behavior.

Please note that there is no call which could return the protocol
(or interface type) without copying the whole data - thus the caller
(utility) is unable to skip unknown interfaces.

-- 
Krzysztof Halasa
Network Administrator
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Oct 07 2002 - 22:00:26 EST