Hello Jakub, Jakub Wilk <jwilk@xxxxxxxxx> writes: > * Richard Palethorpe <rpalethorpe@xxxxxxxx>, 2021-07-08, 11:08: >>Please see upstream commit: >> >> commit dd83c161fbcc5d8be637ab159c0de015cbff5ba4 >> Author: zhongjiang <zhongjiang@xxxxxxxxxx> >> Date: Mon Jul 10 15:53:01 2017 -0700 >> >> kernel/exit.c: avoid undefined behaviour when calling wait4() >> >>It avoids negating INT_MIN by returning early with ESRCH. > > That sounds like a bug in the kernel, though? > > POSIX says the error should be ECHILD if "the process group specified > by pid does not exist". The absolute value of INT_MIN is undefined or "not representable" in two's complement. So I think this can reasonably be considered undefined behaviour and the kernel can do what it wants. Also, as the error code is different, we can detect if the fix has been applied without UBSAN enabled (unlike a similar fix in kill). OTOH, I would have probably used ECHILD for consistency. However it is done now and has been in use for some years. -- Thank you, Richard.