From patchwork Thu Jan 27 10:03:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Korsgaard X-Patchwork-Id: 510961 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0RA3p6U027305 for ; Thu, 27 Jan 2011 10:03:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752195Ab1A0KDv (ORCPT ); Thu, 27 Jan 2011 05:03:51 -0500 Received: from mail-ww0-f44.google.com ([74.125.82.44]:62919 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751997Ab1A0KDu (ORCPT ); Thu, 27 Jan 2011 05:03:50 -0500 Received: by wwa36 with SMTP id 36so1969798wwa.1 for ; Thu, 27 Jan 2011 02:03:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:to:cc:subject:date:message-id :x-mailer; bh=gKBtuRYbbHQtmgdhwDDywYNPa3t0Yjivaag01qz/jSI=; b=DoqV0GaRIY3/B2SBfiQeIE3xST7QvhG2DWw7TWRMTh28JF9/yKJk2PGirdowL5tXWe B2sxMqf/Z8blrVlnfp25baSqYCjtywHGGyuH1d4RPMIUv9jNtlXKyjzPkWb32h4+sRAm o4d9lXDTzLwjP/6MJguMKyupbNbrk+pZrE2y4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer; b=FUsrC+kieTyQCg8SvliALD+vdlgrudkeYZrLXngbNi6prA58Z79gj+P6IHUsCJjzN8 NiNd1Jhdf5kv8kk3uSXz6RBjz3FDTSTryPuXfTCGF62prnHxyjBx+Kl1B3sgyLA69wvH HHTc0klpuEuRWvuSztmv7dTsl68ktwLHP55rU= Received: by 10.227.133.143 with SMTP id f15mr760002wbt.115.1296122627279; Thu, 27 Jan 2011 02:03:47 -0800 (PST) Received: from macbook.be.48ers.dk (191.207-78-194.adsl-fix.skynet.be [194.78.207.191]) by mx.google.com with ESMTPS id y29sm6538879wbd.4.2011.01.27.02.03.39 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 27 Jan 2011 02:03:46 -0800 (PST) Received: by macbook.be.48ers.dk (Postfix, from userid 1000) id 0C84EC3AAA; Thu, 27 Jan 2011 11:03:29 +0100 (CET) From: Peter Korsgaard To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org, baruch@tkos.co.il Cc: Peter Korsgaard Subject: [PATCHv2] evdev: fix evdev_write return value on partial writes Date: Thu, 27 Jan 2011 11:03:27 +0100 Message-Id: <1296122607-9526-1-git-send-email-jacmet@sunsite.dk> X-Mailer: git-send-email 1.7.2.3 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 27 Jan 2011 10:03:52 +0000 (UTC) diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index c8471a2..1ee7d0f 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -321,6 +321,9 @@ static ssize_t evdev_write(struct file *file, const char __user *buffer, struct input_event event; int retval; + if (count < input_event_size()) + return -EINVAL; + retval = mutex_lock_interruptible(&evdev->mutex); if (retval) return retval; @@ -330,7 +333,7 @@ static ssize_t evdev_write(struct file *file, const char __user *buffer, goto out; } - while (retval < count) { + while ((retval + input_event_size()) <= count) { if (input_event_from_user(buffer + retval, &event)) { retval = -EFAULT;