From patchwork Thu May 27 10:01:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 102597 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4RA1ho8030906 for ; Thu, 27 May 2010 10:01:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758075Ab0E0KBf (ORCPT ); Thu, 27 May 2010 06:01:35 -0400 Received: from serv2.oss.ntt.co.jp ([222.151.198.100]:48030 "EHLO serv2.oss.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757378Ab0E0KBf (ORCPT ); Thu, 27 May 2010 06:01:35 -0400 Received: from serv2.oss.ntt.co.jp (localhost [127.0.0.1]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id 03E21248315; Thu, 27 May 2010 19:01:34 +0900 (JST) Received: from serv1.oss.ntt.co.jp (serv1.oss.ntt.co.jp [172.19.0.2]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id E3BBC248314; Thu, 27 May 2010 19:01:33 +0900 (JST) Received: from yshtky3.kern.oss.ntt.co.jp (unknown [172.17.1.110]) by serv1.oss.ntt.co.jp (Postfix) with SMTP id C51E511C11D; Thu, 27 May 2010 19:01:33 +0900 (JST) Date: Thu, 27 May 2010 19:01:58 +0900 From: Takuya Yoshikawa To: mst@redhat.com Cc: kvm@vger.kernel.org, virtualization@lists.osdl.org, netdev@vger.kernel.org Subject: [PATCH 2/3] vhost-net: fix to check the return value of copy_to/from_user() correctly Message-Id: <20100527190158.4587a2db.yoshikawa.takuya@oss.ntt.co.jp> In-Reply-To: <20100527185803.0c0213a1.yoshikawa.takuya@oss.ntt.co.jp> References: <20100527185803.0c0213a1.yoshikawa.takuya@oss.ntt.co.jp> X-Mailer: Sylpheed 3.0.2 (GTK+ 2.20.1; i486-pc-linux-gnu) Mime-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 27 May 2010 10:01:43 +0000 (UTC) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index aa88911..0f41c91 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -593,17 +593,17 @@ static long vhost_net_ioctl(struct file *f, unsigned int ioctl, int r; switch (ioctl) { case VHOST_NET_SET_BACKEND: - r = copy_from_user(&backend, argp, sizeof backend); - if (r < 0) - return r; + if (copy_from_user(&backend, argp, sizeof backend)) + return -EFAULT; return vhost_net_set_backend(n, backend.index, backend.fd); case VHOST_GET_FEATURES: features = VHOST_FEATURES; - return copy_to_user(featurep, &features, sizeof features); + if (copy_to_user(featurep, &features, sizeof features)) + return -EFAULT; + return 0; case VHOST_SET_FEATURES: - r = copy_from_user(&features, featurep, sizeof features); - if (r < 0) - return r; + if (copy_from_user(&features, featurep, sizeof features)) + return -EFAULT; if (features & ~VHOST_FEATURES) return -EOPNOTSUPP; return vhost_net_set_features(n, features);