From patchwork Fri Apr 24 07:22:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ritesh Harjani X-Patchwork-Id: 1276214 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 497lxQ2dS3z9sRf for ; Fri, 24 Apr 2020 17:22:34 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726588AbgDXHWd (ORCPT ); Fri, 24 Apr 2020 03:22:33 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55610 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725898AbgDXHWd (ORCPT ); Fri, 24 Apr 2020 03:22:33 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03O72r3e193452 for ; Fri, 24 Apr 2020 03:22:32 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 30k7rmwax1-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 24 Apr 2020 03:22:32 -0400 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 24 Apr 2020 08:21:52 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 24 Apr 2020 08:21:48 +0100 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 03O7MPFb65536252 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Apr 2020 07:22:25 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0FF16A405B; Fri, 24 Apr 2020 07:22:25 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 08FF0A4060; Fri, 24 Apr 2020 07:22:23 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.79.185.245]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 24 Apr 2020 07:22:22 +0000 (GMT) From: Ritesh Harjani To: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org Cc: Alexander Viro , "Darrick J . Wong" , Christoph Hellwig , Jan Kara , tytso@mit.edu, "Aneesh Kumar K . V" , linux-ext4@vger.kernel.org, Ritesh Harjani Subject: [PATCH 0/2] WARN fibmap user in case of possible addr truncation Date: Fri, 24 Apr 2020 12:52:16 +0530 X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 20042407-0008-0000-0000-000003766B79 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20042407-0009-0000-0000-00004A983B1D Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-24_02:2020-04-23,2020-04-24 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 mlxlogscore=527 adultscore=0 bulkscore=0 impostorscore=0 malwarescore=0 suspectscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004240048 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Currently an ioctl_fibmap() caller may get a truncated and wrong block map address if the actual mapped physical block address is > INT_MAX. If that is the case then lets:- 1. Add a warning, 2. Returns 0 in the block mapped address, 3. And also return -ERANGE error. This is better than providing a wrong information to the user about the block mapping which in the worst case could cause a FS corruption (unknowingly by the caller since kernel didn't warn). Currently these checks are in place only for the filesystems who uses iomap based bmap interface. So let's do this right thing for all the fibmap() callers by adding this logic in ioctl_fibmap() directly. Patch-1 & Patch-2 commit msg may provide additional information. Ritesh Harjani (2): fibmap: Warn and return an error in case of block > INT_MAX iomap: bmap: Remove the WARN and return the proper block address fs/ioctl.c | 5 +++++ fs/iomap/fiemap.c | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-)