* [hurd,commited 1/7] htl: Check error returned by __getrlimit
2023-01-02 10:09 [hurd,commited 0/7] hurd: fixes Samuel Thibault
@ 2023-01-02 10:09 ` Samuel Thibault
2023-01-02 10:09 ` [hurd,commited 2/7] hurd _S_msg_add_auth: Initialize new arrays to 0 Samuel Thibault
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Samuel Thibault @ 2023-01-02 10:09 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
---
htl/pt-create.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/htl/pt-create.c b/htl/pt-create.c
index 5d37edbbff..d3847b69ea 100644
--- a/htl/pt-create.c
+++ b/htl/pt-create.c
@@ -136,8 +136,8 @@ __pthread_create_internal (struct __pthread **thread,
if (stacksize == 0)
{
struct rlimit rlim;
- __getrlimit (RLIMIT_STACK, &rlim);
- if (rlim.rlim_cur != RLIM_INFINITY)
+ err = __getrlimit (RLIMIT_STACK, &rlim);
+ if (err == 0 && rlim.rlim_cur != RLIM_INFINITY)
stacksize = rlim.rlim_cur;
if (stacksize == 0)
stacksize = PTHREAD_STACK_DEFAULT;
--
2.39.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [hurd,commited 2/7] hurd _S_msg_add_auth: Initialize new arrays to 0
2023-01-02 10:09 [hurd,commited 0/7] hurd: fixes Samuel Thibault
2023-01-02 10:09 ` [hurd,commited 1/7] htl: Check error returned by __getrlimit Samuel Thibault
@ 2023-01-02 10:09 ` Samuel Thibault
2023-01-02 10:09 ` [hurd,commited 3/7] hurd hurdstartup: Initialize remaining fields of hurd_startup_data Samuel Thibault
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Samuel Thibault @ 2023-01-02 10:09 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
If make_list fails, they would be undefined, and freeup with free
uninitialized pointers.
---
hurd/hurdauth.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/hurd/hurdauth.c b/hurd/hurdauth.c
index 9086e9484c..25cc8ee88d 100644
--- a/hurd/hurdauth.c
+++ b/hurd/hurdauth.c
@@ -101,21 +101,24 @@ _S_msg_add_auth (mach_port_t me,
__mutex_lock (&_hurd_id.lock);
_hurd_check_ids ();
-#define MAKE(genaux,uidgid) \
- make_list (&new ## genaux ## uidgid ## s, \
+#define MAKE(genaux,uidgid) ({ \
+ new ## genaux ## uidgid ## s = 0; \
+ nnew ## genaux ## uidgid ## s = 0; \
+ make_list (&new ## genaux ## uidgid ## s, \
&nnew ## genaux ## uidgid ## s, \
_hurd_id.genaux.uidgid ## s, \
_hurd_id.genaux.n ## uidgid ## s, \
genaux ## uidgid ## s, \
- n ## genaux ## uidgid ## s)
+ n ## genaux ## uidgid ## s); \
+})
err = MAKE (gen, uid);
if (!err)
- MAKE (aux, uid);
+ err = MAKE (aux, uid);
if (!err)
- MAKE (gen, gid);
+ err = MAKE (gen, gid);
if (!err)
- MAKE (aux, gid);
+ err = MAKE (aux, gid);
#undef MAKE
__mutex_unlock (&_hurd_id.lock);
--
2.39.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [hurd,commited 3/7] hurd hurdstartup: Initialize remaining fields of hurd_startup_data
2023-01-02 10:09 [hurd,commited 0/7] hurd: fixes Samuel Thibault
2023-01-02 10:09 ` [hurd,commited 1/7] htl: Check error returned by __getrlimit Samuel Thibault
2023-01-02 10:09 ` [hurd,commited 2/7] hurd _S_msg_add_auth: Initialize new arrays to 0 Samuel Thibault
@ 2023-01-02 10:09 ` Samuel Thibault
2023-01-02 10:09 ` [hurd,commited 4/7] htl: Drop duplicate check in __pthread_stack_alloc Samuel Thibault
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Samuel Thibault @ 2023-01-02 10:09 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
In case we don't have a bootstrap port or __exec_startup_get_info
failed, we should avoid leaking uninitialized fields of data.
---
hurd/hurdstartup.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/hurd/hurdstartup.c b/hurd/hurdstartup.c
index e9cd8a360b..d312766052 100644
--- a/hurd/hurdstartup.c
+++ b/hurd/hurdstartup.c
@@ -145,6 +145,11 @@ _hurd_startup (void **argptr, void (*main) (intptr_t *data))
data.portarraysize = 0;
data.intarray = NULL;
data.intarraysize = 0;
+ data.stack_base = 0;
+ data.stack_size = 0;
+ data.phdr = 0;
+ data.phdrsz = 0;
+ data.user_entry = 0;
}
else if ((void *) &envp[envc + 1] == argv[0])
{
--
2.39.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [hurd,commited 4/7] htl: Drop duplicate check in __pthread_stack_alloc
2023-01-02 10:09 [hurd,commited 0/7] hurd: fixes Samuel Thibault
` (2 preceding siblings ...)
2023-01-02 10:09 ` [hurd,commited 3/7] hurd hurdstartup: Initialize remaining fields of hurd_startup_data Samuel Thibault
@ 2023-01-02 10:09 ` Samuel Thibault
2023-01-02 10:09 ` [hurd,commited 5/7] hurd: Make dl-sysdep __sbrk check __vm_allocate call Samuel Thibault
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Samuel Thibault @ 2023-01-02 10:09 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
---
sysdeps/mach/htl/pt-stack-alloc.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/sysdeps/mach/htl/pt-stack-alloc.c b/sysdeps/mach/htl/pt-stack-alloc.c
index cb1807cd16..d8c88fc389 100644
--- a/sysdeps/mach/htl/pt-stack-alloc.c
+++ b/sysdeps/mach/htl/pt-stack-alloc.c
@@ -57,9 +57,6 @@ get_stack:
return EAGAIN;
}
- if (base >= VM_MAX_ADDRESS)
- return EAGAIN;
-
next_stack_base = base + stacksize;
(*stackaddr) = (void *) base;
--
2.39.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [hurd,commited 5/7] hurd: Make dl-sysdep __sbrk check __vm_allocate call
2023-01-02 10:09 [hurd,commited 0/7] hurd: fixes Samuel Thibault
` (3 preceding siblings ...)
2023-01-02 10:09 ` [hurd,commited 4/7] htl: Drop duplicate check in __pthread_stack_alloc Samuel Thibault
@ 2023-01-02 10:09 ` Samuel Thibault
2023-01-02 10:09 ` [hurd,commited 6/7] hurd fcntl: Make LOCKED macro more robust Samuel Thibault
2023-01-02 10:09 ` [hurd,commited 7/7] hurd getcwd: Fix memory leak on error Samuel Thibault
6 siblings, 0 replies; 8+ messages in thread
From: Samuel Thibault @ 2023-01-02 10:09 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
The caller won't be able to progress, but better crash than use random
addr.
---
sysdeps/mach/hurd/dl-sysdep.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c
index 2f022ee90c..84fe966efe 100644
--- a/sysdeps/mach/hurd/dl-sysdep.c
+++ b/sysdeps/mach/hurd/dl-sysdep.c
@@ -699,7 +699,8 @@ void *weak_function
__sbrk (intptr_t increment)
{
vm_address_t addr;
- __vm_allocate (__mach_task_self (), &addr, increment, 1);
+ if (__vm_allocate (__mach_task_self (), &addr, increment, 1))
+ return NULL;
return (void *) addr;
}
--
2.39.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [hurd,commited 6/7] hurd fcntl: Make LOCKED macro more robust
2023-01-02 10:09 [hurd,commited 0/7] hurd: fixes Samuel Thibault
` (4 preceding siblings ...)
2023-01-02 10:09 ` [hurd,commited 5/7] hurd: Make dl-sysdep __sbrk check __vm_allocate call Samuel Thibault
@ 2023-01-02 10:09 ` Samuel Thibault
2023-01-02 10:09 ` [hurd,commited 7/7] hurd getcwd: Fix memory leak on error Samuel Thibault
6 siblings, 0 replies; 8+ messages in thread
From: Samuel Thibault @ 2023-01-02 10:09 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
---
sysdeps/mach/hurd/fcntl.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/sysdeps/mach/hurd/fcntl.c b/sysdeps/mach/hurd/fcntl.c
index ea35e9b977..48608493a1 100644
--- a/sysdeps/mach/hurd/fcntl.c
+++ b/sysdeps/mach/hurd/fcntl.c
@@ -109,7 +109,7 @@ __libc_fcntl (int fd, int cmd, ...)
/* Set RESULT by evaluating EXPR with the descriptor locked.
Check for an empty descriptor and return EBADF. */
-#define LOCKED(expr) \
+#define LOCKED(expr) do { \
HURD_CRITICAL_BEGIN; \
__spin_lock (&d->port.lock); \
if (d->port.port == MACH_PORT_NULL) \
@@ -117,7 +117,8 @@ __libc_fcntl (int fd, int cmd, ...)
else \
result = (expr); \
__spin_unlock (&d->port.lock); \
- HURD_CRITICAL_END;
+ HURD_CRITICAL_END; \
+} while(0)
case F_GETFD: /* Get descriptor flags. */
LOCKED (d->flags);
--
2.39.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [hurd,commited 7/7] hurd getcwd: Fix memory leak on error
2023-01-02 10:09 [hurd,commited 0/7] hurd: fixes Samuel Thibault
` (5 preceding siblings ...)
2023-01-02 10:09 ` [hurd,commited 6/7] hurd fcntl: Make LOCKED macro more robust Samuel Thibault
@ 2023-01-02 10:09 ` Samuel Thibault
6 siblings, 0 replies; 8+ messages in thread
From: Samuel Thibault @ 2023-01-02 10:09 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
---
sysdeps/mach/hurd/getcwd.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sysdeps/mach/hurd/getcwd.c b/sysdeps/mach/hurd/getcwd.c
index d11f744b2c..6ca364a418 100644
--- a/sysdeps/mach/hurd/getcwd.c
+++ b/sysdeps/mach/hurd/getcwd.c
@@ -274,6 +274,8 @@ __hurd_canonicalize_directory_name_internal (file_t thisdir,
/* Set errno. */
(void) __hurd_fail (err);
lose:
+ if (orig_size == 0)
+ free (file_name);
cleanup ();
return NULL;
}
--
2.39.0
^ permalink raw reply [flat|nested] 8+ messages in thread