Re: [PATCH] ipc/mqueue: Only perform resource calculation if user valid

From: Al Viro
Date: Fri Aug 24 2018 - 18:29:35 EST


On Fri, Aug 24, 2018 at 02:54:39PM -0700, Kees Cook wrote:

> The overflow was real, but the results went unused, so while the flaw
> is harmless, it's noisy for kernel fuzzers, and the fix makes things
> technically more efficient.

yes, yes, yes, yes and no. Compiler is quite capable of noticing
that targets of assignments are unused outside of that if (user), so
any mentioning of "technically more efficient" is somewhat ridiculous...

Just make that something along the lines of "results of these assignments
are only used under if (user). Moreover, in case if info->user is NULL
they might yield an integer overflow, confusing the fuzzers. The odds
of any compiler letting nasal demons fly on that are pretty much nil,
but it's cleaner to move these under if (user) anyway."