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] [day] [month] [year] [list]
Date: Mon, 18 Dec 2023 20:31:38 -0500
From: Kent Overstreet <kent.overstreet@...ux.dev>
To: "Gustavo A. R. Silva" <gustavoars@...nel.org>
Cc: Brian Foster <bfoster@...hat.com>, linux-bcachefs@...r.kernel.org,
	linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH][next] bcachefs: Replace zero-length array with
 flex-array member and use __counted_by

On Mon, Dec 18, 2023 at 06:24:53PM -0600, Gustavo A. R. Silva wrote:
> Fake flexible arrays (zero-length and one-element arrays) are
> deprecated, and should be replaced by flexible-array members.
> So, replace zero-length array with a flexible-array member in
> `struct bch_ioctl_fsck_offline`.
> 
> Also annotate array `devs` with `__counted_by()` to prepare for the
> coming implementation by GCC and Clang of the `__counted_by` attribute.
> Flexible array members annotated with `__counted_by` can have their
> accesses bounds-checked at run-time via `CONFIG_UBSAN_BOUNDS` (for
> array indexing) and `CONFIG_FORTIFY_SOURCE` (for strcpy/memcpy-family
> functions).
> 
> This fixes the following -Warray-bounds warnings:
> fs/bcachefs/chardev.c: In function 'bch2_ioctl_fsck_offline':
> fs/bcachefs/chardev.c:363:34: warning: array subscript 0 is outside array bounds of '__u64[0]' {aka 'long long unsigned int[]'} [-Warray-bounds=]
>   363 |         if (copy_from_user(devs, &user_arg->devs[0], sizeof(user_arg->devs[0]) * arg.nr_devs)) {
>       |                                  ^~~~~~~~~~~~~~~~~~
> In file included from fs/bcachefs/chardev.c:5:
> fs/bcachefs/bcachefs_ioctl.h:400:33: note: while referencing 'devs'
>   400 |         __u64                   devs[0];
> 
> This results in no differences in binary output.
> 
> Signed-off-by: Gustavo A. R. Silva <gustavoars@...nel.org>

Applied

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ