Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp208920imp; Tue, 19 Feb 2019 21:59:59 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibo25HP0XBuvcguTrei9qzKjPCdIS9aEJSKGfukzppspnmn4VfXVTt+jN2AHBb68uB7TjDg X-Received: by 2002:a62:46db:: with SMTP id o88mr33297505pfi.248.1550642399137; Tue, 19 Feb 2019 21:59:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550642399; cv=none; d=google.com; s=arc-20160816; b=nffAvdctRj79BaS9ohOJBHWV/Rl/VgrGU/EsRv7SrdtxVEP8LuiEDuiIUTcVcf1++E If6Sq4VVoDyR7GrlN5oOB+ZKIzj9r4UDNz8D6w042iz03n0Rcwxt6oDAWptaOmvtpPc+ qe7GKZXPz5StQhqhnbkoaDtO+NMAd2NwsX9qgROyDkHzOj1pyKAIeMJvB8o+N7fd0zDf Hdf9Zo4BfgfUMV0sIhURRMs9QAg+9SG0n/WcX9hGqiZLCaBwW0UGmOyaU/V854YZHfMF 8/3R7TtBUjQBy/iYRJaesnkVlIzAghE3kUi7SWl5g8xk1TpzTQ/38D7nxGNpl33yb2P6 fLbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=tBTbh1I7Q6ylkvAv/4yzta1F99KS0lfuIFkAnPJhw44=; b=rUaEQhUj0P9Kn7C8DplgIrNwdCcNS5TqVJpzz6eCxoFUYT9DOKplwnP8GWJmE+4lss T4ZexcWArjeuTmHeffsQAtFVEyj+Dz35QmHExpnvFqZsmVWGgmK9XL7R8RuMxTVG5ENH eH69/UczvLR8g/vseaFnT4y0h0ujuNAgNfsfjbZGLaBTXZXL69iL4oDnVa0eLnZG/Hv7 2QocY2oC0qtTKBsPTfSWOj8CoSm5rwNsbQ0nLDnoN0UIUlRWbrPoTDXnLBN0m+wF3pFZ GNqA01To+8RzJP/0anb4s5N/1KArrN9xdGvQMxrDtD+o5kAu23LRKqLsjDeOkJpzEC8l Dx+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=AxmdwJZj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q189si17166885pgq.9.2019.02.19.21.59.43; Tue, 19 Feb 2019 21:59:59 -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; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=AxmdwJZj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726945AbfBTF7W (ORCPT + 99 others); Wed, 20 Feb 2019 00:59:22 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:57486 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726297AbfBTF7W (ORCPT ); Wed, 20 Feb 2019 00:59:22 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x1K5sIaC129828; Wed, 20 Feb 2019 05:59:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2018-07-02; bh=tBTbh1I7Q6ylkvAv/4yzta1F99KS0lfuIFkAnPJhw44=; b=AxmdwJZjD7KZfifcgKdOnIzYA9AFZKqMOPO5lwC7gZA25IDTUhMxEGM8rCpkCKsYGrAN m+JAOhQMIr7o+GSk/ZAgM0emXtxmxp8a1INIy+Vv/MIzEfds258i07DLRu44i3SDfo9U 9vMoQcAHMSeLJdOBhybpm+eLeSHlon33RWZmwa99Xfda2jyXJEwV5l1AGI5KWZC0+KW5 vtURs5mK0nM63L/4h5K99GKGx+3UXO1fX2E6XIMbnVPMNMz+14vb1RSoiYlNsAAYZzEB Z6L4AzrQW7o3nGr7uZFB8KwGE1SVSXUX+fMOf15Qx2AFMBFqdbmvMahlU7t+CDBQxPrr mw== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2qp81e7jxt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Feb 2019 05:59:10 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x1K5x5Qh018623 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Feb 2019 05:59:05 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x1K5x3jd026136; Wed, 20 Feb 2019 05:59:04 GMT Received: from kadam (/197.157.0.53) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 19 Feb 2019 21:59:03 -0800 Date: Wed, 20 Feb 2019 08:58:43 +0300 From: Dan Carpenter To: YueHaibing Cc: Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH -next] btrfs: Fix type conversion in btrfs_read_root_item Message-ID: <20190220055621.GM17104@kadam> References: <20190220030840.188854-1-yuehaibing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190220030840.188854-1-yuehaibing@huawei.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9172 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902200042 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 20, 2019 at 03:08:40AM +0000, YueHaibing wrote: > 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))); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Yeah, min_t() should normally cast to unsigned and the extra cast is silly. > + min_t(u32, len, sizeof(*item))); regards, dan carpenter