copyin() instead of sooptcopyin()?

Gleb Smirnoff glebius at freebsd.org
Wed Sep 1 05:00:32 PDT 2004


  Dear hackers,

  I have a case, when I need to pass a small argument to kernel,
and receive large reply using getsockopt().

First I get the argument:

	char var[MAX];
	...
	if ((error = sooptcopyin(sopt, var, MAX, 2))
	...

Then I push reply to it using sooptcopyout(). But userland receives it
truncated to MAX. The problem lives in sooptcopyin() implementation,
which changes sopt->sopt_valsize.

Now, in my patch I solve this using bare copyin(). Another approach
may be saving sopt->sopt_valsize before call to sooptcopyin(), and then
restoring it. Not a nice solution however...

The questions are:

1) Is it OK to use bare copyin()? Which hidden problems can arise?
2) Is that correct that soopcopy[in|out]() changes sopt's fields?

-- 
Totus tuus, Glebius.
GLEBIUS-RIPN GLEB-RIPE


More information about the freebsd-hackers mailing list