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: <6a1c323c0707300454yaf6eebfye9c5aaa3d4fe3723@mail.gmail.com>
Date:	Mon, 30 Jul 2007 07:54:58 -0400
From:	RG <cryptococa@...il.com>
To:	linux-kernel@...r.kernel.org
Subject: Question regarding process' final mmdrop

Hello,
   I've been reading through the kernel source code trying to figure
out when the final mmdrop() after a exit_mm() is called on a task that
is having its virtual address deleted. I have discovered one instance
in finish_task_switch(), the local variable mm is set (for a single
access) to the last user task's active mm_struct, which is then
mmdrop()'d if found not to be NULL. This implies that the user task
that runs before a kernel thread has its mm_struct mmdrop()'d after
said kernel thread is switched out because the kernel thread leeched
off of its mm_struct. When kernel threads leeches off a user task's
active_mm, it's logical for the kernel to increase the reference value
to avoid race conditions, however, exit_mm() increases the mm_struct's
count value in order to deffer the final mmdrop() to
finish_task_switch() (according to the UTLK, end of chapter 9.5). I
assume the final mmdrop() is deferred solely to have a valid pgd left
in %cr3 after mmput() calls mmdrop().
This one pair of switching to a kernel thread then mmdrop()ing its
active_mm once it's switched out makes sense to me. But what I don't
understand is, how the kernel calls mmdrop() after exit_mm().
To clarify, the kernel executes the following code at
finish_task_switch() (kernel/sched.c):
        struct mm_struct *mm = rq->prev_mm;
        ...
        if (mm)
                mmdrop(mm);
I don't see how the kernel is supposed to execute mmdrop() on a
exit_mm()'s behalf when exit_mm() does not set nor even touch
rq->prev_mm.

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ