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]
Message-ID: <Y78AO7WX5Q6Zju3p@sol.localdomain>
Date:   Wed, 11 Jan 2023 10:30:19 -0800
From:   Eric Biggers <ebiggers@...nel.org>
To:     Jan Kara <jack@...e.cz>
Cc:     linux-ext4@...r.kernel.org, Ye Bin <yebin10@...wei.com>
Subject: Re: [PATCH] ext4: use ext4_fc_tl_mem in fast-commit replay path

On Wed, Jan 11, 2023 at 03:43:27PM +0100, Jan Kara wrote:
> On Fri 16-12-22 21:02:12, Eric Biggers wrote:
> > From: Eric Biggers <ebiggers@...gle.com>
> > 
> > To avoid 'sparse' warnings about missing endianness conversions, don't
> > store native endianness values into struct ext4_fc_tl.  Instead, use a
> > separate struct type, ext4_fc_tl_mem.
> > 
> > Fixes: dcc5827484d6 ("ext4: factor out ext4_fc_get_tl()")
> > Cc: Ye Bin <yebin10@...wei.com>
> > Signed-off-by: Eric Biggers <ebiggers@...gle.com>
> 
> Looks good to me. Just one nit below:
> 
> > -static inline void ext4_fc_get_tl(struct ext4_fc_tl *tl, u8 *val)
> > +static inline void ext4_fc_get_tl(struct ext4_fc_tl_mem *tl, u8 *val)
> >  {
> > -	memcpy(tl, val, EXT4_FC_TAG_BASE_LEN);
> > -	tl->fc_len = le16_to_cpu(tl->fc_len);
> > -	tl->fc_tag = le16_to_cpu(tl->fc_tag);
> > +	struct ext4_fc_tl tl_disk;
> > +
> > +	memcpy(&tl_disk, val, EXT4_FC_TAG_BASE_LEN);
> > +	tl->fc_len = le16_to_cpu(tl_disk.fc_len);
> > +	tl->fc_tag = le16_to_cpu(tl_disk.fc_tag);
> >  }
> 
> So why not just:
> 
> 	struct ext4_fc_tl *tl_disk = (struct ext4_fc_tl *)val;
> 
> instead of memcpy?

That would result in unaligned memory accesses.

- Eric

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ