Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933032AbcDKNcT (ORCPT ); Mon, 11 Apr 2016 09:32:19 -0400 Received: from mx2.suse.de ([195.135.220.15]:37403 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932579AbcDKNYT (ORCPT ); Mon, 11 Apr 2016 09:24:19 -0400 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" From: Jiri Slaby To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "Michael S. Tsirkin" , Guenter Roeck , Wim Van Sebroeck , Jiri Slaby Subject: [PATCH 3.12 75/98] watchdog: rc32434_wdt: fix ioctl error handling Date: Mon, 11 Apr 2016 15:23:17 +0200 Message-Id: <2e054c4f876f3810d67c76210bff1c3d3cd8d2eb.1460380917.git.jslaby@suse.cz> X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1243 Lines: 40 From: "Michael S. Tsirkin" 3.12-stable review patch. If anyone has any objections, please let me know. =============== commit 10e7ac22cdd4d211cef99afcb9371b70cb175be6 upstream. Calling return copy_to_user(...) in an ioctl will not do the right thing if there's a pagefault: copy_to_user returns the number of bytes not copied in this case. Fix up watchdog/rc32434_wdt to do return copy_to_user(...)) ? -EFAULT : 0; instead. Signed-off-by: Michael S. Tsirkin Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Jiri Slaby --- drivers/watchdog/rc32434_wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/watchdog/rc32434_wdt.c b/drivers/watchdog/rc32434_wdt.c index 9cf6bc7a234f..6f1ffd94a202 100644 --- a/drivers/watchdog/rc32434_wdt.c +++ b/drivers/watchdog/rc32434_wdt.c @@ -238,7 +238,7 @@ static long rc32434_wdt_ioctl(struct file *file, unsigned int cmd, return -EINVAL; /* Fall through */ case WDIOC_GETTIMEOUT: - return copy_to_user(argp, &timeout, sizeof(int)); + return copy_to_user(argp, &timeout, sizeof(int)) ? -EFAULT : 0; default: return -ENOTTY; } -- 2.8.1