From patchwork Tue Dec 21 23:48:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Farina X-Patchwork-Id: 425371 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 oBLNnMOl009251 for ; Tue, 21 Dec 2010 23:49:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752684Ab0LUXtA (ORCPT ); Tue, 21 Dec 2010 18:49:00 -0500 Received: from mail-gy0-f174.google.com ([209.85.160.174]:35863 "EHLO mail-gy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751799Ab0LUXs7 (ORCPT ); Tue, 21 Dec 2010 18:48:59 -0500 Received: by gyb11 with SMTP id 11so1882826gyb.19 for ; Tue, 21 Dec 2010 15:48:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references:mime-version :content-type:content-transfer-encoding; bh=0jzFftw+5XxFFbrxdXfgKPOXXnrFSvDIXzB9louEVeI=; b=WCCUVrcLX1GoWEqbsXNbqIUm/PQ+ss4aZxZwyciJxGsSbi1tVoJrJn+Vayky8MXCo8 qmD5JUQhUxKd/D7izZ9vXysr5JvPPumsEtVvMdk3GEno/p/QwyiMvUzmQLfP0u0cFkw0 RMAu9tcvvkh+SexoNv0jO9NqwFwKR93Sk+I/U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :mime-version:content-type:content-transfer-encoding; b=SbVueKruNaJs38xQ7ApZjv2dNshte2t3dnRzVpBrLUpLgjSCcwxrY4lROckpfAuTU7 +l3o9JcQUsWGH0V5ggzMH9TJqlOoG1FBjFBBdWnp0alZWVupWs1LmaSS9BTqiisdEEfD nva5jKyjAbCrrcVyXb67/TocjoKbwYamA8WK0= Received: by 10.236.109.3 with SMTP id r3mr11695887yhg.30.1292975339094; Tue, 21 Dec 2010 15:48:59 -0800 (PST) Received: from localhost ([186.205.6.151]) by mx.google.com with ESMTPS id 55sm3167908yhl.37.2010.12.21.15.48.56 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 21 Dec 2010 15:48:58 -0800 (PST) From: Thiago Farina To: linux-kernel@vger.kernel.org Cc: arnd@arndb.de, Guennadi Liakhovetski , Mauro Carvalho Chehab , linux-media@vger.kernel.org Subject: [PATCH v2] drivers/media/video/v4l2-compat-ioctl32.c: Check the return value of copy_to_user Date: Tue, 21 Dec 2010 21:48:45 -0200 Message-Id: <83948188cda2388c2e22a50119dfb0023fba759a.1292975147.git.tfransosi@gmail.com> X-Mailer: git-send-email 1.7.3.2.343.g7d43d In-Reply-To: <201012212003.11446.arnd@arndb.de> References: <201012212003.11446.arnd@arndb.de> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 21 Dec 2010 23:49:23 +0000 (UTC) diff --git a/drivers/media/video/v4l2-compat-ioctl32.c b/drivers/media/video/v4l2-compat-ioctl32.c index e30e8df..6f2a022 100644 --- a/drivers/media/video/v4l2-compat-ioctl32.c +++ b/drivers/media/video/v4l2-compat-ioctl32.c @@ -201,14 +201,12 @@ static struct video_code __user *get_microcode32(struct video_code32 *kp) up = compat_alloc_user_space(sizeof(*up)); - /* - * NOTE! We don't actually care if these fail. If the - * user address is invalid, the native ioctl will do - * the error handling for us - */ - (void) copy_to_user(up->loadwhat, kp->loadwhat, sizeof(up->loadwhat)); - (void) put_user(kp->datasize, &up->datasize); - (void) put_user(compat_ptr(kp->data), &up->data); + if (copy_to_user(up->loadwhat, kp->loadwhat, sizeof(up->loadwhat))) + return NULL; + if (put_user(kp->datasize, &up->datasize)) + return NULL; + if (put_user(compat_ptr(kp->data), &up->data)) + return NULL; return up; }