Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1671734pxy; Thu, 6 May 2021 12:54:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPa3fAjWJcwsVk2RSHiId0t1JGcuFGg+w5PiTrLqNJMOpoYj8VkhBzFcR+DKO+5TLljODj X-Received: by 2002:a17:90a:5e4a:: with SMTP id u10mr6396412pji.202.1620330884888; Thu, 06 May 2021 12:54:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620330884; cv=none; d=google.com; s=arc-20160816; b=lcUNX6TPrjbfsiDf9VbEpgFJqXaQjpc25S1A4xhfOgR2tV5G1Vn/KpCMUY9To9bBB/ XIMo3BgCB4uEteyz9jPGIUKH2AZWfMq2n0B4h6ZLl3m4cTuJTaUkbyv5/ADrrSEREfMh ZmYiGtsU5Hf/pH8lXLAL50w+lCuJ0izeNXmhXXORE5Es/zMfwFHI21T+Bs2MpS3RscBc gxAFJN/keXdJjHghnWYCIrnf+ymeAdepPbAiiUh+BsMaCDP7V2eTPBzIUYA7dNWUkIl2 zkWg1coF1b6O2P7I7ZQ2l14Cnbazu2fa7w5yAw4iHqb8phh2dLtiE1JMzUbhArvDXk9b gnzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2rVW1ibsoIRZVQIC5VoQ0rlFZy8jqgzdYAHFSRq2LyE=; b=JMtIy04pgg/IXV+dONCF0OmNT1dkWeMYPXX5bflNDjzkzdYEuD0mq/5oQtSLC7T9xE DJELH12bdIPCReH3RFTG8GqAdDWtw0Ux5j80oTy7RGS1qKuqHhSQRiTWsHT56kkbnBTo BYxAEZ1OaFzR4o4SnJV0eaPvKinKqVfu+1LdYZoHXr5UePgyWOijczDPZ//s0kbTI3ic AhvFGnHwBfcQmin/wdTI47vtjqZLmOcG995E8rx/2dvmrQBgK9qqX1TVcmONfR07YxpR 840A30okY+sDDMjKySHKxJBe2E2Ehe1zLOtDZG39rHwBBwdc6m8F+CWoyIBoL0EyDMF4 bI1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="f/KnPdAf"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l5si1525310pfu.220.2021.05.06.12.54.32; Thu, 06 May 2021 12:54:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="f/KnPdAf"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232591AbhEFSot (ORCPT + 99 others); Thu, 6 May 2021 14:44:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31345 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236547AbhEFSo0 (ORCPT ); Thu, 6 May 2021 14:44:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620326607; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2rVW1ibsoIRZVQIC5VoQ0rlFZy8jqgzdYAHFSRq2LyE=; b=f/KnPdAfQyxKCxQb2yhIWQSgvH5iHDVOu0KAMFAhjvyViratDT2rakbDl+w+3wrCyLZPuj UmCmToU0LaDEfqxLgaxXb+2GYCIZCItZ0f5XLINhNMMim9BJfpfIMjQX1WtA2IGQibgpy0 AGA/NowAE7jVdvWZxC1LcGwq2c47jYk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-313-1HwfdGnXNMGgSIe3oqBBqQ-1; Thu, 06 May 2021 14:43:25 -0400 X-MC-Unique: 1HwfdGnXNMGgSIe3oqBBqQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 46BFD80059E; Thu, 6 May 2021 18:43:24 +0000 (UTC) Received: from horse.redhat.com (ovpn-114-166.rdu2.redhat.com [10.10.114.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA7DF5C1A1; Thu, 6 May 2021 18:43:19 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 49B74223D99; Thu, 6 May 2021 14:43:19 -0400 (EDT) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, virtio-fs@redhat.com, miklos@szeredi.hu Cc: vgoyal@redhat.com, dgilbert@redhat.com, linux-kernel@vger.kernel.org, dan.carpenter@oracle.com Subject: [PATCH 1/2] virtiofs, dax: Fix smatch warning about loss of info during shift Date: Thu, 6 May 2021 14:43:03 -0400 Message-Id: <20210506184304.321645-2-vgoyal@redhat.com> In-Reply-To: <20210506184304.321645-1-vgoyal@redhat.com> References: <20210506184304.321645-1-vgoyal@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dan reported a smatch warning during potentential loss of info during left shift if this code is compiled on 32bit systems. New smatch warnings: fs/fuse/dax.c:113 fuse_setup_one_mapping() warn: should 'start_idx << 21' be a +64 bit type? I ran smatch and found two more instances of similar warning. This patch fixes all such instances. Reported-by: Dan Carpenter Signed-off-by: Vivek Goyal --- fs/fuse/dax.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c index ff99ab2a3c43..f06fdad3f7b1 100644 --- a/fs/fuse/dax.c +++ b/fs/fuse/dax.c @@ -186,7 +186,7 @@ static int fuse_setup_one_mapping(struct inode *inode, unsigned long start_idx, struct fuse_conn_dax *fcd = fm->fc->dax; struct fuse_inode *fi = get_fuse_inode(inode); struct fuse_setupmapping_in inarg; - loff_t offset = start_idx << FUSE_DAX_SHIFT; + loff_t offset = (loff_t)start_idx << FUSE_DAX_SHIFT; FUSE_ARGS(args); ssize_t err; @@ -872,7 +872,7 @@ static int dmap_writeback_invalidate(struct inode *inode, struct fuse_dax_mapping *dmap) { int ret; - loff_t start_pos = dmap->itn.start << FUSE_DAX_SHIFT; + loff_t start_pos = (loff_t)dmap->itn.start << FUSE_DAX_SHIFT; loff_t end_pos = (start_pos + FUSE_DAX_SZ - 1); ret = filemap_fdatawrite_range(inode->i_mapping, start_pos, end_pos); @@ -966,7 +966,7 @@ inode_inline_reclaim_one_dmap(struct fuse_conn_dax *fcd, struct inode *inode, dmap = inode_lookup_first_dmap(inode); if (dmap) { start_idx = dmap->itn.start; - dmap_start = start_idx << FUSE_DAX_SHIFT; + dmap_start = (u64)start_idx << FUSE_DAX_SHIFT; dmap_end = dmap_start + FUSE_DAX_SZ - 1; } up_read(&fi->dax->sem); @@ -1118,7 +1118,7 @@ static int lookup_and_reclaim_dmap(struct fuse_conn_dax *fcd, { int ret; struct fuse_inode *fi = get_fuse_inode(inode); - loff_t dmap_start = start_idx << FUSE_DAX_SHIFT; + loff_t dmap_start = (loff_t)start_idx << FUSE_DAX_SHIFT; loff_t dmap_end = (dmap_start + FUSE_DAX_SZ) - 1; down_write(&fi->i_mmap_sem); -- 2.25.4