linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] btrfs: Prevent open-coded arithmetic on kmalloc
@ 2025-09-19 14:58 Miquel Sabaté Solà
  2025-09-19 14:58 ` [PATCH 1/2] btrfs: Prevent open-coded arithmetic in kmalloc Miquel Sabaté Solà
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Miquel Sabaté Solà @ 2025-09-19 14:58 UTC (permalink / raw)
  To: linux-btrfs; +Cc: clm, dsterba, linux-kernel, Miquel Sabaté Solà

Hello,

There were a couple of instances in btrfs code in which kmalloc was being
used with open-coded arithmetic. This can lead into unfortunate overflow
situations as describbed here [1]. The solution is to use kmalloc_array in
these cases, which is what it's being done in my first patch.

The second patch is a small cleanup after fixing up my first patch, in
which I realized that the __free(kfree) attribute would come in handy in a
couple of particularly large functions with multiple exit points. This
second patch is probably more of a cosmetic thing, and it's not an
exhaustive exercise by any means. All of this to say that even if I feel
like it should be included, I don't mind if it has to be dropped.

Cheers,
Miquel

[1] Documentation/process/deprecated.rst

Miquel Sabaté Solà (2):
  btrfs: Prevent open-coded arithmetic in kmalloc
  btrfs: Prefer using the __free cleanup attribute

 fs/btrfs/delayed-inode.c | 18 ++++++++----------
 fs/btrfs/tree-log.c      | 30 +++++++++++-------------------
 2 files changed, 19 insertions(+), 29 deletions(-)

--
2.51.0

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-09-23  8:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-19 14:58 [PATCH 0/2] btrfs: Prevent open-coded arithmetic on kmalloc Miquel Sabaté Solà
2025-09-19 14:58 ` [PATCH 1/2] btrfs: Prevent open-coded arithmetic in kmalloc Miquel Sabaté Solà
2025-09-22 10:28   ` David Sterba
2025-09-22 12:47     ` Miquel Sabaté Solà
2025-09-23  6:13       ` David Sterba
2025-09-23  6:47         ` Miquel Sabaté Solà
2025-09-23  7:00           ` David Sterba
2025-09-23  8:00             ` Miquel Sabaté Solà
2025-09-19 14:58 ` [PATCH 2/2] btrfs: Prefer using the __free cleanup attribute Miquel Sabaté Solà
2025-09-22 10:34 ` [PATCH 0/2] btrfs: Prevent open-coded arithmetic on kmalloc David Sterba
2025-09-22 12:51   ` Miquel Sabaté Solà
2025-09-23  6:11     ` David Sterba
2025-09-23  6:46       ` Miquel Sabaté Solà

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).