Re: futex question



Hi all:

catching up with the mails now. still pretty early here in the west coast.

Once upon a time, like on 09-10-05 4:47 AM, Thomas Gleixner wrote:
On Mon, 5 Oct 2009, Peter Zijlstra wrote:
On Mon, 2009-10-05 at 12:56 +0200, Thomas Gleixner wrote:

Looking more into that I think we should check whether the robust list
has an entry (lock held) in do_execve() and return -EWOULDBLOCK to
luser space. Same if pi_waiters is not empty. Holding a lock and
calling execve() is simply broken.


ha ha! Now you say it's broken :) Indeed, I also thought so. However, I wonder if this behavior change could potentially break some user space application?


Fine by me ;-)

something like the below?

The question is of course what Ani was doing that triggered this in the
first place and if he can live with this.. :-)

---
fs/exec.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/fs/exec.c b/fs/exec.c
index d49be6b..0812ba6 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1295,6 +1295,22 @@ int do_execve(char * filename,
bool clear_in_exec;
int retval;

+ retval = -EWOULDBLOCK;
+#ifdef CONFIG_FUTEX
+ if (unlikely(current->robust_list))
+ goto out_ret;
+#ifdef CONFIG_COMPAT
+ if (unlikely(current->compat_robust_list))
+ goto out_ret;
+#endif

That needs to call into the futex code and check whether the list is
empty. If not empty, return. If empty set the pointer to NULL

True. Just because the head pointer has been registered does not mean that the list is non-empty. It can point back to itself when no locks are held as it's circular.

We need to clear those pointers regardless. After the exceve(), the address values are meaningless under the new mm context.

Ani
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: futex question
    ... has an entry (lock held) in do_execveand return -EWOULDBLOCK to ... Same if pi_waiters is not empty. ... +#ifdef CONFIG_COMPAT ...
    (Linux-Kernel)
  • Re: Independent thread fireing events in ATL Service synchronization requirements?
    ... and hence the loop will not execute, ... m_vec itself is not a pointer, so it cannot be NULL for sure. ... >> Did you lock while adding and removing your objects to the list? ... >>> and made my client list a class with synchronization inside ...
    (microsoft.public.vc.atl)
  • Re: Independent thread fireing events in ATL Service synchronization requirements?
    ... Did you lock while adding and removing your objects to the list? ... are firing the events, since the lock is maintained around the entire ... > and made my client list a class with synchronization inside ... > pointer is not enough and that I would also need to lock ...
    (microsoft.public.vc.atl)
  • Re: wakeup idea...
    ... this pointer is actually a relevant datastructure. ... The first one can be implemented as an array; the reason of such a design decision is to avoid locking at SX acquire. ... of all the owners against the priority propagation for the read lock case. ...
    (freebsd-arch)
  • Re: Thread-safety and STL
    ... Raw pointers such as pvec introduce exception safety issues, ... the vector is a member of a class, it typically shouldn't be a pointer. ... Lock objects such as above should only ever be declared as local ... To see the problem, note that predicate objects are passed around by value, ...
    (microsoft.public.vc.mfc)