[BUG] False positive in scripts/checkpatch.pl

From: Heinrich Schuchardt
Date: Fri Jun 10 2016 - 21:26:46 EST


scripts/checkpatch.pl reports

ERROR: Please use git commit description style
'commit <12+ chars of sha1> ("<title line>")'-
ie: 'commit 0123456789ab ("commit description")'

for this patch.

On 64bit systems an undetected overflow may occur in
do_proc_dointvec_minmax_conv_param as can be demonstrated
with the following example:

# echo 9223372036854776806 > /proc/sys/kernel/threads-max
# cat /proc/sys/kernel/threads-max
998

Signed-off-by: Heinrich Schuchardt <xypron.glpk@xxxxxx>
---
kernel/sysctl.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 35f0dcb..a9e7be3 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2313,7 +2313,17 @@ static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
{
struct do_proc_dointvec_minmax_conv_param *param = data;
if (write) {
- int val = *negp ? -*lvalp : *lvalp;
+ int val;
+
+ if (*negp) {
+ if (*lvalp > (unsigned long) INT_MAX + 1)
+ return -EINVAL;
+ val = -*lvalp;
+ } else {
+ if (*lvalp > (unsigned long) INT_MAX)
+ return -EINVAL;
+ val = *lvalp;
+ }
if ((param->min && *param->min > val) ||
(param->max && *param->max < val))
return -EINVAL;
--
2.1.4