commit:     7e90bb7885c15f9b071072648ab3d24e829bc95d
Author:     Arisu Tachibana <alicef <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 28 11:48:52 2025 +0000
Commit:     Arisu Tachibana <alicef <AT> gentoo <DOT> org>
CommitDate: Thu Aug 28 11:48:52 2025 +0000
URL:        https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=7e90bb78

Add fs_prevent_file_descriptor_table_allocation

Signed-off-by: Arisu Tachibana <alicef <AT> gentoo.org>

 0000_README                                        |  4 +++
 ..._prevent_file_descriptor_table_allocation.patch | 30 ++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/0000_README b/0000_README
index 55894e22..806e7f6a 100644
--- a/0000_README
+++ b/0000_README
@@ -223,6 +223,10 @@ Patch:  
1510_fs-enable-link-security-restrictions-by-default.patch
 From:   
http://sources.debian.net/src/linux/3.16.7-ckt4-3/debian/patches/debian/fs-enable-link-security-restrictions-by-default.patch/
 Desc:   Enable link security restrictions by default.
 
+Patch:  1520_revert_fs_prevent_file_descriptor_table_allocation.patch
+From:   https://bugs.gentoo.org/961922
+Desc:   revert prevent file descriptor table allocation, possible causing 
crashes
+
 Patch:  1700_sparc-address-warray-bound-warnings.patch
 From:   https://github.com/KSPP/linux/issues/109
 Desc:   Address -Warray-bounds warnings 

diff --git a/1520_revert_fs_prevent_file_descriptor_table_allocation.patch 
b/1520_revert_fs_prevent_file_descriptor_table_allocation.patch
new file mode 100644
index 00000000..aef6add0
--- /dev/null
+++ b/1520_revert_fs_prevent_file_descriptor_table_allocation.patch
@@ -0,0 +1,30 @@
+---
+ fs/file.c | 15 ---------------
+ 1 file changed, 15 deletions(-)
+
+diff --git a/fs/file.c b/fs/file.c
+index 4579c3296498..b6fb6d18ac3b 100644
+--- a/fs/file.c
++++ b/fs/file.c
+@@ -126,21 +126,6 @@ static struct fdtable * alloc_fdtable(unsigned int nr)
+       if (unlikely(nr > sysctl_nr_open))
+               nr = ((sysctl_nr_open - 1) | (BITS_PER_LONG - 1)) + 1;
+ 
+-      /*
+-       * Check if the allocation size would exceed INT_MAX. kvmalloc_array()
+-       * and kvmalloc() will warn if the allocation size is greater than
+-       * INT_MAX, as filp_cachep objects are not __GFP_NOWARN.
+-       *
+-       * This can happen when sysctl_nr_open is set to a very high value and
+-       * a process tries to use a file descriptor near that limit. For 
example,
+-       * if sysctl_nr_open is set to 1073741816 (0x3ffffff8) - which is what
+-       * systemd typically sets it to - then trying to use a file descriptor
+-       * close to that value will require allocating a file descriptor table
+-       * that exceeds 8GB in size.
+-       */
+-      if (unlikely(nr > INT_MAX / sizeof(struct file *)))
+-              return ERR_PTR(-EMFILE);
+-
+       fdt = kmalloc(sizeof(struct fdtable), GFP_KERNEL_ACCOUNT);
+       if (!fdt)
+               goto out;

Reply via email to