From patchwork Thu Feb 27 13:36:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 230159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DB49C11D3D for ; Thu, 27 Feb 2020 14:43:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 07E2A24691 for ; Thu, 27 Feb 2020 14:43:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582814614; bh=RQoQ8frxlbI1QjilHnH3/LmzPQ60HcJMzxc+C18UY60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ncnOPiIRiP+lsnMq2PqXv0ns8YtkNUmMKAKtyT7T2/1Rcb/qgV/ux8UssslmCIe/2 55i+pLGZqsqJ6Fh0RF96JAqgl4s71ApjDmikY/dlYf5R87w9DjkKTgvwxLPMaBByza Eac9bg06CiE+mPqXXbJH71GTU9SOsXdeKxQCgGqs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731086AbgB0On2 (ORCPT ); Thu, 27 Feb 2020 09:43:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:47184 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731056AbgB0Ntj (ORCPT ); Thu, 27 Feb 2020 08:49:39 -0500 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 17D3124688; Thu, 27 Feb 2020 13:49:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582811377; bh=RQoQ8frxlbI1QjilHnH3/LmzPQ60HcJMzxc+C18UY60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t5mu2pT86/ErcXMTD4+TkfS0OzIWThrZDlWPXljY3nvaLGuNdyU4CU8CeIgTmE7g4 gMFwlPAiuopH24ZRCgkphp/37RPzVjN0nVklakWTaVX6pUzdDHC3Lv2jgC452ur1fK V0rEBz1wjq7T0DGxkIJZTwDui17UmfVE4hpHyO5A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kbuild test robot , Coly Li , Jens Axboe , Sasha Levin Subject: [PATCH 4.9 109/165] bcache: explicity type cast in bset_bkey_last() Date: Thu, 27 Feb 2020 14:36:23 +0100 Message-Id: <20200227132247.075670600@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227132230.840899170@linuxfoundation.org> References: <20200227132230.840899170@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Coly Li [ Upstream commit 7c02b0055f774ed9afb6e1c7724f33bf148ffdc0 ] In bset.h, macro bset_bkey_last() is defined as, bkey_idx((struct bkey *) (i)->d, (i)->keys) Parameter i can be variable type of data structure, the macro always works once the type of struct i has member 'd' and 'keys'. bset_bkey_last() is also used in macro csum_set() to calculate the checksum of a on-disk data structure. When csum_set() is used to calculate checksum of on-disk bcache super block, the parameter 'i' data type is struct cache_sb_disk. Inside struct cache_sb_disk (also in struct cache_sb) the member keys is __u16 type. But bkey_idx() expects unsigned int (a 32bit width), so there is problem when sending parameters via stack to call bkey_idx(). Sparse tool from Intel 0day kbuild system reports this incompatible problem. bkey_idx() is part of user space API, so the simplest fix is to cast the (i)->keys to unsigned int type in macro bset_bkey_last(). Reported-by: kbuild test robot Signed-off-by: Coly Li Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/md/bcache/bset.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/md/bcache/bset.h b/drivers/md/bcache/bset.h index b935839ab79c6..f483041eed986 100644 --- a/drivers/md/bcache/bset.h +++ b/drivers/md/bcache/bset.h @@ -380,7 +380,8 @@ void bch_btree_keys_stats(struct btree_keys *, struct bset_stats *); /* Bkey utility code */ -#define bset_bkey_last(i) bkey_idx((struct bkey *) (i)->d, (i)->keys) +#define bset_bkey_last(i) bkey_idx((struct bkey *) (i)->d, \ + (unsigned int)(i)->keys) static inline struct bkey *bset_bkey_idx(struct bset *i, unsigned idx) {