Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp235236ybg; Thu, 17 Oct 2019 22:06:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3D2UolAgwJMNSsbRTZPeNaC/DT08iMuTO3qWH9e3Jqm208s5GhpnVFqCZLKmMY8rbqF5w X-Received: by 2002:a17:906:154a:: with SMTP id c10mr6716342ejd.238.1571375200779; Thu, 17 Oct 2019 22:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571375200; cv=none; d=google.com; s=arc-20160816; b=OUUlmwTQlkzsUhT10YkpamXZMve8/FK2z7If0gnCVRTH22OR04h8mqPIR8U1lXYUGc H2fyuj34/wOhCm3CBP5KH4wSm8+2bQuax+NYMHk09aeI0FmBqJmplfUGuomkWvtiXWKK pMU1oA6RmY+vSk7dE5l8Pq0b7V3+7Rx3h58vK6pCFa6PIdX2UvxJVhBfRX8EnnNMH6Ok /mptNPv1sRlOxn1Pszt2noA/6t2bGpyBVKbMvXj3jV5bGYh0W145TPed8yXSj6ih8eQq K7fNs1WgKEy1rylC4Z8dLktb81zZLrPYwLaUTFaTR5MUmCZf8ec7UZELSFtD2Slnf7QL BkoQ== 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=d7DSe1rI//78VBhuavIl5WrYTfo6uxx+v7slxv530Kg=; b=xPqGf6AwgACXwusyxumT3o987Sh4tdfygZB+CPvBukJhMUl25p2wnMzthhlwdfO9ts nX/Zl3zE/qqq6qcWMBh3qgxOXGylPZNZUy5LQL7yNRPFXWdVW7/7PAR27ARpnmFFAVA2 YEdXc3Mc7JoY+Pb0WziZO3oIXkwXN8Hueon37wgQeLr79EKqxBlwlQRQU2JIP1YmZ8i5 bgyBO9XKLSuRDrI5ZkOGziHtw0vAq70bfoDw3eUO6y7PBVWNjPkmebEiRUNQn/q1PzDC 6xnnnzMhYzWEH8Davp2kP9tLQWcpy2IWKYQt4zpNcymIm9FD6P5+04wEhPcXcPL6YuLQ TysQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OtZWNwtb; 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 c14si3573685eda.8.2019.10.17.22.06.17; Thu, 17 Oct 2019 22:06:40 -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=OtZWNwtb; 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 S2394094AbfJPWTK (ORCPT + 99 others); Wed, 16 Oct 2019 18:19:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:43904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389739AbfJPVyN (ORCPT ); Wed, 16 Oct 2019 17:54:13 -0400 Received: from localhost (unknown [192.55.54.58]) (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 9F60220872; Wed, 16 Oct 2019 21:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571262852; bh=oSBMJg9jxiX29dS/4Zk49nDXcKWbTqNiDD2KtX8PJe4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OtZWNwtb6SYvq6AeF2FiFMmXt1q3tdZ9WH0YvDegMGjV1zVNYIsKXT/AsrqmYXxGm rnZpxNfQ/VoNOSSHHg6Q1C0NDK0OADw8y8OxVD/uWxivBtbD5CMFeJjnEKUmjtF1oB FGQXyLrcnxYoIqzzwkM5nMyVMQlWmK7FBeUtGCq8= 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.9 19/92] ceph: fix directories inode i_blkbits initialization Date: Wed, 16 Oct 2019 14:49:52 -0700 Message-Id: <20191016214815.696498042@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214759.600329427@linuxfoundation.org> References: <20191016214759.600329427@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 339fdf6355df7..7fcddaaca8a5d 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -800,7 +800,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