Page MenuHomeFreeBSD

D32313.id96264.diff
No OneTemporary

D32313.id96264.diff

diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -151,6 +151,11 @@
SYSCTL_INT(_security_bsd, OID_AUTO, map_at_zero, CTLFLAG_RWTUN, &map_at_zero, 0,
"Permit processes to map an object at virtual address 0.");
+static int core_dump_intr = 1;
+SYSCTL_INT(_kern, OID_AUTO, core_dump_intr, CTLFLAG_RW,
+ &core_dump_intr, 0,
+ "Core dumping interruptible with SIGKILL");
+
static int
sysctl_kern_ps_strings(SYSCTL_HANDLER_ARGS)
{
@@ -1926,7 +1931,7 @@
struct mount *mp;
size_t resid, runlen;
int error;
- bool success;
+ bool interrupted, success;
KASSERT((uintptr_t)base % PAGE_SIZE == 0,
("%s: user address %p is not page-aligned", __func__, base));
@@ -1935,7 +1940,8 @@
return (compress_chunk(cp, base, tmpbuf, len));
map = &cp->td->td_proc->p_vmspace->vm_map;
- for (; len > 0; base += runlen, offset += runlen, len -= runlen) {
+ for (interrupted = false; !interrupted && len > 0;
+ base += runlen, offset += runlen, len -= runlen) {
/*
* Attempt to page in all virtual pages in the range. If a
* virtual page is not backed by the pager, it is represented as
@@ -1943,6 +1949,12 @@
* anonymous memory or truncated files, for example.
*/
for (runlen = 0; runlen < len; runlen += PAGE_SIZE) {
+ if (core_dump_intr && curproc_is_killed_hard()) {
+ error = EINTR;
+ success = false;
+ interrupted = true;
+ break;
+ }
error = vm_fault(map, (uintptr_t)base + runlen,
VM_PROT_READ, VM_FAULT_NOFILL, NULL);
if (runlen == 0)
@@ -1987,6 +1999,8 @@
break;
}
}
+ if (interrupted)
+ error = EINTR;
return (error);
}
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -214,7 +214,6 @@
#define SIGPROP_TTYSTOP 0x08 /* ditto, from tty */
#define SIGPROP_IGNORE 0x10 /* ignore by default */
#define SIGPROP_CONT 0x20 /* continue if suspended */
-#define SIGPROP_CANTMASK 0x40 /* non-maskable, catchable */
static int sigproptbl[NSIG] = {
[SIGHUP] = SIGPROP_KILL,
@@ -3277,6 +3276,29 @@
return (ret);
}
+bool
+curproc_is_killed_hard(void)
+{
+ struct thread *td;
+ struct proc *p;
+ struct sigacts *ps;
+ bool res;
+
+ td = curthread;
+ if ((td->td_flags & TDF_NEEDSIGCHK) == 0)
+ return (false);
+
+ p = td->td_proc;
+ PROC_LOCK(p);
+ ps = p->p_sigacts;
+ mtx_lock(&ps->ps_mtx);
+ res = SIGISMEMBER(td->td_sigqueue.sq_signals, SIGKILL) ||
+ SIGISMEMBER(p->p_sigqueue.sq_signals, SIGKILL);
+ mtx_unlock(&ps->ps_mtx);
+ PROC_UNLOCK(p);
+ return (res);
+}
+
void
proc_wkilled(struct proc *p)
{
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -1162,7 +1162,7 @@
extern void (*cpu_idle_hook)(sbintime_t); /* Hook to machdep CPU idler. */
void cpu_switch(struct thread *, struct thread *, struct mtx *);
void cpu_throw(struct thread *, struct thread *) __dead2;
-void unsleep(struct thread *);
+bool curproc_is_killed_hard(void);
void userret(struct thread *, struct trapframe *);
void cpu_exit(struct thread *);

File Metadata

Mime Type
text/plain
Expires
Mon, Sep 30, 9:10 PM (11 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
13204774
Default Alt Text
D32313.id96264.diff (3 KB)

Event Timeline