Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2074856ybp; Thu, 10 Oct 2019 01:43:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgtFt4c4N/0cxUXZw6O4J4a4d8dQYWjJYFhvTOnpPRbul3VD34bNwpkWPB3eD6ccpoUvzE X-Received: by 2002:a17:906:27c5:: with SMTP id k5mr6843672ejc.173.1570697037470; Thu, 10 Oct 2019 01:43:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570697037; cv=none; d=google.com; s=arc-20160816; b=qQZpSLShtHCiq8lKAlYLs2UwoyDvg9B1GjPAF1YH+yjdOHKnW0xU0r9zpJLBtIDst/ 1ovFUkubUGDA4qzIYw/dP00LiunNBz3qGxgZbvWNYM8BRu05LWsSJdXrrUUrF3S6hNs3 dM15MKWFdVT4EvzNJm95MxsJRsfPSgDNpPVQGFx7GwD9aLjCeZxXX53wrbRusnVsj9n2 uP/OEc4Cp1P0LYJWQUyjM5LQs99oEmBAAYRKGGjOB1ctPqlWIkWN2cZvc7I6X1hoGOoR cEpeOvvcy26XaV2op1CTQUlbEitV+nrE1EhO/yMIkFOAd26CMIem48DZ601yuDvZkMp2 SMUA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uY7b2wpBCCEVetdjwKKKz7edLhzMSil95RbVR+nOWxk=; b=mZs2+EwcP5n/+FsXQBYro9Gc1bBD7usMmVci/j2kHz/VSSZwLpbGyhOMdWJ2dk1MR7 aY1X/aDF3M+cx4iOQATJNssJM7Fdpj3JwS77aT/KcwYLViZpwVhrIHL1DaLQVk6OpJ9a ToO5r2SM2C+w+fgW5BSpNlhwZA93vkE2Y2Z9wZjv+cYCmud9HphCQl7RvuWN8Tc4xquF DJhNb2Hv9oSKMM2owlffMGJegSJvmq8YhwIZlKBgEpWY3tgw+n1cue2YM2GmsAlX8DEU DnXi++CxqU8v3Kc7ucy5OAhmGa+hwIc/YUzYaI9LixtTL1iEyZQDTcHblu9sZhQJ5hq8 wTlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MVKa4tWZ; 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 ck7si2745512ejb.250.2019.10.10.01.43.34; Thu, 10 Oct 2019 01:43:57 -0700 (PDT) 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=@kernel.org header.s=default header.b=MVKa4tWZ; 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 S2388420AbfJJIlx (ORCPT + 99 others); Thu, 10 Oct 2019 04:41:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:46356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388414AbfJJIlt (ORCPT ); Thu, 10 Oct 2019 04:41:49 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E061021BE5; Thu, 10 Oct 2019 08:41:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570696909; bh=au7RXpazVKg8aDvc0+r3dLxy0AhQ6+CZk+Ol5BMAo6c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MVKa4tWZPmZ4xfXKZDmkyXI+eizSyCeByXgVeMmo11Ma+SUOmgrAf+4DHPwYHHaXg RXTuKZDN+EiU65yzqaZrwAJar+btKyJw1Ld0shahTA6C9DyPdXBDLG4fO2SEpIhvEK Tt8DGIcXZQAgWYGvVByF0ZqjuyRHYQOIv3VK+AP0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Luis Henriques , Jeff Layton , Ilya Dryomov , Sasha Levin Subject: [PATCH 5.3 098/148] ceph: fix directories inode i_blkbits initialization Date: Thu, 10 Oct 2019 10:35:59 +0200 Message-Id: <20191010083617.195609047@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083609.660878383@linuxfoundation.org> References: <20191010083609.660878383@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luis Henriques [ Upstream commit 750670341a24cb714e624e0fd7da30900ad93752 ] When filling an inode with info from the MDS, i_blkbits is being initialized using fl_stripe_unit, which contains the stripe unit in bytes. Unfortunately, this doesn't make sense for directories as they have fl_stripe_unit set to '0'. This means that i_blkbits will be set to 0xff, causing an UBSAN undefined behaviour in i_blocksize(): UBSAN: Undefined behaviour in ./include/linux/fs.h:731:12 shift exponent 255 is too large for 32-bit type 'int' Fix this by initializing i_blkbits to CEPH_BLOCK_SHIFT if fl_stripe_unit is zero. Signed-off-by: Luis Henriques Reviewed-by: Jeff Layton Signed-off-by: Ilya Dryomov Signed-off-by: Sasha Levin --- fs/ceph/inode.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 18500edefc56f..3b537e7038c7a 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -801,7 +801,12 @@ static int fill_inode(struct inode *inode, struct page *locked_page, /* update inode */ inode->i_rdev = le32_to_cpu(info->rdev); - inode->i_blkbits = fls(le32_to_cpu(info->layout.fl_stripe_unit)) - 1; + /* directories have fl_stripe_unit set to zero */ + if (le32_to_cpu(info->layout.fl_stripe_unit)) + inode->i_blkbits = + fls(le32_to_cpu(info->layout.fl_stripe_unit)) - 1; + else + inode->i_blkbits = CEPH_BLOCK_SHIFT; __ceph_update_quota(ci, iinfo->max_bytes, iinfo->max_files); -- 2.20.1