Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp308034ybz; Fri, 24 Apr 2020 00:23:13 -0700 (PDT) X-Google-Smtp-Source: APiQypIHtSqmVXaOg3fYeHMfjS4mRqIHESTD/OD/39xGAXl4AGpxEWPhoKpzdglDiKChUH0IpXaI X-Received: by 2002:a05:6402:a43:: with SMTP id bt3mr5818700edb.157.1587712993351; Fri, 24 Apr 2020 00:23:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587712993; cv=none; d=google.com; s=arc-20160816; b=CvC2A6wVHb+Fg97It9IHXiYAApdpOh11oJfr3apLWY6PXiiaoG5X8UXqAdX+kiDZDQ iZdLRcSU5qAeG94EROqHcJNfUnlDR4Qzg9FFUKwk/5+jYqKFltvOS3jP0bEP1/z5wvOz 04UJdZJffEQylOhgy0wv8jgzvsMBV5UT2QhrxHXMa4xt7kDCjELEeFOoKZ5SR1v/Rapu c4/xjMrUoETWdCKwTWQB8VEJQ98dWu49E5LzSZgBw83UwAm5HgHtDTaMsGSWfxy5nDpF 3kYF16EOQQWe0qF6mebSuoF5Bwz48rLQOgX7E/lW433kKirgiKsH1ZZxcz0xrbU/geVq YZLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:date:subject:cc:to:from; bh=OcOwCTkav6yRnlC+JGMpI0kwM5q1DwiqNAI4/mxx8og=; b=ijW8d5zs/kRjPvDriwWmzdHkd4xa+z5lXnUYMaeBRt/XNXxmIOVmYw8qIDWiIHM4t7 dxANRjve+QNjP7TmXsRSJgcBT59VKax9yoS8KFabhR+g/trg9d4t+2T+zfwlmq2oMXGo h1AA0kIXIQAWg5lOqjN6YjB1kSX8pSP6H6Pk/ameauAdzrXYx4t5KjRxebUgx7BSB9yw JSnwpp87H6J30aFRe4hJky3a1yeplASEDKVagPyLyayarBm8p5BpQ8583MEH+DeyQAt+ a6ZdM86BulKaK7SwgfndCgKtTNcSHV9fFOwMZzkwM0ynNBe9uHXpnSjFUo3L742/RlAT gt0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t14si2521967edi.331.2020.04.24.00.22.42; Fri, 24 Apr 2020 00:23:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726338AbgDXHWd (ORCPT + 99 others); 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 Content-Transfer-Encoding: 8bit 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(-) -- 2.21.0