Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp93083imp; Tue, 19 Feb 2019 18:57:33 -0800 (PST) X-Google-Smtp-Source: AHgI3IYejcuEOTlhzrwv8uQBJLISpvN/sBtqIoGeOgxmPqc6vUx2DrKQry5YkEvX5kDdGsixGCCs X-Received: by 2002:a62:5789:: with SMTP id i9mr31914943pfj.75.1550631453188; Tue, 19 Feb 2019 18:57:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550631453; cv=none; d=google.com; s=arc-20160816; b=YMmonQNxbBXFdMesrYTPX53M9IhmuXYvBVTOt2K1qFVA7Wjc7iLu9tES5fm+blda+2 JlvU6krHJYar8SweMGrdGagpOghI5V6xD7fg639v0r6wqGgURFFI9sXJ2xxno/dcU6k5 isfBd9dQMrnmNqQyXgAUx/FH8dPvQFZ1txwJv2h90DHpXfM8xIRRBkOrad1guluZcJSl 3tynw5glLohD2N5jnMlgiALTKC9dF79Zp5KAEVjJCR/OSihy2DAtir20j4wdgAKEK5D8 d+caBTz+FnUqvPp/tFo4nOW7oAyXDfUxZugNoTp+EUBy6s1nEvA0Jz5HVB2YkSj2NEXG 5dsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=alXpXQgj8QYP1JZWjy0iq4vBzZZ8EyjAvo++v6vQm3g=; b=TOEDg4ewSZAJylGFZ0TaJiwLGQdp8Ze4Z6J+mjSIakgneUs4JW9fS8zaLnHZ8HgPVr Jxy9gbZVU4p1o//vPxXV7LK6gUQAd/hRHoiLerw9DfeBsyb8UjsE/Q0o4Lfnnzpj/Q3p hXRwUJrlKd1+52xWdz1BQNMH/WOyLowo0A9kSgU4qLb4quaMk/IGDanFZ+tzEmZloz5T UVnUuEO6vtXKw8QtcxVMgfWL3H3kuZWXI5AeHbkmwf78meaqzv05PtGzpMj1umJ1ra0G L8iHtXvrPLqyQkqKFvnL4I1FVuEqVWqRpzUo6+SltSAOkJbmUWpBhkWzOVxu2HnWzLsW IIvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c11si3682307pfn.233.2019.02.19.18.57.17; Tue, 19 Feb 2019 18:57:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730542AbfBTCzK (ORCPT + 99 others); Tue, 19 Feb 2019 21:55:10 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:3700 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730154AbfBTCzJ (ORCPT ); Tue, 19 Feb 2019 21:55:09 -0500 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 56FBFFAD96B3C80A09C7; Wed, 20 Feb 2019 10:55:07 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.408.0; Wed, 20 Feb 2019 10:54:59 +0800 From: YueHaibing To: Chris Mason , Josef Bacik , David Sterba CC: YueHaibing , , , Subject: [PATCH -next] btrfs: Fix type conversion in btrfs_read_root_item Date: Wed, 20 Feb 2019 03:08:40 +0000 Message-ID: <20190220030840.188854-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org btrfs_item_size_nr return value is u32, convert it to int may result in truncation.Also read_extent_buffer expect a unsigned param, so min_t should use type u32 to compare. Fixes: 8ea05e3a4262 ("Btrfs: introduce subvol uuids and times") Signed-off-by: YueHaibing --- fs/btrfs/root-tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c index 02d1a57af78b..893d12fbfda0 100644 --- a/fs/btrfs/root-tree.c +++ b/fs/btrfs/root-tree.c @@ -21,12 +21,12 @@ static void btrfs_read_root_item(struct extent_buffer *eb, int slot, struct btrfs_root_item *item) { uuid_le uuid; - int len; + u32 len; int need_reset = 0; len = btrfs_item_size_nr(eb, slot); read_extent_buffer(eb, item, btrfs_item_ptr_offset(eb, slot), - min_t(int, len, (int)sizeof(*item))); + min_t(u32, len, sizeof(*item))); if (len < sizeof(*item)) need_reset = 1; if (!need_reset && btrfs_root_generation(item)