Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2082561ybp; Thu, 10 Oct 2019 01:53:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6xBqWne9aJL9tAkIXgAxTwJRgd890/3SSf/+hzU06EigNbx6+21CTU/oR42mQaUfdUe/1 X-Received: by 2002:a17:906:8608:: with SMTP id o8mr7099232ejx.179.1570697584085; Thu, 10 Oct 2019 01:53:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570697584; cv=none; d=google.com; s=arc-20160816; b=qjg7inPJCW+oJq3KDkLH1hG7GQHICq5+ps27jQWXpxfHkBBvDTByoVlBQCmQS8ravL 8xDfWeJ2eXa7yReli+Va/W1hRqJllco9CLE/86ygPwAboIrjPC6pn789abBF4PgnaLn/ DEEdSKh37OctlG0Q/fmAc9y/a34/2x6LSxVH4gAfHyWH1DfTBZ3RYa9O8iKLDcjILN3v vBg7+K2kpBQrLp14/5xQyhLlKmWY8Zm1QVPVWwsH+w6FFrIFc2Tl6tFOgnOx6WPOgImK m80GQUXVpUgthPynJu+WY2aqnigGXl/ktG0Raz4PirJRK+M6xMnIwraeqPkDWacMqdaz FJ9w== 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=zCHPY2LN5t9q7z1IwFe8k3+bHvoyMD8aph7+v3I6x9Q=; b=tykB3rHxHSsGNblhTl2W3ITeeQlFhPfATJSmhnIUBsh3/m3BvChP39C1AZHT7hisn/ FV6YAQUxv8Lutr35ThGirTJzIy92DQL5NLQyFaTQDNnGw0Dzq0LczLbPSC8uBA+YX8QJ puYLJ88LoEA/VJJVQaKr1UVbmbfF9ETenuLqMKjukSapHOdLf7EMNtqqqHsIXUqxrHAO WoqykF4xt7ZIqCeEGnkfh3d3nALGoBUZzds36ED+2gED3CLp/ukDH+d7IKKE9kULAtnH vioQly+0fBpROISK/R5iNsVFbTMXSg9fSEE+y5w6Tocs++mO93rY/4hCukDBhSCKpiMH kRwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VMq+9aIg; 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 p2si2566622edx.106.2019.10.10.01.52.40; Thu, 10 Oct 2019 01:53:04 -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=VMq+9aIg; 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 S2390281AbfJJIwg (ORCPT + 99 others); Thu, 10 Oct 2019 04:52:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:60400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389156AbfJJIwa (ORCPT ); Thu, 10 Oct 2019 04:52:30 -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 CCE8A21A4C; Thu, 10 Oct 2019 08:52:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570697550; bh=iYquV7rnSBLN4fz1yz+JjspIOWP43YtxMzKycPphq00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VMq+9aIgOOMc2EtFpariFvVtQViDKJyZ2KF3fluNvwluMDlKT0jg+xusKAeX17EBg q8CLE9CbZflfh2hYlhfXCoYEY7ApTEXg0AcNn4w2bnwh8Nq4/N6fl39A7PN0Sz04FU NisKWZj0wslBbmZz4fU5fUWLu9JKbdCMq4on9/bY= 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 4.14 32/61] ceph: fix directories inode i_blkbits initialization Date: Thu, 10 Oct 2019 10:36:57 +0200 Message-Id: <20191010083509.551622651@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083449.500442342@linuxfoundation.org> References: <20191010083449.500442342@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 9bda8c7a80a05..879bc08250931 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -789,7 +789,12 @@ static int fill_inode(struct inode *inode, struct page *locked_page, ci->i_version = le64_to_cpu(info->version); inode->i_version++; 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; if ((new_version || (new_issued & CEPH_CAP_AUTH_SHARED)) && (issued & CEPH_CAP_AUTH_EXCL) == 0) { -- 2.20.1