Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4559561imu; Tue, 29 Jan 2019 03:48:08 -0800 (PST) X-Google-Smtp-Source: ALg8bN60IS6spZt3kMo+zmP3nJPSvRG/XodLlS5Omn7d4sXACrdgc1+kKb2uPKxX+Gr6MYoDv5sL X-Received: by 2002:a63:2905:: with SMTP id p5mr23649927pgp.178.1548762488871; Tue, 29 Jan 2019 03:48:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548762488; cv=none; d=google.com; s=arc-20160816; b=eRklceZSAc9fOb3pM8aVnlqP/HaNfM2Nb+lXgfhBcps42AoVWazs+eEFipcJBnarZZ IEdNslW7NcOQILMS465kDPAZNSBsWbAqiTw/Uac6XEayivM0d4CDl98nhOAyNP7SZU/Q CGw+V8OmxNiMpEObIR8vHlIT6yISqTVv6KA/z+Ph3gmBRq6isbQZXx0AlB2+qm3OoNTe oJY3O111WNWO2kN0ZWckJ0ScYScd6HV1gh9YPPxjPY+gw6JZDs72Jn6ATPeLkGUOW3o3 Ww/IQvHXt46GcTuRk7Kbn3PmjI2VJzsDOHE2y9NeWEUi6Q/ZLWtCSVRK6T7lSclUgaDc TiHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VHbDCogiscUJKZgpc+818K1JNSvFtE0ZCp0gFEJJhdU=; b=RXeGXITte3ik15SF7ddGk//oLQyjzBri9vJHJjOYgZ8noOdW0wp47y7K9+qT4lHRoY YUsri7s8xtZS919Acav91WO8er+eoJEi7aH/KhtRrq+d+ZiywuDYvlnWtxsQhcFQJeD3 gh17vddGrCeb20GzW5rjfMhtNHhTK0IZV8r+eKaRVbrFetcFhggK9KZQH1GAOA9KZKN+ 0Cxf5rqiS7n+AmUHqT4wfs+OFKiqcwk/U+3nhdbEk8ZS4P8e/Tt8UCbXS0HAPFkJgBEC LjuHjPNz8En/RQO4CT6qGBUZwdDhs79m7SoF/qF4pYD0D8daowjgSn8waDJSxxv9BeJv 6zJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mh8P9NW7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z5si2710804pgu.19.2019.01.29.03.47.53; Tue, 29 Jan 2019 03:48:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mh8P9NW7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730573AbfA2LqX (ORCPT + 99 others); Tue, 29 Jan 2019 06:46:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:36922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730946AbfA2LqS (ORCPT ); Tue, 29 Jan 2019 06:46:18 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EB5C321874; Tue, 29 Jan 2019 11:46:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548762377; bh=wFGWZTSJ7nLDUK6UBAn7f+yjTCJctEKk7Vm4HKbNKPU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mh8P9NW7pf1Ah2USoxvUrTbwRubEKip7VIWc+dTOj5QvX6h6mbTrcL4oSZna+cn/M 2vHaqZqO8OTexe3IyqCDIuyF57D4hQwJmnTuOBvSeGdoIBbIU78pf6CHLVwbtkEYE0 bH/RaCwlddjBnCcsM/7gjxRYDpOmZzN8tsUHWNGc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kyungtae Kim , Peter Hutterer , Dmitry Torokhov Subject: [PATCH 4.19 060/103] Input: uinput - fix undefined behavior in uinput_validate_absinfo() Date: Tue, 29 Jan 2019 12:35:37 +0100 Message-Id: <20190129113204.281783124@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129113159.567154026@linuxfoundation.org> References: <20190129113159.567154026@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dmitry Torokhov commit d77651a227f8920dd7ec179b84e400cce844eeb3 upstream. An integer overflow may arise in uinput_validate_absinfo() if "max - min" can't be represented by an "int". We should check for overflow before trying to use the result. Reported-by: Kyungtae Kim Reviewed-by: Peter Hutterer Cc: stable@vger.kernel.org Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/misc/uinput.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include "../input-compat.h" @@ -405,7 +406,7 @@ static int uinput_open(struct inode *ino static int uinput_validate_absinfo(struct input_dev *dev, unsigned int code, const struct input_absinfo *abs) { - int min, max; + int min, max, range; min = abs->minimum; max = abs->maximum; @@ -417,7 +418,7 @@ static int uinput_validate_absinfo(struc return -EINVAL; } - if (abs->flat > max - min) { + if (!check_sub_overflow(max, min, &range) && abs->flat > range) { printk(KERN_DEBUG "%s: abs_flat #%02x out of range: %d (min:%d/max:%d)\n", UINPUT_NAME, code, abs->flat, min, max);