From patchwork Sun Sep 28 08:48:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 4991191 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E70239F2BB for ; Sun, 28 Sep 2014 08:48:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0CCF4201BC for ; Sun, 28 Sep 2014 08:48:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03076201C8 for ; Sun, 28 Sep 2014 08:48:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753642AbaI1IrY (ORCPT ); Sun, 28 Sep 2014 04:47:24 -0400 Received: from mail-pd0-f181.google.com ([209.85.192.181]:50845 "EHLO mail-pd0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753559AbaI1IrT (ORCPT ); Sun, 28 Sep 2014 04:47:19 -0400 Received: by mail-pd0-f181.google.com with SMTP id z10so1496442pdj.26 for ; Sun, 28 Sep 2014 01:47:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Xgb6HZtRWQ0NSroDHSVmE1pNEIWtuEZdiEwgY+4291U=; b=kqygMxaFzvQQde+NkCLbYwf5JivCr4bNOt5ZRAaWVHjePdmIlCM27A8U2NdtU+0du+ HvTQfAHOeJFIloUiuFADcYVoFSSQQAs82k1kT3Q/KNJbwOqmkGViJi7fznm48SS5PXXD a8qPgHdzW92/y+vgyrbYH35k/7SWZhrvtL6thRkSz/tFjKIp3WbYzbNfPrfdNxWw/VLb K+j/JN2jDKi03j9zNJY4e120AT9L9Q6+O3az+rvPqR8EAOpM4aRcArnUjw6COkkFsZNH uYe8+fDCDaSSCwE+MuBgayHsaa3IDp5sKGcZJPiJmm9IhD81tC5hT0YvPu+dP+Zhp+WW T3Xw== X-Gm-Message-State: ALoCoQlxChK1DofhBALf7pntelBWDx/I/+JxAtMgkUJJcf99T9ogm1KYtQeW+RWA9uw2U0YvWN8e X-Received: by 10.68.139.163 with SMTP id qz3mr49755189pbb.26.1411894039361; Sun, 28 Sep 2014 01:47:19 -0700 (PDT) Received: from molino.home.network (c-24-19-133-29.hsd1.wa.comcast.net. [24.19.133.29]) by mx.google.com with ESMTPSA id cf4sm9217882pbb.87.2014.09.28.01.47.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 28 Sep 2014 01:47:17 -0700 (PDT) From: Omar Sandoval To: Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] btrfs: fix sparse address space warnings Date: Sun, 28 Sep 2014 01:48:11 -0700 Message-Id: <1411894092-28784-2-git-send-email-osandov@osandov.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1411894092-28784-1-git-send-email-osandov@osandov.com> References: <1411894092-28784-1-git-send-email-osandov@osandov.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The buffer passed to vfs_write in send and several casts of ioctl fields are missing the __user annotation. Also fixes a couple of related trivial style issues. Signed-off-by: Omar Sandoval Reviewed-by: David Sterba --- fs/btrfs/ioctl.c | 6 +++--- fs/btrfs/send.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 8a8e298..0f9a5a1 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2176,7 +2176,7 @@ static noinline int btrfs_ioctl_tree_search_v2(struct file *file, inode = file_inode(file); ret = search_ioctl(inode, &args.key, &buf_size, - (char *)(&uarg->buf[0])); + (char __user *)(&uarg->buf[0])); if (ret == 0 && copy_to_user(&uarg->key, &args.key, sizeof(args.key))) ret = -EFAULT; else if (ret == -EOVERFLOW && @@ -4247,7 +4247,7 @@ static long btrfs_ioctl_ino_to_path(struct btrfs_root *root, void __user *arg) ipath->fspath->val[i] = rel_ptr; } - ret = copy_to_user((void *)(unsigned long)ipa->fspath, + ret = copy_to_user((void __user *)(unsigned long)ipa->fspath, (void *)(unsigned long)ipath->fspath, size); if (ret) { ret = -EFAULT; @@ -4322,7 +4322,7 @@ static long btrfs_ioctl_logical_to_ino(struct btrfs_root *root, if (ret < 0) goto out; - ret = copy_to_user((void *)(unsigned long)loi->inodes, + ret = copy_to_user((void __user *)(unsigned long)loi->inodes, (void *)(unsigned long)inodes, size); if (ret) ret = -EFAULT; diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 6528aa6..e0be577 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -515,7 +515,8 @@ static int write_buf(struct file *filp, const void *buf, u32 len, loff_t *off) set_fs(KERNEL_DS); while (pos < len) { - ret = vfs_write(filp, (char *)buf + pos, len - pos, off); + ret = vfs_write(filp, (__force const char __user *)buf + pos, + len - pos, off); /* TODO handle that correctly */ /*if (ret == -ERESTARTSYS) { continue; @@ -639,8 +640,7 @@ static int send_header(struct send_ctx *sctx) strcpy(hdr.magic, BTRFS_SEND_STREAM_MAGIC); hdr.version = cpu_to_le32(BTRFS_SEND_STREAM_VERSION); - return write_buf(sctx->send_filp, &hdr, sizeof(hdr), - &sctx->send_off); + return write_buf(sctx->send_filp, &hdr, sizeof(hdr), &sctx->send_off); } /* @@ -676,7 +676,7 @@ static int send_cmd(struct send_ctx *sctx) hdr->crc = cpu_to_le32(crc); ret = write_buf(sctx->send_filp, sctx->send_buf, sctx->send_size, - &sctx->send_off); + &sctx->send_off); sctx->total_send_size += sctx->send_size; sctx->cmd_send_size[le16_to_cpu(hdr->cmd)] += sctx->send_size;