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>] [day] [month] [year] [list]
Message-ID: <CAFf+5zgU2A4PmOm06Ca654UgLErJbfMTK5XhnR5X2D0Jz2J-SA@mail.gmail.com>
Date: Fri, 31 Jan 2025 13:51:19 +0530
From: Amit <amitchoudhary0523@...il.com>
To: linux-kernel@...r.kernel.org
Subject: Advantages of crashing if someone is freeing NULL pointer.

Hi,

kfree(NULL) doesn't crash. If kfree(NULL) crashes then we can get few
advantages.

Let's say that we do the following:

kfree(x);
x = NULL;

Now, if someone uses 'x' again then it will crash. Also, if someone
does double free of 'x' again then also the kernel will crash. So, we
can solve two problems in one shot.

The side-effect is that the code now will become:

if (x) {
  kfree(x);
  x = NULL;
}

This will introduce a few more instructions, probably 10 instructions
but 10 extra instructions per kfree() should not slow down the kernel.
I don't think we are calling kfree() very frequently.

If people agree with me then I can make the necessary changes and send a patch.

If people here agree with me then I will also try to get free(NULL) to
crash in the C library - I will talk to them and send a patch if they
agree. But first, I wanted to see if people here agree with me or not.

Regards,
Amit

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ