From patchwork Mon Apr 21 12:13:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gui Hecheng X-Patchwork-Id: 4024001 X-Patchwork-Delegate: dave@jikos.cz 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 634749F391 for ; Mon, 21 Apr 2014 12:18:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 722752015E for ; Mon, 21 Apr 2014 12:18:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 83EA620219 for ; Mon, 21 Apr 2014 12:18:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752057AbaDUMSH (ORCPT ); Mon, 21 Apr 2014 08:18:07 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:52084 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751897AbaDUMSC (ORCPT ); Mon, 21 Apr 2014 08:18:02 -0400 X-IronPort-AV: E=Sophos;i="4.97,896,1389715200"; d="scan'208";a="29520275" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 21 Apr 2014 20:15:33 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s3LCI08o032318 for ; Mon, 21 Apr 2014 20:18:00 +0800 Received: from localhost.localdomain (10.167.226.111) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.146.2; Mon, 21 Apr 2014 20:18:03 +0800 From: Gui Hecheng To: CC: Gui Hecheng Subject: [PATCH 1/2] btrfs-progs: fix wrong max system array size check in user space Date: Mon, 21 Apr 2014 20:13:31 +0800 Message-ID: <1398082412-5805-1-git-send-email-guihc.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.1.4 MIME-Version: 1.0 X-Originating-IP: [10.167.226.111] 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=ham 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 For system chunk array, We copy a "disk_key" and an chunk item each time, so there should be enough space to hold both of them, not only the chunk item. Signed-off-by: Gui Hecheng --- volumes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/volumes.c b/volumes.c index 77ffd32..b39f374 100644 --- a/volumes.c +++ b/volumes.c @@ -630,7 +630,8 @@ int btrfs_add_system_chunk(struct btrfs_trans_handle *trans, u8 *ptr; array_size = btrfs_super_sys_array_size(super_copy); - if (array_size + item_size > BTRFS_SYSTEM_CHUNK_ARRAY_SIZE) + if (array_size + item_size + sizeof(disk_key) + > BTRFS_SYSTEM_CHUNK_ARRAY_SIZE) return -EFBIG; ptr = super_copy->sys_chunk_array + array_size;