lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 1 Apr 2023 09:00:59 +0800
From:   Chao Yu <chao@...nel.org>
To:     Bo Ye <bo.ye@...iatek.com>, Jaegeuk Kim <jaegeuk@...nel.org>,
        Matthias Brugger <matthias.bgg@...il.com>,
        AngeloGioacchino Del Regno 
        <angelogioacchino.delregno@...labora.com>,
        xiongping1 <xiongping1@...omi.com>,
        qixiaoyu1 <qixiaoyu1@...omi.com>
Cc:     yongdong.zhang@...iatek.com, peng.zhou@...iatek.com,
        browse.zhang@...iatek.com, light.hsieh@...iatek.com,
        Qilin Tan <qilin.tan@...iatek.com>,
        linux-f2fs-devel@...ts.sourceforge.net,
        linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-mediatek@...ts.infradead.org
Subject: Re: [PATCH 2/2] f2fs: add __pack attribute for extent_info

On 2023/3/31 17:26, Bo Ye wrote:
> From: Qilin Tan <qilin.tan@...iatek.com>
> 
> Need add __pack for struct extent_info to align to memory
> layout of struct rb_entry.

Jaegeuk has fixed this bug w/ below patchset, please check it:

https://lore.kernel.org/linux-f2fs-devel/20230313201216.924234-1-jaegeuk@kernel.org/

Thanks,

> 
> struct rb_entry {
>      struct rb_node rb_node;     /* rb node located in rb-tree */
>      union {
>          struct {
>              unsigned int ofs;   /* start offset of the entry */
>              unsigned int len;   /* length of the entry */
>          };
>          unsigned long long key;     /* 64-bits key */
>      } __packed;
> };
> 
> struct extent_info {
>      unsigned int fofs;      /* start offset in a file */
>      unsigned int len;       /* length of the extent */
>      union {
>          ...
>          /* block age extent_cache */
>          struct {
>              /* block age of the extent */
>              unsigned long long age;
>              /* last total blocks allocated */
>              unsigned long long last_blocks;
>          };
> };
> 
> The new fields(age, last_blocks) are u64 in change 71644dff4811, it
> cause the memory alignment based on 8 bytes in some complier. So the
> field fofs and len are alloced with 8 bytes and using the last 4 byts.
> Its memory is not aligned with struct rb_entry. the ofs of rb_entry
> pointer to a invalid value and cause writing file failed.
> 
> struct extent_info's offset should be 12 rather than 16 from the
> beginning of struct rb_entry.
> 
> The offset dump for the bad case as:
> kworker/u16:6: [name:f2fs&]f2fs_lookup_rb_tree_for_insert:MTK_DEBUG: ino=1629 re=0xc675dc08 ofs=0 re->ofs=0, re->len=68 ei=0xc675dc18 ei.fofs=68 ei.len=277
> 
> Fixes: 71644dff4811 ("f2fs: add block_age-based extent cache")
> Signed-off-by: Bo Ye <bo.ye@...iatek.com>
> Signed-off-by: Qilin Tan <qilin.tan@...iatek.com>
> ---
>   fs/f2fs/f2fs.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index b0ab2062038a..7c690667a42f 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -660,7 +660,7 @@ struct extent_info {
>   			unsigned long long last_blocks;
>   		};
>   	};
> -};
> +} __packed;
>   
>   struct extent_node {
>   	struct rb_node rb_node;		/* rb node located in rb-tree */

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ