Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp242340rdb; Mon, 29 Jan 2024 00:08:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IGh1xOIUi3woeuNQqLmH4JNpOJb7eaH4zsTJjt0YYhJPBvbv5Md0j6cfLxVJLM4S6kUsDg2 X-Received: by 2002:a17:90a:550c:b0:293:9bc3:ed0f with SMTP id b12-20020a17090a550c00b002939bc3ed0fmr1569569pji.30.1706515693970; Mon, 29 Jan 2024 00:08:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706515693; cv=pass; d=google.com; s=arc-20160816; b=ASdx+eZtdF5cB15njDP8sC6AavQ7Ml/FMzMfccVc66hPkpMLdqenugZgzSpkTySwXf jIQow8FQ1XV9kpgxZpaSBJICHKA0vk4nfl1wO4fMaqMuHki48Hwuk1yCRIQTgrDXXJsv NvXX3s+Cma0DWUJfR8xqhIOohrKl29zv+xlO2n5W0jk4q2c14E1pk1fGmzhdFaaar5X1 +Qja4rjZhcxhlUCj7p4NBVTD7ljrPCNpm7PlK7+qWiXvmV9fgFN+ok/ecU5FDM1Og+Hd I5vmyscg94Qxn5rU6CkfVo7dsWkcWtthw/MXJSe3cdO55wuXV7zH5MMqkOdzXmTPED1K D+wQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature :dkim-signature; bh=SelnU1PmjcEBam/XFIeYfnjb/zVT85VEHjJYVt2fRhM=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=TZUH46Vy5m/vxzbWBKu7NZ75202YwzJFG7VldvbARLJ0NSxjn8gdX8YN34Fzvgzm0f w7aXX4fMI+vTYM6DMgjRClYQ95V3MVDwhmifsSvp+NcELSGnbz630OMgyLHRbkXw95Ya IFWeWDQE3Mg5IHqLPsQSwIMJjHgRjVtAuWtepRNdAR1fGnwfKkBb2VWhn537CyiTi885 ZirgcoxlWfjySrrKOElBOPO4tza8G080X3OmL8P5cktcx0ZxrsfjhbrxGgvbPGR4+8cf TJxm4hZ6k+xbVbCuNpCSKTvwukOeCPRM2KsrUzCcrtgjFRcnVswp3jm3yAiV/vc27QwS YnLQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=u6Vv7kMM; dkim=pass header.i=@paragon-software.com header.s=mail header.b=Wtto7Qtd; arc=pass (i=1 spf=pass spfdomain=paragon-software.com dkim=pass dkdomain=paragon-software.com dkim=pass dkdomain=paragon-software.com dmarc=pass fromdomain=paragon-software.com); spf=pass (google.com: domain of linux-kernel+bounces-42326-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42326-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t11-20020a17090ae50b00b00290f050e73dsi5305331pjy.133.2024.01.29.00.08.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 00:08:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42326-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=u6Vv7kMM; dkim=pass header.i=@paragon-software.com header.s=mail header.b=Wtto7Qtd; arc=pass (i=1 spf=pass spfdomain=paragon-software.com dkim=pass dkdomain=paragon-software.com dkim=pass dkdomain=paragon-software.com dmarc=pass fromdomain=paragon-software.com); spf=pass (google.com: domain of linux-kernel+bounces-42326-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42326-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0F690283E95 for ; Mon, 29 Jan 2024 08:07:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0DA3A53801; Mon, 29 Jan 2024 08:07:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="u6Vv7kMM"; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="Wtto7Qtd" Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC22C537E4; Mon, 29 Jan 2024 08:07:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706515654; cv=none; b=Yy5ADQkFG8/J4WvD9QxVJd+bVQt7b85Yi+P9m7kp7c5PSd3zBa9q7GG5YIo+97q7mvf7Dg0s3glQzQ7GJHIQPDY2K/GIYO8Lw60ntxzQ4b7Iarx/I6+nCjtZS8tRJczUrESEXc1IDteDObGNCAOu6589LnUSsbz8IslN4do2Yvk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706515654; c=relaxed/simple; bh=ebmE+3+S0pyuODXXnBFsAaOW8KZdxmR2O/v1cJbjSO4=; h=Message-ID:Date:MIME-Version:Subject:From:To:CC:References: In-Reply-To:Content-Type; b=FWxT1FbR2DkjL75FmaP6cR/1kVVcJrTqCjP8+7N1A+pRvoHlMHsOHEJxTj7NCYA23n6tZeGcbeb3f4XU5PyCliTzO+J5F1GoV7reDCv6SgXegfVnTpjyHrZoqYZ+naW8BkprqphZWgRSyNN0EtiHMzgjjWp1VZuUjRavnWTy2ZM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=u6Vv7kMM; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=Wtto7Qtd; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 7FDD4211A; Mon, 29 Jan 2024 08:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1706515239; bh=SelnU1PmjcEBam/XFIeYfnjb/zVT85VEHjJYVt2fRhM=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=u6Vv7kMMhVrF1vzHeBcbgCVN50yqGtaSjYEW8ON03Jpi9XNbYJTXzaxT3SL7XzqkR 6cVEFcLHJqpCZPwiKlGjpz4nt/DQ35sChxYkSuds3Mglu5URBYpWvpL+eCJTyNUdyU PwK2jkF7UHG1AxfabfmC4+8rZX4YlrHvxS8NDj4A= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id CD4702135; Mon, 29 Jan 2024 08:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1706515649; bh=SelnU1PmjcEBam/XFIeYfnjb/zVT85VEHjJYVt2fRhM=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=Wtto7QtdPRPmS/B/yMBSisnCRJ6+b1ajjrp4oEe6VyxUX0X4ZSj8qrypAZAtWHZj9 lYzyzKoRORuHV0Debb33xTzi+KuDmwW4b2O3si54WDc+C+3enMK+RyZdkLoaGZNKuK ZTtdTn5ydRwrRNARy+ocBiKd+dGUC7ujq+i7Y2SQ= Received: from [192.168.211.199] (192.168.211.199) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Mon, 29 Jan 2024 11:07:29 +0300 Message-ID: <7d42dc06-2f7f-40b4-8d9f-89eebd0a8f06@paragon-software.com> Date: Mon, 29 Jan 2024 11:07:29 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 1/5] fs/ntfs3: Prevent generic message "attempt to access beyond end of device" Content-Language: en-US From: Konstantin Komarov To: CC: , References: In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) It used in test environment. Signed-off-by: Konstantin Komarov ---  fs/ntfs3/fsntfs.c  | 24 ++++++++++++++++++++++++  fs/ntfs3/ntfs_fs.h | 14 +-------------  2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index 321978019407..ae2ef5c11868 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -1007,6 +1007,30 @@ static inline __le32 security_hash(const void *sd, size_t bytes)      return cpu_to_le32(hash);  } +/* + * simple wrapper for sb_bread_unmovable. + */ +struct buffer_head *ntfs_bread(struct super_block *sb, sector_t block) +{ +    struct ntfs_sb_info *sbi = sb->s_fs_info; +    struct buffer_head *bh; + +    if (unlikely(block >= sbi->volume.blocks)) { +        /* prevent generic message "attempt to access beyond end of device" */ +        ntfs_err(sb, "try to read out of volume at offset 0x%llx", +             (u64)block << sb->s_blocksize_bits); +        return NULL; +    } + +    bh = sb_bread_unmovable(sb, block); +    if (bh) +        return bh; + +    ntfs_err(sb, "failed to read volume at offset 0x%llx", +         (u64)block << sb->s_blocksize_bits); +    return NULL; +} +  int ntfs_sb_read(struct super_block *sb, u64 lbo, size_t bytes, void *buffer)  {      struct block_device *bdev = sb->s_bdev; diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 2b54ae94440f..81f7563428ee 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -586,6 +586,7 @@ bool check_index_header(const struct INDEX_HDR *hdr, size_t bytes);  int log_replay(struct ntfs_inode *ni, bool *initialized);  /* Globals from fsntfs.c */ +struct buffer_head *ntfs_bread(struct super_block *sb, sector_t block);  bool ntfs_fix_pre_write(struct NTFS_RECORD_HEADER *rhdr, size_t bytes);  int ntfs_fix_post_read(struct NTFS_RECORD_HEADER *rhdr, size_t bytes,                 bool simple); @@ -1032,19 +1033,6 @@ static inline u64 bytes_to_block(const struct super_block *sb, u64 size)      return (size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;  } -static inline struct buffer_head *ntfs_bread(struct super_block *sb, -                         sector_t block) -{ -    struct buffer_head *bh = sb_bread_unmovable(sb, block); - -    if (bh) -        return bh; - -    ntfs_err(sb, "failed to read volume at offset 0x%llx", -         (u64)block << sb->s_blocksize_bits); -    return NULL; -} -  static inline struct ntfs_inode *ntfs_i(struct inode *inode)  {      return container_of(inode, struct ntfs_inode, vfs_inode); -- 2.34.1