Skip to contentSkip to conversation

fs: fix close_on_exec pointer in alloc_fdtable

PATCH In review Bobby Powers 3 participants 5 messages Feb 22, 2012 – Feb 24, 2012 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: fix close_on_exec pointer in alloc_fdtable

alloc_fdtable allocates space for the open_fds and close_on_exec bitfields together, as 2 * nr / BITS_PER_BYTE. close_on_exec needs to point to open_fds + nr / BITS_PER_BYTE, not open_fds + nr / BITS_PER_LONG, as introducted in 1fd36adc: Replace the fd_sets in struct fdtable with an array of unsigned longs.

---
 fs/file.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/file.c +1 -1
index 2d479dd..171f6b4 100644
@@ -179,7 +179,7 @@ static struct fdtable * alloc_fdtable(unsigned int nr)
 	if (!data)
 		goto out_arr;
 	fdt->open_fds = data;
-	data += nr / BITS_PER_LONG;
+	data += nr / BITS_PER_BYTE;
 	fdt->close_on_exec = data;
 	fdt->next = NULL;
 
Signature · 1 line
1.7.7.6
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Bobby Powers

alloc_fdtable allocates space for the open_fds and close_on_exec bitfields together, as 2 * nr / BITS_PER_BYTE. close_on_exec needs to point to open_fds + nr / BITS_PER_BYTE, not open_fds + nr / BITS_PER_LONG, as introducted in 1fd36adc: Replace the fd_sets in struct fdtable with an array of unsigned longs.

Yes, you're right. At one point I changed data to be an unsigned long *.

#2 lore raw
Quoted 8 lines · David Howells
Quoted 6 lines · Bobby Powers

alloc_fdtable allocates space for the open_fds and close_on_exec bitfields together, as 2 * nr / BITS_PER_BYTE.  close_on_exec needs to point to open_fds + nr / BITS_PER_BYTE, not open_fds + nr / BITS_PER_LONG, as introducted in 1fd36adc: Replace the fd_sets in struct fdtable with an array of unsigned longs.

Quoted 5 lines
Quoted 1 line

Yes, you're right.  At one point I changed data to be an unsigned long *.

Thanks, its nice to have confirmation - I'm still pretty new at this. Can this get pulled onto tip/x86/x32? Desktop applications like firefox and chrome don't work reliably without it.

#3 lore raw
Quoted 11 lines · Bobby Powers
Quoted 10 lines · David Howells
Quoted 7 lines · Bobby Powers

alloc_fdtable allocates space for the open_fds and close_on_exec bitfields together, as 2 * nr / BITS_PER_BYTE. close_on_exec needs to point to open_fds + nr / BITS_PER_BYTE, not open_fds + nr / BITS_PER_LONG, as introducted in 1fd36adc: Replace the fd_sets in struct fdtable with an array of unsigned longs.

Quoted 8 lines
Quoted 3 lines

Yes, you're right. At one point I changed data to be an unsigned long *.

Thanks, its nice to have confirmation - I'm still pretty new at this. Can this get pulled onto tip/x86/x32? Desktop applications like firefox and chrome don't work reliably without it.

tip:core/types (and the updated core/types needs to be merged into x86/x32) but yes.

-hpa

#4 lore raw

[tip:core/types] fs: Fix close_on_exec pointer in alloc_fdtable

In reply to Bobby Powers
Commit-ID:  f044db4cb4bf16893812d35b5fbeaaf3e30c9215
Gitweb:     http://git.kernel.org/tip/f044db4cb4bf16893812d35b5fbeaaf3e30c9215
Author:     Bobby Powers <[email protected]>
AuthorDate: Wed, 22 Feb 2012 00:29:47 -0500
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Thu, 23 Feb 2012 18:28:52 -0800

fs: Fix close_on_exec pointer in alloc_fdtable

alloc_fdtable allocates space for the open_fds and close_on_exec bitfields together, as 2 * nr / BITS_PER_BYTE. close_on_exec needs to point to open_fds + nr / BITS_PER_BYTE, not open_fds + nr / BITS_PER_LONG, as introducted in 1fd36adc: Replace the fd_sets in struct fdtable with an array of unsigned longs.

---
 fs/file.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/file.c +1 -1
index 2d479dd..171f6b4 100644
@@ -179,7 +179,7 @@ static struct fdtable * alloc_fdtable(unsigned int nr)
 	if (!data)
 		goto out_arr;
 	fdt->open_fds = data;
-	data += nr / BITS_PER_LONG;
+	data += nr / BITS_PER_BYTE;
 	fdt->close_on_exec = data;
 	fdt->next = NULL;