[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] linux-user: Return EINVAL for getgroups() with negative g

From: Michael Tokarev
Subject: Re: [PATCH v2] linux-user: Return EINVAL for getgroups() with negative gidsetsize
Date: Fri, 9 Jun 2023 19:48:51 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0

09.06.2023 19:29, Peter Maydell wrote:
Coverity doesn't like the way we might end up calling getgroups()
with a NULL grouplist pointer. This is fine for the special case
of gidsetsize == 0, but we will also do it if the guest passes
us a negative gidsetsize. (CID 1512465)

Explicitly fail the negative gidsetsize with EINVAL, as the kernel
does. This means we definitely only call the libc getgroups()
with valid parameters. It also brings the getgroups() code in
to line with the setgroups() code.

Possibly Coverity may still complain about getgroups(0, NULL), but
that would be a false positive.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
v2: also change TARGET_NR_getgroups32 code

Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>

This can be applied to -trivial just fine, I think.  There's another
change in there already in exactly this area.

Thank you Peter!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]