xref: /dragonfly/sys/kern/kern_checkpoint.c (revision 80d831e1)
10ba6fbbfSMatthew Dillon /*-
20ba6fbbfSMatthew Dillon  * Copyright (c) 2003 Kip Macy
30ba6fbbfSMatthew Dillon  * All rights reserved.
40ba6fbbfSMatthew Dillon  *
50ba6fbbfSMatthew Dillon  * Redistribution and use in source and binary forms, with or without
60ba6fbbfSMatthew Dillon  * modification, are permitted provided that the following conditions
70ba6fbbfSMatthew Dillon  * are met:
80ba6fbbfSMatthew Dillon  * 1. Redistributions of source code must retain the above copyright
90ba6fbbfSMatthew Dillon  *    notice, this list of conditions and the following disclaimer.
100ba6fbbfSMatthew Dillon  * 2. Redistributions in binary form must reproduce the above copyright
110ba6fbbfSMatthew Dillon  *    notice, this list of conditions and the following disclaimer in the
120ba6fbbfSMatthew Dillon  *    documentation and/or other materials provided with the distribution.
130ba6fbbfSMatthew Dillon  *
140ba6fbbfSMatthew Dillon  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
150ba6fbbfSMatthew Dillon  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
160ba6fbbfSMatthew Dillon  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
170ba6fbbfSMatthew Dillon  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
180ba6fbbfSMatthew Dillon  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
190ba6fbbfSMatthew Dillon  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
200ba6fbbfSMatthew Dillon  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
210ba6fbbfSMatthew Dillon  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
220ba6fbbfSMatthew Dillon  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
230ba6fbbfSMatthew Dillon  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
240ba6fbbfSMatthew Dillon  * SUCH DAMAGE.
250ba6fbbfSMatthew Dillon  */
260ba6fbbfSMatthew Dillon 
270ba6fbbfSMatthew Dillon #include <sys/types.h>
280ba6fbbfSMatthew Dillon #include <sys/param.h>
290ba6fbbfSMatthew Dillon #include <sys/proc.h>
300ba6fbbfSMatthew Dillon #include <sys/module.h>
310ba6fbbfSMatthew Dillon #include <sys/sysent.h>
320ba6fbbfSMatthew Dillon #include <sys/kernel.h>
330ba6fbbfSMatthew Dillon #include <sys/systm.h>
340ba6fbbfSMatthew Dillon #include <sys/nlookup.h>
350ba6fbbfSMatthew Dillon 
360ba6fbbfSMatthew Dillon #include <sys/file.h>
370ba6fbbfSMatthew Dillon #include <sys/fcntl.h>
380ba6fbbfSMatthew Dillon #include <sys/signal.h>
390ba6fbbfSMatthew Dillon #include <vm/vm_param.h>
400ba6fbbfSMatthew Dillon #include <vm/vm.h>
410ba6fbbfSMatthew Dillon #include <sys/imgact_elf.h>
420ba6fbbfSMatthew Dillon #include <sys/procfs.h>
430ba6fbbfSMatthew Dillon 
440ba6fbbfSMatthew Dillon #include <sys/lock.h>
450ba6fbbfSMatthew Dillon #include <vm/pmap.h>
460ba6fbbfSMatthew Dillon #include <vm/vm_map.h>
470ba6fbbfSMatthew Dillon #include <vm/vm_extern.h>
480ba6fbbfSMatthew Dillon #include <sys/mman.h>
49*80d831e1SMatthew Dillon #include <sys/sysmsg.h>
500ba6fbbfSMatthew Dillon #include <sys/resource.h>
510ba6fbbfSMatthew Dillon #include <sys/resourcevar.h>
520ba6fbbfSMatthew Dillon #include <sys/malloc.h>
530ba6fbbfSMatthew Dillon #include <sys/stat.h>
540ba6fbbfSMatthew Dillon #include <sys/uio.h>
550ba6fbbfSMatthew Dillon #include <sys/vnode.h>
56664f5072SSascha Wildner #include <machine/inttypes.h>
570ba6fbbfSMatthew Dillon #include <machine/limits.h>
58f8334305SMatthew Dillon #include <machine/frame.h>
590ba6fbbfSMatthew Dillon #include <sys/signalvar.h>
600ba6fbbfSMatthew Dillon #include <sys/syslog.h>
610ba6fbbfSMatthew Dillon #include <sys/sysctl.h>
62f8334305SMatthew Dillon #include <machine/sigframe.h>
630ba6fbbfSMatthew Dillon #include <sys/exec.h>
640ba6fbbfSMatthew Dillon #include <sys/unistd.h>
650ba6fbbfSMatthew Dillon #include <sys/time.h>
660ba6fbbfSMatthew Dillon #include <sys/kern_syscall.h>
670ba6fbbfSMatthew Dillon #include <sys/checkpoint.h>
680ba6fbbfSMatthew Dillon #include <sys/mount.h>
690ba6fbbfSMatthew Dillon #include <sys/ckpt.h>
700ba6fbbfSMatthew Dillon 
71684a93c4SMatthew Dillon #include <sys/mplock2.h>
72684a93c4SMatthew Dillon #include <sys/file2.h>
73684a93c4SMatthew Dillon 
740ba6fbbfSMatthew Dillon static int elf_loadphdrs(struct file *fp,  Elf_Phdr *phdr, int numsegs);
757d20a8ffSSimon Schubert static int elf_getnotes(struct lwp *lp, struct file *fp, size_t notesz);
760ba6fbbfSMatthew Dillon static int elf_demarshalnotes(void *src, prpsinfo_t *psinfo,
770ba6fbbfSMatthew Dillon 		 prstatus_t *status, prfpregset_t *fpregset, int nthreads);
787d20a8ffSSimon Schubert static int elf_loadnotes(struct lwp *, prpsinfo_t *, prstatus_t *,
790ba6fbbfSMatthew Dillon 		 prfpregset_t *);
807d20a8ffSSimon Schubert static int elf_getsigs(struct lwp *lp, struct file *fp);
81f3a2d8c4SMatthew Dillon static int elf_getfiles(struct lwp *lp, struct file *fp);
820ba6fbbfSMatthew Dillon static int elf_gettextvp(struct proc *p, struct file *fp);
830ba6fbbfSMatthew Dillon static char *ckpt_expand_name(const char *name, uid_t uid, pid_t pid);
840ba6fbbfSMatthew Dillon 
850ba6fbbfSMatthew Dillon static int ckptgroup = 0;       /* wheel only, -1 for any group */
860ba6fbbfSMatthew Dillon SYSCTL_INT(_kern, OID_AUTO, ckptgroup, CTLFLAG_RW, &ckptgroup, 0, "");
870ba6fbbfSMatthew Dillon 
880ba6fbbfSMatthew Dillon /* ref count to see how many processes that are being checkpointed */
890ba6fbbfSMatthew Dillon static int chptinuse = 0;
900ba6fbbfSMatthew Dillon 
910ba6fbbfSMatthew Dillon static __inline
920ba6fbbfSMatthew Dillon int
read_check(struct file * fp,void * buf,size_t nbyte)930ba6fbbfSMatthew Dillon read_check(struct file *fp, void *buf, size_t nbyte)
940ba6fbbfSMatthew Dillon {
950ba6fbbfSMatthew Dillon 	size_t nread;
960ba6fbbfSMatthew Dillon 	int error;
970ba6fbbfSMatthew Dillon 
98664f5072SSascha Wildner 	PRINTF(("reading %zd bytes\n", nbyte));
99e7440b28SMatthew Dillon 	error = fp_read(fp, buf, nbyte, &nread, 1, UIO_SYSSPACE);
1000ba6fbbfSMatthew Dillon 	if (error) {
1010ba6fbbfSMatthew Dillon                 PRINTF(("read failed - %d", error));
1020ba6fbbfSMatthew Dillon 	} else if (nread != nbyte) {
103664f5072SSascha Wildner                 PRINTF(("wanted to read %zd - read %zd\n", nbyte, nread));
1040ba6fbbfSMatthew Dillon 		error = EINVAL;
1050ba6fbbfSMatthew Dillon 	}
1060ba6fbbfSMatthew Dillon 	return error;
1070ba6fbbfSMatthew Dillon }
1080ba6fbbfSMatthew Dillon 
1090ba6fbbfSMatthew Dillon static int
elf_gethdr(struct file * fp,Elf_Ehdr * ehdr)1100ba6fbbfSMatthew Dillon elf_gethdr(struct file *fp, Elf_Ehdr *ehdr)
1110ba6fbbfSMatthew Dillon {
1120ba6fbbfSMatthew Dillon 	size_t nbyte = sizeof(Elf_Ehdr);
1130ba6fbbfSMatthew Dillon 	int error;
1140ba6fbbfSMatthew Dillon 
1150ba6fbbfSMatthew Dillon 	if ((error = read_check(fp, ehdr, nbyte)) != 0)
1160ba6fbbfSMatthew Dillon 		goto done;
1170ba6fbbfSMatthew Dillon 	if (!(ehdr->e_ehsize == sizeof(Elf_Ehdr))) {
1180ba6fbbfSMatthew Dillon 		PRINTF(("wrong elf header size: %d\n"
119664f5072SSascha Wildner 		       "expected size        : %zd\n",
1200ba6fbbfSMatthew Dillon 		       ehdr->e_ehsize, sizeof(Elf_Ehdr)));
1210ba6fbbfSMatthew Dillon 		return EINVAL;
1220ba6fbbfSMatthew Dillon 	}
1230ba6fbbfSMatthew Dillon 	if (!(ehdr->e_phentsize == sizeof(Elf_Phdr))) {
1240ba6fbbfSMatthew Dillon 		PRINTF(("wrong program header size: %d\n"
125664f5072SSascha Wildner 		       "expected size            : %zd\n",
1260ba6fbbfSMatthew Dillon 		       ehdr->e_phentsize, sizeof(Elf_Phdr)));
1270ba6fbbfSMatthew Dillon 		return EINVAL;
1280ba6fbbfSMatthew Dillon 	}
1290ba6fbbfSMatthew Dillon 
1300ba6fbbfSMatthew Dillon 	if (!(ehdr->e_ident[EI_MAG0] == ELFMAG0 &&
1310ba6fbbfSMatthew Dillon 	      ehdr->e_ident[EI_MAG1] == ELFMAG1 &&
1320ba6fbbfSMatthew Dillon 	      ehdr->e_ident[EI_MAG2] == ELFMAG2 &&
1330ba6fbbfSMatthew Dillon 	      ehdr->e_ident[EI_MAG3] == ELFMAG3 &&
1340ba6fbbfSMatthew Dillon 	      ehdr->e_ident[EI_CLASS] == ELF_CLASS &&
1350ba6fbbfSMatthew Dillon 	      ehdr->e_ident[EI_DATA] == ELF_DATA &&
1360ba6fbbfSMatthew Dillon 	      ehdr->e_ident[EI_VERSION] == EV_CURRENT &&
1372d4fb35dSSamuel J. Greear 	      ehdr->e_ident[EI_OSABI] == ELFOSABI_NONE &&
1380ba6fbbfSMatthew Dillon 	      ehdr->e_ident[EI_ABIVERSION] == 0)) {
1390ba6fbbfSMatthew Dillon 		PRINTF(("bad elf header\n there are %d segments\n",
1400ba6fbbfSMatthew Dillon 		       ehdr->e_phnum));
1410ba6fbbfSMatthew Dillon 		return EINVAL;
1420ba6fbbfSMatthew Dillon 
1430ba6fbbfSMatthew Dillon 	}
1440ba6fbbfSMatthew Dillon 	PRINTF(("Elf header size:           %d\n", ehdr->e_ehsize));
1450ba6fbbfSMatthew Dillon 	PRINTF(("Program header size:       %d\n", ehdr->e_phentsize));
1460ba6fbbfSMatthew Dillon 	PRINTF(("Number of Program headers: %d\n", ehdr->e_phnum));
1470ba6fbbfSMatthew Dillon  done:
1480ba6fbbfSMatthew Dillon 	return error;
1490ba6fbbfSMatthew Dillon }
1500ba6fbbfSMatthew Dillon 
1510ba6fbbfSMatthew Dillon static int
elf_getphdrs(struct file * fp,Elf_Phdr * phdr,size_t nbyte)1520ba6fbbfSMatthew Dillon elf_getphdrs(struct file *fp, Elf_Phdr *phdr, size_t nbyte)
1530ba6fbbfSMatthew Dillon {
1540ba6fbbfSMatthew Dillon 	int i;
1550ba6fbbfSMatthew Dillon 	int error;
1560ba6fbbfSMatthew Dillon 	int nheaders = nbyte/sizeof(Elf_Phdr);
1570ba6fbbfSMatthew Dillon 
1580ba6fbbfSMatthew Dillon 	PRINTF(("reading phdrs section\n"));
1590ba6fbbfSMatthew Dillon 	if ((error = read_check(fp, phdr, nbyte)) != 0)
1600ba6fbbfSMatthew Dillon 		goto done;
161ff7a3478SMatthew Dillon 	PRINTF(("headers section:\n"));
1620ba6fbbfSMatthew Dillon 	for (i = 0; i < nheaders; i++) {
163ff7a3478SMatthew Dillon 		PRINTF(("entry type:   %d\n", phdr[i].p_type));
16436484f1dSSascha Wildner 		PRINTF(("file offset:  %jd\n", (intmax_t)phdr[i].p_offset));
165ff7a3478SMatthew Dillon 		PRINTF(("virt address: %p\n", (uint32_t *)phdr[i].p_vaddr));
16636484f1dSSascha Wildner 		PRINTF(("file size:    %jd\n", (intmax_t)phdr[i].p_filesz));
16736484f1dSSascha Wildner 		PRINTF(("memory size:  %jd\n", (intmax_t)phdr[i].p_memsz));
168ff7a3478SMatthew Dillon 		PRINTF(("\n"));
1690ba6fbbfSMatthew Dillon 	}
1700ba6fbbfSMatthew Dillon  done:
1710ba6fbbfSMatthew Dillon 	return error;
1720ba6fbbfSMatthew Dillon }
1730ba6fbbfSMatthew Dillon 
1740ba6fbbfSMatthew Dillon 
1750ba6fbbfSMatthew Dillon static int
elf_getnotes(struct lwp * lp,struct file * fp,size_t notesz)1767d20a8ffSSimon Schubert elf_getnotes(struct lwp *lp, struct file *fp, size_t notesz)
1770ba6fbbfSMatthew Dillon {
1780ba6fbbfSMatthew Dillon 	int error;
1790ba6fbbfSMatthew Dillon 	int nthreads;
1800ba6fbbfSMatthew Dillon 	char *note;
1810ba6fbbfSMatthew Dillon 	prpsinfo_t *psinfo;
1820ba6fbbfSMatthew Dillon 	prstatus_t *status;
1830ba6fbbfSMatthew Dillon 	prfpregset_t *fpregset;
1840ba6fbbfSMatthew Dillon 
1850ba6fbbfSMatthew Dillon 	nthreads = (notesz - sizeof(prpsinfo_t))/(sizeof(prstatus_t) +
1860ba6fbbfSMatthew Dillon 						  sizeof(prfpregset_t));
1870ba6fbbfSMatthew Dillon 	PRINTF(("reading notes header nthreads=%d\n", nthreads));
1880ba6fbbfSMatthew Dillon 	if (nthreads <= 0 || nthreads > CKPT_MAXTHREADS)
1890ba6fbbfSMatthew Dillon 		return EINVAL;
1900ba6fbbfSMatthew Dillon 
191efda3bd0SMatthew Dillon 	psinfo  = kmalloc(sizeof(prpsinfo_t), M_TEMP, M_ZERO | M_WAITOK);
192efda3bd0SMatthew Dillon 	status  = kmalloc(nthreads*sizeof(prstatus_t), M_TEMP, M_WAITOK);
193efda3bd0SMatthew Dillon 	fpregset  = kmalloc(nthreads*sizeof(prfpregset_t), M_TEMP, M_WAITOK);
194efda3bd0SMatthew Dillon 	note = kmalloc(notesz, M_TEMP, M_WAITOK);
1950ba6fbbfSMatthew Dillon 
1960ba6fbbfSMatthew Dillon 
1970ba6fbbfSMatthew Dillon 	PRINTF(("reading notes section\n"));
1980ba6fbbfSMatthew Dillon 	if ((error = read_check(fp, note, notesz)) != 0)
1990ba6fbbfSMatthew Dillon 		goto done;
2000ba6fbbfSMatthew Dillon 	error = elf_demarshalnotes(note, psinfo, status, fpregset, nthreads);
2010ba6fbbfSMatthew Dillon 	if (error)
2020ba6fbbfSMatthew Dillon 		goto done;
2030ba6fbbfSMatthew Dillon 	/* fetch register state from notes */
2047d20a8ffSSimon Schubert 	error = elf_loadnotes(lp, psinfo, status, fpregset);
2050ba6fbbfSMatthew Dillon  done:
2060ba6fbbfSMatthew Dillon 	if (psinfo)
207efda3bd0SMatthew Dillon 		kfree(psinfo, M_TEMP);
2080ba6fbbfSMatthew Dillon 	if (status)
209efda3bd0SMatthew Dillon 		kfree(status, M_TEMP);
2100ba6fbbfSMatthew Dillon 	if (fpregset)
211efda3bd0SMatthew Dillon 		kfree(fpregset, M_TEMP);
2120ba6fbbfSMatthew Dillon 	if (note)
213efda3bd0SMatthew Dillon 		kfree(note, M_TEMP);
2140ba6fbbfSMatthew Dillon 	return error;
2150ba6fbbfSMatthew Dillon }
2160ba6fbbfSMatthew Dillon 
2170ba6fbbfSMatthew Dillon static int
ckpt_thaw_proc(struct lwp * lp,struct file * fp)2187d20a8ffSSimon Schubert ckpt_thaw_proc(struct lwp *lp, struct file *fp)
2190ba6fbbfSMatthew Dillon {
2207d20a8ffSSimon Schubert 	struct proc *p = lp->lwp_proc;
2210ba6fbbfSMatthew Dillon 	Elf_Phdr *phdr = NULL;
2220ba6fbbfSMatthew Dillon 	Elf_Ehdr *ehdr = NULL;
2230ba6fbbfSMatthew Dillon 	int error;
2240ba6fbbfSMatthew Dillon 	size_t nbyte;
2250ba6fbbfSMatthew Dillon 
2260ba6fbbfSMatthew Dillon 	TRACE_ENTER;
2270ba6fbbfSMatthew Dillon 
228efda3bd0SMatthew Dillon 	ehdr = kmalloc(sizeof(Elf_Ehdr), M_TEMP, M_ZERO | M_WAITOK);
2290ba6fbbfSMatthew Dillon 
2300ba6fbbfSMatthew Dillon 	if ((error = elf_gethdr(fp, ehdr)) != 0)
2310ba6fbbfSMatthew Dillon 		goto done;
2320ba6fbbfSMatthew Dillon 	nbyte = sizeof(Elf_Phdr) * ehdr->e_phnum;
233efda3bd0SMatthew Dillon 	phdr = kmalloc(nbyte, M_TEMP, M_WAITOK);
2340ba6fbbfSMatthew Dillon 
2350ba6fbbfSMatthew Dillon 	/* fetch description of program writable mappings */
2360ba6fbbfSMatthew Dillon 	if ((error = elf_getphdrs(fp, phdr, nbyte)) != 0)
2370ba6fbbfSMatthew Dillon 		goto done;
2380ba6fbbfSMatthew Dillon 
2390ba6fbbfSMatthew Dillon 	/* fetch notes section containing register state */
2407d20a8ffSSimon Schubert 	if ((error = elf_getnotes(lp, fp, phdr->p_filesz)) != 0)
2410ba6fbbfSMatthew Dillon 		goto done;
2420ba6fbbfSMatthew Dillon 
2430ba6fbbfSMatthew Dillon 	/* fetch program text vnodes */
2440ba6fbbfSMatthew Dillon 	if ((error = elf_gettextvp(p, fp)) != 0)
2450ba6fbbfSMatthew Dillon 		goto done;
2460ba6fbbfSMatthew Dillon 
2470ba6fbbfSMatthew Dillon 	/* fetch signal disposition */
2487d20a8ffSSimon Schubert 	if ((error = elf_getsigs(lp, fp)) != 0) {
2496ea70f76SSascha Wildner 		kprintf("failure in recovering signals\n");
2500ba6fbbfSMatthew Dillon 		goto done;
2514f12bfd3SMatthew Dillon 	}
2520ba6fbbfSMatthew Dillon 
2530ba6fbbfSMatthew Dillon 	/* fetch open files */
254f3a2d8c4SMatthew Dillon 	if ((error = elf_getfiles(lp, fp)) != 0)
2550ba6fbbfSMatthew Dillon 		goto done;
2560ba6fbbfSMatthew Dillon 
2570ba6fbbfSMatthew Dillon 	/* handle mappings last in case we are reading from a socket */
2580ba6fbbfSMatthew Dillon 	error = elf_loadphdrs(fp, phdr, ehdr->e_phnum);
2590ba6fbbfSMatthew Dillon 
2600ba6fbbfSMatthew Dillon 	/*
2610ba6fbbfSMatthew Dillon 	 * Set the textvp to the checkpoint file and mark the vnode so
2620ba6fbbfSMatthew Dillon 	 * a future checkpointing of this checkpoint-restored program
2630ba6fbbfSMatthew Dillon 	 * will copy out the contents of the mappings rather then trying
2640ba6fbbfSMatthew Dillon 	 * to record the vnode info related to the checkpoint file, which
2650ba6fbbfSMatthew Dillon 	 * is likely going to be destroyed when the program is re-checkpointed.
2660ba6fbbfSMatthew Dillon 	 */
2670ba6fbbfSMatthew Dillon 	if (error == 0 && fp->f_data && fp->f_type == DTYPE_VNODE) {
2680ba6fbbfSMatthew Dillon 		if (p->p_textvp)
2690ba6fbbfSMatthew Dillon 			vrele(p->p_textvp);
2700ba6fbbfSMatthew Dillon 		p->p_textvp = (struct vnode *)fp->f_data;
2712247fe02SMatthew Dillon 		vsetflags(p->p_textvp, VCKPT);
2720ba6fbbfSMatthew Dillon 		vref(p->p_textvp);
2730ba6fbbfSMatthew Dillon 	}
2740ba6fbbfSMatthew Dillon done:
2750ba6fbbfSMatthew Dillon 	if (ehdr)
276efda3bd0SMatthew Dillon 		kfree(ehdr, M_TEMP);
2770ba6fbbfSMatthew Dillon 	if (phdr)
278efda3bd0SMatthew Dillon 		kfree(phdr, M_TEMP);
2790ba6fbbfSMatthew Dillon 	TRACE_EXIT;
2800ba6fbbfSMatthew Dillon 	return error;
2810ba6fbbfSMatthew Dillon }
2820ba6fbbfSMatthew Dillon 
2830ba6fbbfSMatthew Dillon static int
elf_loadnotes(struct lwp * lp,prpsinfo_t * psinfo,prstatus_t * status,prfpregset_t * fpregset)2847d20a8ffSSimon Schubert elf_loadnotes(struct lwp *lp, prpsinfo_t *psinfo, prstatus_t *status,
2850ba6fbbfSMatthew Dillon 	   prfpregset_t *fpregset)
2860ba6fbbfSMatthew Dillon {
2877d20a8ffSSimon Schubert 	struct proc *p = lp->lwp_proc;
2880ba6fbbfSMatthew Dillon 	int error;
2890ba6fbbfSMatthew Dillon 
2900ba6fbbfSMatthew Dillon 	/* validate status and psinfo */
2910ba6fbbfSMatthew Dillon 	TRACE_ENTER;
2920ba6fbbfSMatthew Dillon 	if (status->pr_version != PRSTATUS_VERSION ||
2930ba6fbbfSMatthew Dillon 	    status->pr_statussz != sizeof(prstatus_t) ||
2940ba6fbbfSMatthew Dillon 	    status->pr_gregsetsz != sizeof(gregset_t) ||
2950ba6fbbfSMatthew Dillon 	    status->pr_fpregsetsz != sizeof(fpregset_t) ||
2960ba6fbbfSMatthew Dillon 	    psinfo->pr_version != PRPSINFO_VERSION ||
2970ba6fbbfSMatthew Dillon 	    psinfo->pr_psinfosz != sizeof(prpsinfo_t)) {
2980ba6fbbfSMatthew Dillon 	        PRINTF(("status check failed\n"));
2990ba6fbbfSMatthew Dillon 		error = EINVAL;
3000ba6fbbfSMatthew Dillon 		goto done;
3010ba6fbbfSMatthew Dillon 	}
3027d20a8ffSSimon Schubert 	/* XXX lwp handle more than one lwp*/
30308f2f1bbSSimon Schubert 	if ((error = set_regs(lp, &status->pr_reg)) != 0)
3040ba6fbbfSMatthew Dillon 		goto done;
30508f2f1bbSSimon Schubert 	error = set_fpregs(lp, fpregset);
3060ba6fbbfSMatthew Dillon 	strlcpy(p->p_comm, psinfo->pr_fname, sizeof(p->p_comm));
3070ba6fbbfSMatthew Dillon 	/* XXX psinfo->pr_psargs not yet implemented */
3080ba6fbbfSMatthew Dillon  done:
3090ba6fbbfSMatthew Dillon 	TRACE_EXIT;
3100ba6fbbfSMatthew Dillon 	return error;
3110ba6fbbfSMatthew Dillon }
3120ba6fbbfSMatthew Dillon 
3130ba6fbbfSMatthew Dillon static int
elf_getnote(void * src,size_t * off,const char * name,unsigned int type,void ** desc,size_t descsz)3140ba6fbbfSMatthew Dillon elf_getnote(void *src, size_t *off, const char *name, unsigned int type,
3150ba6fbbfSMatthew Dillon 	    void **desc, size_t descsz)
3160ba6fbbfSMatthew Dillon {
3170ba6fbbfSMatthew Dillon 	Elf_Note note;
3180ba6fbbfSMatthew Dillon 	int error;
3190ba6fbbfSMatthew Dillon 
3200ba6fbbfSMatthew Dillon 	TRACE_ENTER;
3210ba6fbbfSMatthew Dillon 	if (src == NULL) {
3220ba6fbbfSMatthew Dillon 		error = EFAULT;
3230ba6fbbfSMatthew Dillon 		goto done;
3240ba6fbbfSMatthew Dillon 	}
3250ba6fbbfSMatthew Dillon 	bcopy((char *)src + *off, &note, sizeof note);
3260ba6fbbfSMatthew Dillon 
327664f5072SSascha Wildner 	PRINTF(("at offset: %zd expected note of type: %d - got: %d\n",
3280ba6fbbfSMatthew Dillon 	       *off, type, note.n_type));
3290ba6fbbfSMatthew Dillon 	*off += sizeof note;
3300ba6fbbfSMatthew Dillon 	if (type != note.n_type) {
3310ba6fbbfSMatthew Dillon 		TRACE_ERR;
3320ba6fbbfSMatthew Dillon 		error = EINVAL;
3330ba6fbbfSMatthew Dillon 		goto done;
3340ba6fbbfSMatthew Dillon 	}
3350ba6fbbfSMatthew Dillon 	if (strncmp(name, (char *) src + *off, note.n_namesz) != 0) {
3360ba6fbbfSMatthew Dillon 		error = EINVAL;
3370ba6fbbfSMatthew Dillon 		goto done;
3380ba6fbbfSMatthew Dillon 	}
3390ba6fbbfSMatthew Dillon 	*off += roundup2(note.n_namesz, sizeof(Elf_Size));
3400ba6fbbfSMatthew Dillon 	if (note.n_descsz != descsz) {
3410ba6fbbfSMatthew Dillon 		TRACE_ERR;
3420ba6fbbfSMatthew Dillon 		error = EINVAL;
3430ba6fbbfSMatthew Dillon 		goto done;
3440ba6fbbfSMatthew Dillon 	}
3450ba6fbbfSMatthew Dillon 	if (desc)
3460ba6fbbfSMatthew Dillon 	        bcopy((char *)src + *off, *desc, note.n_descsz);
3470ba6fbbfSMatthew Dillon 	*off += roundup2(note.n_descsz, sizeof(Elf_Size));
3480ba6fbbfSMatthew Dillon 	error = 0;
3490ba6fbbfSMatthew Dillon  done:
3500ba6fbbfSMatthew Dillon 	TRACE_EXIT;
3510ba6fbbfSMatthew Dillon 	return error;
3520ba6fbbfSMatthew Dillon }
3530ba6fbbfSMatthew Dillon 
3540ba6fbbfSMatthew Dillon static int
elf_demarshalnotes(void * src,prpsinfo_t * psinfo,prstatus_t * status,prfpregset_t * fpregset,int nthreads)3550ba6fbbfSMatthew Dillon elf_demarshalnotes(void *src, prpsinfo_t *psinfo, prstatus_t *status,
3560ba6fbbfSMatthew Dillon 		   prfpregset_t *fpregset, int nthreads)
3570ba6fbbfSMatthew Dillon {
3580ba6fbbfSMatthew Dillon 	int i;
3590ba6fbbfSMatthew Dillon 	int error;
360973c11b9SMatthew Dillon 	size_t off = 0;
3610ba6fbbfSMatthew Dillon 
3620ba6fbbfSMatthew Dillon 	TRACE_ENTER;
3632d4fb35dSSamuel J. Greear 	error = elf_getnote(src, &off, "CORE", NT_PRPSINFO,
364075a756cSMatthew Dillon 			   (void **)&psinfo, sizeof(prpsinfo_t));
365075a756cSMatthew Dillon 	if (error)
366075a756cSMatthew Dillon 		goto done;
3672d4fb35dSSamuel J. Greear 	error = elf_getnote(src, &off, "CORE", NT_PRSTATUS,
3680ba6fbbfSMatthew Dillon 			   (void **)&status, sizeof(prstatus_t));
3690ba6fbbfSMatthew Dillon 	if (error)
3700ba6fbbfSMatthew Dillon 		goto done;
3712d4fb35dSSamuel J. Greear 	error = elf_getnote(src, &off, "CORE", NT_FPREGSET,
3720ba6fbbfSMatthew Dillon 			   (void **)&fpregset, sizeof(prfpregset_t));
3730ba6fbbfSMatthew Dillon 	if (error)
3740ba6fbbfSMatthew Dillon 		goto done;
3750ba6fbbfSMatthew Dillon 
3760ba6fbbfSMatthew Dillon 	/*
3770ba6fbbfSMatthew Dillon 	 * The remaining portion needs to be an integer multiple
3780ba6fbbfSMatthew Dillon 	 * of prstatus_t and prfpregset_t
3790ba6fbbfSMatthew Dillon 	 */
3800ba6fbbfSMatthew Dillon 	for (i = 0 ; i < nthreads - 1; i++) {
3810ba6fbbfSMatthew Dillon 		status++; fpregset++;
3822d4fb35dSSamuel J. Greear 		error = elf_getnote(src, &off, "CORE", NT_PRSTATUS,
3830ba6fbbfSMatthew Dillon 				   (void **)&status, sizeof (prstatus_t));
3840ba6fbbfSMatthew Dillon 		if (error)
3850ba6fbbfSMatthew Dillon 			goto done;
3862d4fb35dSSamuel J. Greear 		error = elf_getnote(src, &off, "CORE", NT_FPREGSET,
3870ba6fbbfSMatthew Dillon 				   (void **)&fpregset, sizeof(prfpregset_t));
3880ba6fbbfSMatthew Dillon 		if (error)
3890ba6fbbfSMatthew Dillon 			goto done;
3900ba6fbbfSMatthew Dillon 	}
3910ba6fbbfSMatthew Dillon 
3920ba6fbbfSMatthew Dillon  done:
3930ba6fbbfSMatthew Dillon 	TRACE_EXIT;
3940ba6fbbfSMatthew Dillon 	return error;
3950ba6fbbfSMatthew Dillon }
3960ba6fbbfSMatthew Dillon 
3970ba6fbbfSMatthew Dillon 
3980ba6fbbfSMatthew Dillon static int
mmap_phdr(struct file * fp,Elf_Phdr * phdr)3990ba6fbbfSMatthew Dillon mmap_phdr(struct file *fp, Elf_Phdr *phdr)
4000ba6fbbfSMatthew Dillon {
4010ba6fbbfSMatthew Dillon 	int error;
4020ba6fbbfSMatthew Dillon 	size_t len;
4030ba6fbbfSMatthew Dillon 	int prot;
4040ba6fbbfSMatthew Dillon 	void *addr;
4050ba6fbbfSMatthew Dillon 	int flags;
4060ba6fbbfSMatthew Dillon 	off_t pos;
4070ba6fbbfSMatthew Dillon 
4080ba6fbbfSMatthew Dillon 	TRACE_ENTER;
4090ba6fbbfSMatthew Dillon 	pos = phdr->p_offset;
4100ba6fbbfSMatthew Dillon 	len = phdr->p_filesz;
4110ba6fbbfSMatthew Dillon 	addr = (void *)phdr->p_vaddr;
4120ba6fbbfSMatthew Dillon 	flags = MAP_FIXED | MAP_NOSYNC | MAP_PRIVATE;
4130ba6fbbfSMatthew Dillon 	prot = 0;
4140ba6fbbfSMatthew Dillon 	if (phdr->p_flags & PF_R)
4150ba6fbbfSMatthew Dillon 		prot |= PROT_READ;
4160ba6fbbfSMatthew Dillon 	if (phdr->p_flags & PF_W)
4170ba6fbbfSMatthew Dillon 		prot |= PROT_WRITE;
4180ba6fbbfSMatthew Dillon 	if (phdr->p_flags & PF_X)
4190ba6fbbfSMatthew Dillon 		prot |= PROT_EXEC;
4200ba6fbbfSMatthew Dillon 	if ((error = fp_mmap(addr, len, prot, flags, fp, pos, &addr)) != 0) {
4210ba6fbbfSMatthew Dillon 		PRINTF(("mmap failed: %d\n", error);	   );
4220ba6fbbfSMatthew Dillon 	}
423664f5072SSascha Wildner 	PRINTF(("map @%08"PRIxPTR"-%08"PRIxPTR" fileoff %08x-%08x\n", (uintptr_t)addr,
424664f5072SSascha Wildner 		   (uintptr_t)((char *)addr + len), (int)pos, (int)(pos + len)));
4250ba6fbbfSMatthew Dillon 	TRACE_EXIT;
4260ba6fbbfSMatthew Dillon 	return error;
4270ba6fbbfSMatthew Dillon }
4280ba6fbbfSMatthew Dillon 
429ff7a3478SMatthew Dillon /*
430ff7a3478SMatthew Dillon  * Load memory mapped segments.  The segments are backed by the checkpoint
431ff7a3478SMatthew Dillon  * file.
432ff7a3478SMatthew Dillon  */
4330ba6fbbfSMatthew Dillon static int
elf_loadphdrs(struct file * fp,Elf_Phdr * phdr,int numsegs)4340ba6fbbfSMatthew Dillon elf_loadphdrs(struct file *fp, Elf_Phdr *phdr, int numsegs)
4350ba6fbbfSMatthew Dillon {
4360ba6fbbfSMatthew Dillon 	int i;
4370ba6fbbfSMatthew Dillon 	int error = 0;
4380ba6fbbfSMatthew Dillon 
4390ba6fbbfSMatthew Dillon 	TRACE_ENTER;
4400ba6fbbfSMatthew Dillon 	for (i = 1; i < numsegs; i++)  {
4410ba6fbbfSMatthew Dillon 		if ((error = mmap_phdr(fp, &phdr[i])) != 0)
4420ba6fbbfSMatthew Dillon 			break;
4430ba6fbbfSMatthew Dillon 	}
4440ba6fbbfSMatthew Dillon 	TRACE_EXIT;
4450ba6fbbfSMatthew Dillon 	return error;
4460ba6fbbfSMatthew Dillon }
4470ba6fbbfSMatthew Dillon 
4480ba6fbbfSMatthew Dillon static int
elf_getsigs(struct lwp * lp,struct file * fp)4497d20a8ffSSimon Schubert elf_getsigs(struct lwp *lp, struct file *fp)
4500ba6fbbfSMatthew Dillon {
4517d20a8ffSSimon Schubert 	struct proc *p = lp->lwp_proc;
4520ba6fbbfSMatthew Dillon 	int error;
4530ba6fbbfSMatthew Dillon 	struct ckpt_siginfo *csi;
4540ba6fbbfSMatthew Dillon 
4550ba6fbbfSMatthew Dillon 	TRACE_ENTER;
456efda3bd0SMatthew Dillon 	csi = kmalloc(sizeof(struct ckpt_siginfo), M_TEMP, M_ZERO | M_WAITOK);
4570ba6fbbfSMatthew Dillon 	if ((error = read_check(fp, csi, sizeof(struct ckpt_siginfo))) != 0)
4580ba6fbbfSMatthew Dillon 		goto done;
4590ba6fbbfSMatthew Dillon 
4600ba6fbbfSMatthew Dillon 	if (csi->csi_ckptpisz != sizeof(struct ckpt_siginfo)) {
4610ba6fbbfSMatthew Dillon 		TRACE_ERR;
4620ba6fbbfSMatthew Dillon 		error = EINVAL;
4630ba6fbbfSMatthew Dillon 		goto done;
4640ba6fbbfSMatthew Dillon 	}
46504a31cc9SSascha Wildner 	bcopy(&csi->csi_sigacts, p->p_sigacts, sizeof(struct sigacts));
4660ba6fbbfSMatthew Dillon 	bcopy(&csi->csi_itimerval, &p->p_realtimer, sizeof(struct itimerval));
4674f12bfd3SMatthew Dillon 	SIG_CANTMASK(csi->csi_sigmask);
4687d20a8ffSSimon Schubert 	/* XXX lwp handle more than one lwp */
46908f2f1bbSSimon Schubert 	bcopy(&csi->csi_sigmask, &lp->lwp_sigmask, sizeof(sigset_t));
4700ba6fbbfSMatthew Dillon 	p->p_sigparent = csi->csi_sigparent;
4710ba6fbbfSMatthew Dillon  done:
4720ba6fbbfSMatthew Dillon 	if (csi)
473efda3bd0SMatthew Dillon 		kfree(csi, M_TEMP);
4740ba6fbbfSMatthew Dillon 	TRACE_EXIT;
4750ba6fbbfSMatthew Dillon 	return error;
4760ba6fbbfSMatthew Dillon }
4770ba6fbbfSMatthew Dillon 
4780ba6fbbfSMatthew Dillon /*
4790ba6fbbfSMatthew Dillon  * Returns a locked, refd vnode
4800ba6fbbfSMatthew Dillon  */
4810ba6fbbfSMatthew Dillon static int
ckpt_fhtovp(fhandle_t * fh,struct vnode ** vpp)4820ba6fbbfSMatthew Dillon ckpt_fhtovp(fhandle_t *fh, struct vnode **vpp)
4830ba6fbbfSMatthew Dillon {
4840ba6fbbfSMatthew Dillon 	struct mount *mp;
4850ba6fbbfSMatthew Dillon 	int error;
4860ba6fbbfSMatthew Dillon 
4870ba6fbbfSMatthew Dillon 	TRACE_ENTER;
4880ba6fbbfSMatthew Dillon 	mp = vfs_getvfs(&fh->fh_fsid);
4890ba6fbbfSMatthew Dillon 
4900ba6fbbfSMatthew Dillon 	if (!mp) {
4910ba6fbbfSMatthew Dillon 		TRACE_ERR;
4920ba6fbbfSMatthew Dillon 		PRINTF(("failed to get mount - ESTALE\n"));
4930ba6fbbfSMatthew Dillon 	        TRACE_EXIT;
4940ba6fbbfSMatthew Dillon 		return ESTALE;
4950ba6fbbfSMatthew Dillon 	}
49667863d04SMatthew Dillon 	error = VFS_FHTOVP(mp, NULL, &fh->fh_fid, vpp);
497fb578eacSMatthew Dillon 	mount_drop(mp);
4980ba6fbbfSMatthew Dillon 	if (error) {
4990ba6fbbfSMatthew Dillon 		PRINTF(("failed with: %d\n", error));
5000ba6fbbfSMatthew Dillon 		TRACE_ERR;
5010ba6fbbfSMatthew Dillon 	}
5020ba6fbbfSMatthew Dillon 	TRACE_EXIT;
503fb578eacSMatthew Dillon 	return error;
5040ba6fbbfSMatthew Dillon }
5050ba6fbbfSMatthew Dillon 
5060ba6fbbfSMatthew Dillon static int
mmap_vp(struct vn_hdr * vnh)5070ba6fbbfSMatthew Dillon mmap_vp(struct vn_hdr *vnh)
5080ba6fbbfSMatthew Dillon {
5090ba6fbbfSMatthew Dillon 	struct vnode *vp;
5100ba6fbbfSMatthew Dillon 	Elf_Phdr *phdr;
5110ba6fbbfSMatthew Dillon 	struct file *fp;
5120ba6fbbfSMatthew Dillon 	int error;
5130ba6fbbfSMatthew Dillon 	TRACE_ENTER;
5140ba6fbbfSMatthew Dillon 
5150ba6fbbfSMatthew Dillon 	phdr = &vnh->vnh_phdr;
5160ba6fbbfSMatthew Dillon 
5170ba6fbbfSMatthew Dillon 	if ((error = ckpt_fhtovp(&vnh->vnh_fh, &vp)) != 0)
5180ba6fbbfSMatthew Dillon 		return error;
5190ba6fbbfSMatthew Dillon 	/*
5200ba6fbbfSMatthew Dillon 	 * XXX O_RDONLY -> or O_RDWR if file is PROT_WRITE, MAP_SHARED
5210ba6fbbfSMatthew Dillon 	 */
5220ba6fbbfSMatthew Dillon 	if ((error = fp_vpopen(vp, O_RDONLY, &fp)) != 0) {
5230ba6fbbfSMatthew Dillon 		vput(vp);
5240ba6fbbfSMatthew Dillon 		return error;
5250ba6fbbfSMatthew Dillon 	}
5260ba6fbbfSMatthew Dillon 	error = mmap_phdr(fp, phdr);
5270ba6fbbfSMatthew Dillon 	fp_close(fp);
5280ba6fbbfSMatthew Dillon 	TRACE_EXIT;
5290ba6fbbfSMatthew Dillon 	return error;
5300ba6fbbfSMatthew Dillon }
5310ba6fbbfSMatthew Dillon 
5320ba6fbbfSMatthew Dillon 
5330ba6fbbfSMatthew Dillon static int
elf_gettextvp(struct proc * p,struct file * fp)5340ba6fbbfSMatthew Dillon elf_gettextvp(struct proc *p, struct file *fp)
5350ba6fbbfSMatthew Dillon {
5360ba6fbbfSMatthew Dillon 	int i;
5370ba6fbbfSMatthew Dillon 	int error;
5380ba6fbbfSMatthew Dillon 	int vpcount;
5390ba6fbbfSMatthew Dillon 	struct ckpt_vminfo vminfo;
5400ba6fbbfSMatthew Dillon 	struct vn_hdr *vnh = NULL;
5410ba6fbbfSMatthew Dillon 
5420ba6fbbfSMatthew Dillon 	TRACE_ENTER;
5430ba6fbbfSMatthew Dillon 	if ((error = read_check(fp, &vminfo, sizeof(vminfo))) != 0)
5440ba6fbbfSMatthew Dillon 		goto done;
5450ba6fbbfSMatthew Dillon 	if (vminfo.cvm_dsize < 0 ||
5460ba6fbbfSMatthew Dillon 	    vminfo.cvm_dsize > p->p_rlimit[RLIMIT_DATA].rlim_cur ||
5470ba6fbbfSMatthew Dillon 	    vminfo.cvm_tsize < 0 ||
5480ba6fbbfSMatthew Dillon 	    (u_quad_t)vminfo.cvm_tsize > maxtsiz ||
54988181b08SMatthew Dillon 	    vminfo.cvm_daddr >= (caddr_t)VM_MAX_USER_ADDRESS ||
55088181b08SMatthew Dillon 	    vminfo.cvm_taddr >= (caddr_t)VM_MAX_USER_ADDRESS
5510ba6fbbfSMatthew Dillon 	) {
5520ba6fbbfSMatthew Dillon 	    error = ERANGE;
5530ba6fbbfSMatthew Dillon 	    goto done;
5540ba6fbbfSMatthew Dillon 	}
5550ba6fbbfSMatthew Dillon 
5560ba6fbbfSMatthew Dillon 	vmspace_exec(p, NULL);
5570ba6fbbfSMatthew Dillon 	p->p_vmspace->vm_daddr = vminfo.cvm_daddr;
5584b566556SMatthew Dillon 	p->p_vmspace->vm_dsize = ctob(vminfo.cvm_dsize);	/* in bytes */
5590ba6fbbfSMatthew Dillon 	p->p_vmspace->vm_taddr = vminfo.cvm_taddr;
5604b566556SMatthew Dillon 	p->p_vmspace->vm_tsize = ctob(vminfo.cvm_tsize);	/* in bytes */
5610ba6fbbfSMatthew Dillon 	if ((error = read_check(fp, &vpcount, sizeof(int))) != 0)
5620ba6fbbfSMatthew Dillon 		goto done;
563efda3bd0SMatthew Dillon 	vnh = kmalloc(sizeof(struct vn_hdr) * vpcount, M_TEMP, M_WAITOK);
5640ba6fbbfSMatthew Dillon 	if ((error = read_check(fp, vnh, sizeof(struct vn_hdr)*vpcount)) != 0)
5650ba6fbbfSMatthew Dillon 		goto done;
5660ba6fbbfSMatthew Dillon 	for (i = 0; i < vpcount; i++) {
5670ba6fbbfSMatthew Dillon 		if ((error = mmap_vp(&vnh[i])) != 0)
5680ba6fbbfSMatthew Dillon 			goto done;
5690ba6fbbfSMatthew Dillon 	}
5700ba6fbbfSMatthew Dillon 
5710ba6fbbfSMatthew Dillon  done:
5720ba6fbbfSMatthew Dillon 	if (vnh)
573efda3bd0SMatthew Dillon 		kfree(vnh, M_TEMP);
5740ba6fbbfSMatthew Dillon 	TRACE_EXIT;
5750ba6fbbfSMatthew Dillon 	return error;
5760ba6fbbfSMatthew Dillon }
5770ba6fbbfSMatthew Dillon 
5780ba6fbbfSMatthew Dillon 
5790ba6fbbfSMatthew Dillon 
5800ba6fbbfSMatthew Dillon /* place holder */
5810ba6fbbfSMatthew Dillon static int
elf_getfiles(struct lwp * lp,struct file * fp)582f3a2d8c4SMatthew Dillon elf_getfiles(struct lwp *lp, struct file *fp)
5830ba6fbbfSMatthew Dillon {
5840ba6fbbfSMatthew Dillon 	int error;
5850ba6fbbfSMatthew Dillon 	int i;
5860ba6fbbfSMatthew Dillon 	int filecount;
5870ba6fbbfSMatthew Dillon 	int fd;
5880ba6fbbfSMatthew Dillon 	struct ckpt_filehdr filehdr;
5890ba6fbbfSMatthew Dillon 	struct ckpt_fileinfo *cfi_base = NULL;
590f3a2d8c4SMatthew Dillon 	struct filedesc *fdp = lp->lwp_proc->p_fd;
5910ba6fbbfSMatthew Dillon 	struct vnode *vp;
5920ba6fbbfSMatthew Dillon 	struct file *tempfp;
5930ba6fbbfSMatthew Dillon 	struct file *ofp;
5940ba6fbbfSMatthew Dillon 
5950ba6fbbfSMatthew Dillon 	TRACE_ENTER;
5960ba6fbbfSMatthew Dillon 	if ((error = read_check(fp, &filehdr, sizeof(filehdr))) != 0)
5970ba6fbbfSMatthew Dillon 		goto done;
5980ba6fbbfSMatthew Dillon 	filecount = filehdr.cfh_nfiles;
599efda3bd0SMatthew Dillon 	cfi_base = kmalloc(filecount*sizeof(struct ckpt_fileinfo), M_TEMP, M_WAITOK);
6000ba6fbbfSMatthew Dillon 	error = read_check(fp, cfi_base, filecount*sizeof(struct ckpt_fileinfo));
6010ba6fbbfSMatthew Dillon 	if (error)
6020ba6fbbfSMatthew Dillon 		goto done;
6030ba6fbbfSMatthew Dillon 
6040ba6fbbfSMatthew Dillon 	/*
6054f12bfd3SMatthew Dillon 	 * Close all file descriptors >= 3.  These descriptors are from the
6060ba6fbbfSMatthew Dillon 	 * checkpt(1) program itself and should not be retained.
6074f12bfd3SMatthew Dillon 	 *
6084f12bfd3SMatthew Dillon 	 * XXX we need a flag so a checkpoint restore can opt to supply the
6094f12bfd3SMatthew Dillon 	 * descriptors, or the non-regular-file descripors.
6100ba6fbbfSMatthew Dillon 	 */
611f3a2d8c4SMatthew Dillon 	for (i = 3; i < fdp->fd_nfiles; ++i)
6120ba6fbbfSMatthew Dillon 		kern_close(i);
6130ba6fbbfSMatthew Dillon 
6140ba6fbbfSMatthew Dillon 	/*
6150ba6fbbfSMatthew Dillon 	 * Scan files to load
6160ba6fbbfSMatthew Dillon 	 */
6170ba6fbbfSMatthew Dillon 	for (i = 0; i < filecount; i++) {
6180ba6fbbfSMatthew Dillon 		struct ckpt_fileinfo *cfi= &cfi_base[i];
6190ba6fbbfSMatthew Dillon 		/*
6200ba6fbbfSMatthew Dillon 		 * Ignore placeholder entries where cfi_index is less then
6210ba6fbbfSMatthew Dillon 		 * zero.  This will occur if the elf core dump code thinks
6220ba6fbbfSMatthew Dillon 		 * it can save a vnode but winds up not being able to.
6230ba6fbbfSMatthew Dillon 		 */
6240ba6fbbfSMatthew Dillon 		if (cfi->cfi_index < 0)
6250ba6fbbfSMatthew Dillon 			continue;
6260ba6fbbfSMatthew Dillon 
627ff7a3478SMatthew Dillon 		/*
628ff7a3478SMatthew Dillon 		 * Restore a saved file descriptor.  If CKFIF_ISCKPTFD is
629ff7a3478SMatthew Dillon 		 * set the descriptor represents the checkpoint file itself,
630ff7a3478SMatthew Dillon 		 * probably due to the user calling sys_checkpoint().  We
631ff7a3478SMatthew Dillon 		 * want to use the fp being used to restore the checkpoint
632ff7a3478SMatthew Dillon 		 * instead of trying to restore the original filehandle.
633ff7a3478SMatthew Dillon 		 */
634ff7a3478SMatthew Dillon 		if (cfi->cfi_ckflags & CKFIF_ISCKPTFD) {
635ff7a3478SMatthew Dillon 			fhold(fp);
636ff7a3478SMatthew Dillon 			tempfp = fp;
637ff7a3478SMatthew Dillon 			error = 0;
638ff7a3478SMatthew Dillon 		} else {
639ff7a3478SMatthew Dillon 			error = ckpt_fhtovp(&cfi->cfi_fh, &vp);
640ff7a3478SMatthew Dillon 			if (error == 0) {
641ff7a3478SMatthew Dillon 				error = fp_vpopen(vp, OFLAGS(cfi->cfi_flags),
642ff7a3478SMatthew Dillon 						  &tempfp);
643ff7a3478SMatthew Dillon 				if (error)
6440ba6fbbfSMatthew Dillon 					vput(vp);
6450ba6fbbfSMatthew Dillon 			}
646ff7a3478SMatthew Dillon 		}
647ff7a3478SMatthew Dillon 		if (error)
648ff7a3478SMatthew Dillon 			break;
6490ba6fbbfSMatthew Dillon 		tempfp->f_offset = cfi->cfi_offset;
6500ba6fbbfSMatthew Dillon 
6510ba6fbbfSMatthew Dillon 		/*
6520ba6fbbfSMatthew Dillon 		 * If overwriting a descriptor close the old descriptor.  This
6530ba6fbbfSMatthew Dillon 		 * only occurs if the saved core saved descriptors that we
6540ba6fbbfSMatthew Dillon 		 * have not already closed.
6550ba6fbbfSMatthew Dillon 		 */
656f3a2d8c4SMatthew Dillon 		if (cfi->cfi_index < fdp->fd_nfiles &&
657f3a2d8c4SMatthew Dillon 		    (ofp = fdp->fd_files[cfi->cfi_index].fp) != NULL) {
6580ba6fbbfSMatthew Dillon 			kern_close(cfi->cfi_index);
6590ba6fbbfSMatthew Dillon 		}
6600ba6fbbfSMatthew Dillon 
6610ba6fbbfSMatthew Dillon 		/*
6620ba6fbbfSMatthew Dillon 		 * Allocate the descriptor we want.
6630ba6fbbfSMatthew Dillon 		 */
664f3a2d8c4SMatthew Dillon 		if (fdalloc(lp->lwp_proc, cfi->cfi_index, &fd) != 0) {
6650ba6fbbfSMatthew Dillon 			PRINTF(("can't currently restore fd: %d\n",
6660ba6fbbfSMatthew Dillon 			       cfi->cfi_index));
6670ba6fbbfSMatthew Dillon 			fp_close(fp);
6680ba6fbbfSMatthew Dillon 			goto done;
6690ba6fbbfSMatthew Dillon 		}
6700ba6fbbfSMatthew Dillon 		KKASSERT(fd == cfi->cfi_index);
671f3a2d8c4SMatthew Dillon 		fsetfd(fdp, tempfp, fd);
672259b8ea0SMatthew Dillon 		fdrop(tempfp);
6730ba6fbbfSMatthew Dillon 		cfi++;
6740ba6fbbfSMatthew Dillon 		PRINTF(("restoring %d\n", cfi->cfi_index));
6750ba6fbbfSMatthew Dillon 	}
6760ba6fbbfSMatthew Dillon 
6770ba6fbbfSMatthew Dillon  done:
6780ba6fbbfSMatthew Dillon 	if (cfi_base)
679efda3bd0SMatthew Dillon 		kfree(cfi_base, M_TEMP);
6800ba6fbbfSMatthew Dillon 	TRACE_EXIT;
6810ba6fbbfSMatthew Dillon 	return error;
6820ba6fbbfSMatthew Dillon }
6830ba6fbbfSMatthew Dillon 
6840ba6fbbfSMatthew Dillon static int
ckpt_freeze_proc(struct lwp * lp,struct file * fp)6857d20a8ffSSimon Schubert ckpt_freeze_proc(struct lwp *lp, struct file *fp)
6860ba6fbbfSMatthew Dillon {
6877d20a8ffSSimon Schubert 	struct proc *p = lp->lwp_proc;
6880ba6fbbfSMatthew Dillon 	rlim_t limit;
6890ba6fbbfSMatthew Dillon 	int error;
6900ba6fbbfSMatthew Dillon 
6915686ec5aSMatthew Dillon 	lwkt_gettoken(&p->p_token);	/* needed for proc_*() calls */
69298c2b8acSMatthew Dillon 
6930ba6fbbfSMatthew Dillon         PRINTF(("calling generic_elf_coredump\n"));
6940ba6fbbfSMatthew Dillon 	limit = p->p_rlimit[RLIMIT_CORE].rlim_cur;
6950ba6fbbfSMatthew Dillon 	if (limit) {
696f5b92db7SMatthew Dillon 		if (p->p_stat != SCORE) {
697f5b92db7SMatthew Dillon 			proc_stop(p, SCORE);
6986acb4ed8SSimon Schubert 			while (p->p_nstopped < p->p_nthreads - 1)
6996acb4ed8SSimon Schubert 				tsleep(&p->p_nstopped, 0, "freeze", 1);
7007d20a8ffSSimon Schubert 			error = generic_elf_coredump(lp, SIGCKPT, fp, limit);
701f5b92db7SMatthew Dillon 			proc_unstop(p, SCORE);
702f5b92db7SMatthew Dillon 		} else {
703f5b92db7SMatthew Dillon 			error = ERANGE;
704f5b92db7SMatthew Dillon 		}
7050ba6fbbfSMatthew Dillon 	} else {
7060ba6fbbfSMatthew Dillon 		error = ERANGE;
7070ba6fbbfSMatthew Dillon 	}
7085686ec5aSMatthew Dillon 	lwkt_reltoken(&p->p_token);
7090ba6fbbfSMatthew Dillon 	return error;
7100ba6fbbfSMatthew Dillon }
7110ba6fbbfSMatthew Dillon 
7123919ced0SMatthew Dillon /*
7133919ced0SMatthew Dillon  * MPALMOSTSAFE
7143919ced0SMatthew Dillon  */
7150ba6fbbfSMatthew Dillon int
sys_sys_checkpoint(struct sysmsg * sysmsg,const struct sys_checkpoint_args * uap)716*80d831e1SMatthew Dillon sys_sys_checkpoint(struct sysmsg *sysmsg,
717*80d831e1SMatthew Dillon 		   const struct sys_checkpoint_args *uap)
7180ba6fbbfSMatthew Dillon {
7190ba6fbbfSMatthew Dillon         int error = 0;
7209910d07bSMatthew Dillon 	struct thread *td = curthread;
7219910d07bSMatthew Dillon 	struct proc *p = td->td_proc;
7220ba6fbbfSMatthew Dillon 	struct file *fp;
7230ba6fbbfSMatthew Dillon 
7240ba6fbbfSMatthew Dillon 	/*
7250ba6fbbfSMatthew Dillon 	 * Only certain groups (to reduce our security exposure).  -1
7260ba6fbbfSMatthew Dillon 	 * allows any group.
7270ba6fbbfSMatthew Dillon 	 */
7289910d07bSMatthew Dillon 	if (ckptgroup >= 0 && groupmember(ckptgroup, td->td_ucred) == 0)
7290ba6fbbfSMatthew Dillon 		return (EPERM);
7300ba6fbbfSMatthew Dillon 
7310ba6fbbfSMatthew Dillon 	/*
7320ba6fbbfSMatthew Dillon 	 * For now we can only checkpoint the current process
7330ba6fbbfSMatthew Dillon 	 */
7340ba6fbbfSMatthew Dillon 	if (uap->pid != -1 && uap->pid != p->p_pid)
7350ba6fbbfSMatthew Dillon 		return (EINVAL);
7360ba6fbbfSMatthew Dillon 
7373919ced0SMatthew Dillon 	get_mplock();
7383919ced0SMatthew Dillon 
7390ba6fbbfSMatthew Dillon 	switch (uap->type) {
7400ba6fbbfSMatthew Dillon 	case CKPT_FREEZE:
7410ba6fbbfSMatthew Dillon 		fp = NULL;
7420ba6fbbfSMatthew Dillon 		if (uap->fd == -1 && uap->pid == (pid_t)-1)
7439910d07bSMatthew Dillon 			error = checkpoint_signal_handler(td->td_lwp);
74435949930SMatthew Dillon 		else if ((fp = holdfp(td, uap->fd, FWRITE)) == NULL)
7450ba6fbbfSMatthew Dillon 			error = EBADF;
7460ba6fbbfSMatthew Dillon 		else
7479910d07bSMatthew Dillon 			error = ckpt_freeze_proc(td->td_lwp, fp);
7480ba6fbbfSMatthew Dillon 		if (fp)
74935949930SMatthew Dillon 			dropfp(td, uap->fd, fp);
7500ba6fbbfSMatthew Dillon 		break;
7510ba6fbbfSMatthew Dillon 	case CKPT_THAW:
7523919ced0SMatthew Dillon 		if (uap->pid != -1) {
7533919ced0SMatthew Dillon 			error = EINVAL;
7543919ced0SMatthew Dillon 			break;
7553919ced0SMatthew Dillon 		}
75635949930SMatthew Dillon 		if ((fp = holdfp(td, uap->fd, FREAD)) == NULL) {
7573919ced0SMatthew Dillon 			error = EBADF;
7583919ced0SMatthew Dillon 			break;
7593919ced0SMatthew Dillon 		}
760*80d831e1SMatthew Dillon 		sysmsg->sysmsg_result = uap->retval;
7619910d07bSMatthew Dillon 	        error = ckpt_thaw_proc(td->td_lwp, fp);
76235949930SMatthew Dillon 		dropfp(td, uap->fd, fp);
7630ba6fbbfSMatthew Dillon 		break;
7640ba6fbbfSMatthew Dillon 	default:
7650ba6fbbfSMatthew Dillon 	        error = EOPNOTSUPP;
7660ba6fbbfSMatthew Dillon 		break;
7670ba6fbbfSMatthew Dillon 	}
7683919ced0SMatthew Dillon 	rel_mplock();
7690ba6fbbfSMatthew Dillon 	return error;
7700ba6fbbfSMatthew Dillon }
7710ba6fbbfSMatthew Dillon 
7720ba6fbbfSMatthew Dillon int
checkpoint_signal_handler(struct lwp * lp)7737d20a8ffSSimon Schubert checkpoint_signal_handler(struct lwp *lp)
7740ba6fbbfSMatthew Dillon {
7759910d07bSMatthew Dillon 	struct thread *td = lp->lwp_thread;
7767d20a8ffSSimon Schubert 	struct proc *p = lp->lwp_proc;
7770ba6fbbfSMatthew Dillon 	char *buf;
7780ba6fbbfSMatthew Dillon 	struct file *fp;
7790ba6fbbfSMatthew Dillon 	struct nlookupdata nd;
7800ba6fbbfSMatthew Dillon 	int error;
7810ba6fbbfSMatthew Dillon 
7820ba6fbbfSMatthew Dillon 	chptinuse++;
7830ba6fbbfSMatthew Dillon 
7840ba6fbbfSMatthew Dillon 	/*
7850ba6fbbfSMatthew Dillon 	 * Being able to checkpoint an suid or sgid program is not a good
7860ba6fbbfSMatthew Dillon 	 * idea.
7870ba6fbbfSMatthew Dillon 	 */
7884643740aSMatthew Dillon 	if (sugid_coredump == 0 && (p->p_flags & P_SUGID)) {
7890ba6fbbfSMatthew Dillon 		chptinuse--;
7900ba6fbbfSMatthew Dillon 		return (EPERM);
7910ba6fbbfSMatthew Dillon 	}
7920ba6fbbfSMatthew Dillon 
7939910d07bSMatthew Dillon 	buf = ckpt_expand_name(p->p_comm, td->td_ucred->cr_uid, p->p_pid);
7940ba6fbbfSMatthew Dillon 	if (buf == NULL) {
7950ba6fbbfSMatthew Dillon 		chptinuse--;
7960ba6fbbfSMatthew Dillon 		return (ENOMEM);
7970ba6fbbfSMatthew Dillon 	}
7980ba6fbbfSMatthew Dillon 
7990ba6fbbfSMatthew Dillon 	log(LOG_INFO, "pid %d (%s), uid %d: checkpointing to %s\n",
8000ba6fbbfSMatthew Dillon 		p->p_pid, p->p_comm,
8019910d07bSMatthew Dillon 		(td->td_ucred ? td->td_ucred->cr_uid : -1),
8020ba6fbbfSMatthew Dillon 		buf);
8030ba6fbbfSMatthew Dillon 
8040ba6fbbfSMatthew Dillon 	PRINTF(("ckpt handler called, using '%s'\n", buf));
8050ba6fbbfSMatthew Dillon 
8060ba6fbbfSMatthew Dillon 	/*
8070ba6fbbfSMatthew Dillon 	 * Use the same safety flags that the coredump code uses.  Remove
8080ba6fbbfSMatthew Dillon 	 * any previous checkpoint file before writing out the new one in
8090ba6fbbfSMatthew Dillon 	 * case we are re-checkpointing a program that had been checkpt
8100ba6fbbfSMatthew Dillon 	 * restored.  Otherwise we will corrupt the program space (which is
8110ba6fbbfSMatthew Dillon 	 * made up of mmap()ings of the previous checkpoint file) while we
8120ba6fbbfSMatthew Dillon 	 * write out the new one.
8130ba6fbbfSMatthew Dillon 	 */
8140ba6fbbfSMatthew Dillon 	error = nlookup_init(&nd, buf, UIO_SYSSPACE, 0);
8150ba6fbbfSMatthew Dillon 	if (error == 0)
8160ba6fbbfSMatthew Dillon 		error = kern_unlink(&nd);
8170ba6fbbfSMatthew Dillon 	nlookup_done(&nd);
8180ba6fbbfSMatthew Dillon 	error = fp_open(buf, O_WRONLY|O_CREAT|O_TRUNC|O_NOFOLLOW, 0600, &fp);
8190ba6fbbfSMatthew Dillon 	if (error == 0) {
8207d20a8ffSSimon Schubert 		error = ckpt_freeze_proc(lp, fp);
8210ba6fbbfSMatthew Dillon 		fp_close(fp);
8220ba6fbbfSMatthew Dillon 	} else {
8236ea70f76SSascha Wildner 		kprintf("checkpoint failed with open - error: %d\n", error);
8240ba6fbbfSMatthew Dillon 	}
825efda3bd0SMatthew Dillon 	kfree(buf, M_TEMP);
8260ba6fbbfSMatthew Dillon 	chptinuse--;
8270ba6fbbfSMatthew Dillon 	return (error);
8280ba6fbbfSMatthew Dillon }
8290ba6fbbfSMatthew Dillon 
8300ba6fbbfSMatthew Dillon static char ckptfilename[MAXPATHLEN] = {"%N.ckpt"};
8310ba6fbbfSMatthew Dillon SYSCTL_STRING(_kern, OID_AUTO, ckptfile, CTLFLAG_RW, ckptfilename,
8320ba6fbbfSMatthew Dillon 	      sizeof(ckptfilename), "process checkpoint name format string");
8330ba6fbbfSMatthew Dillon 
8340ba6fbbfSMatthew Dillon /*
8350ba6fbbfSMatthew Dillon  * expand_name(name, uid, pid)
8360ba6fbbfSMatthew Dillon  * Expand the name described in corefilename, using name, uid, and pid.
8376ea70f76SSascha Wildner  * corefilename is a kprintf-like string, with three format specifiers:
8380ba6fbbfSMatthew Dillon  *	%N	name of process ("name")
8390ba6fbbfSMatthew Dillon  *	%P	process id (pid)
8400ba6fbbfSMatthew Dillon  *	%U	user id (uid)
8410ba6fbbfSMatthew Dillon  * For example, "%N.core" is the default; they can be disabled completely
8420ba6fbbfSMatthew Dillon  * by using "/dev/null", or all core files can be stored in "/cores/%U/%N-%P".
8430ba6fbbfSMatthew Dillon  * This is controlled by the sysctl variable kern.corefile (see above).
8440ba6fbbfSMatthew Dillon  *
8450ba6fbbfSMatthew Dillon  * -- taken from the coredump code
8460ba6fbbfSMatthew Dillon  */
8470ba6fbbfSMatthew Dillon 
8480ba6fbbfSMatthew Dillon static
8490ba6fbbfSMatthew Dillon char *
ckpt_expand_name(const char * name,uid_t uid,pid_t pid)8500ba6fbbfSMatthew Dillon ckpt_expand_name(const char *name, uid_t uid, pid_t pid)
8510ba6fbbfSMatthew Dillon {
8520ba6fbbfSMatthew Dillon 	char *temp;
8530ba6fbbfSMatthew Dillon 	char *bp;
8540ba6fbbfSMatthew Dillon 	char buf[11];		/* Buffer for pid/uid -- max 4B */
8550ba6fbbfSMatthew Dillon 	int error;
8560ba6fbbfSMatthew Dillon 	int i;
8570ba6fbbfSMatthew Dillon 	int n;
8580ba6fbbfSMatthew Dillon 	char *format = ckptfilename;
8590ba6fbbfSMatthew Dillon 	size_t namelen;
8600ba6fbbfSMatthew Dillon 
861efda3bd0SMatthew Dillon 	temp = kmalloc(MAXPATHLEN + 1, M_TEMP, M_NOWAIT);
8620ba6fbbfSMatthew Dillon 	if (temp == NULL)
8630ba6fbbfSMatthew Dillon 		return NULL;
8640ba6fbbfSMatthew Dillon 	namelen = strlen(name);
8650ba6fbbfSMatthew Dillon 	n = 0;
8660ba6fbbfSMatthew Dillon 	if (ckptfilename[0] != '/') {
8670ba6fbbfSMatthew Dillon 		if ((bp = kern_getcwd(temp, MAXPATHLEN - 1, &error)) == NULL) {
868efda3bd0SMatthew Dillon 			kfree(temp, M_TEMP);
8690ba6fbbfSMatthew Dillon 			return NULL;
8700ba6fbbfSMatthew Dillon 		}
8710ba6fbbfSMatthew Dillon 		n = strlen(bp);
8720ba6fbbfSMatthew Dillon 		bcopy(bp, temp, n + 1);	/* normalize location of the path */
8730ba6fbbfSMatthew Dillon 		temp[n++] = '/';
8740ba6fbbfSMatthew Dillon 		temp[n] = '\0';
8750ba6fbbfSMatthew Dillon 	}
8760ba6fbbfSMatthew Dillon 	for (i= 0; n < MAXPATHLEN && format[i]; i++) {
8770ba6fbbfSMatthew Dillon 		int l;
8780ba6fbbfSMatthew Dillon 		switch (format[i]) {
8790ba6fbbfSMatthew Dillon 		case '%':	/* Format character */
8800ba6fbbfSMatthew Dillon 			i++;
8810ba6fbbfSMatthew Dillon 			switch (format[i]) {
8820ba6fbbfSMatthew Dillon 			case '%':
8830ba6fbbfSMatthew Dillon 				temp[n++] = '%';
8840ba6fbbfSMatthew Dillon 				break;
8850ba6fbbfSMatthew Dillon 			case 'N':	/* process name */
8860ba6fbbfSMatthew Dillon 				if ((n + namelen) > MAXPATHLEN) {
8870ba6fbbfSMatthew Dillon 					log(LOG_ERR, "pid %d (%s), uid (%u):  Path `%s%s' is too long\n",
8880ba6fbbfSMatthew Dillon 					    pid, name, uid, temp, name);
889efda3bd0SMatthew Dillon 					kfree(temp, M_TEMP);
8900ba6fbbfSMatthew Dillon 					return NULL;
8910ba6fbbfSMatthew Dillon 				}
8920ba6fbbfSMatthew Dillon 				memcpy(temp+n, name, namelen);
8930ba6fbbfSMatthew Dillon 				n += namelen;
8940ba6fbbfSMatthew Dillon 				break;
8950ba6fbbfSMatthew Dillon 			case 'P':	/* process id */
896f8c7a42dSMatthew Dillon 				l = ksprintf(buf, "%u", pid);
8970ba6fbbfSMatthew Dillon 				if ((n + l) > MAXPATHLEN) {
8980ba6fbbfSMatthew Dillon 					log(LOG_ERR, "pid %d (%s), uid (%u):  Path `%s%s' is too long\n",
8990ba6fbbfSMatthew Dillon 					    pid, name, uid, temp, name);
900efda3bd0SMatthew Dillon 					kfree(temp, M_TEMP);
9010ba6fbbfSMatthew Dillon 					return NULL;
9020ba6fbbfSMatthew Dillon 				}
9030ba6fbbfSMatthew Dillon 				memcpy(temp+n, buf, l);
9040ba6fbbfSMatthew Dillon 				n += l;
9050ba6fbbfSMatthew Dillon 				break;
9060ba6fbbfSMatthew Dillon 			case 'U':	/* user id */
907f8c7a42dSMatthew Dillon 				l = ksprintf(buf, "%u", uid);
9080ba6fbbfSMatthew Dillon 				if ((n + l) > MAXPATHLEN) {
9090ba6fbbfSMatthew Dillon 					log(LOG_ERR, "pid %d (%s), uid (%u):  Path `%s%s' is too long\n",
9100ba6fbbfSMatthew Dillon 					    pid, name, uid, temp, name);
911efda3bd0SMatthew Dillon 					kfree(temp, M_TEMP);
9120ba6fbbfSMatthew Dillon 					return NULL;
9130ba6fbbfSMatthew Dillon 				}
9140ba6fbbfSMatthew Dillon 				memcpy(temp+n, buf, l);
9150ba6fbbfSMatthew Dillon 				n += l;
9160ba6fbbfSMatthew Dillon 				break;
9170ba6fbbfSMatthew Dillon 			default:
9180ba6fbbfSMatthew Dillon 			  	log(LOG_ERR, "Unknown format character %c in `%s'\n", format[i], format);
9190ba6fbbfSMatthew Dillon 			}
9200ba6fbbfSMatthew Dillon 			break;
9210ba6fbbfSMatthew Dillon 		default:
9220ba6fbbfSMatthew Dillon 			temp[n++] = format[i];
9230ba6fbbfSMatthew Dillon 		}
9240ba6fbbfSMatthew Dillon 	}
9250ba6fbbfSMatthew Dillon 	temp[n] = '\0';
9260ba6fbbfSMatthew Dillon 	return temp;
9270ba6fbbfSMatthew Dillon }
9280ba6fbbfSMatthew Dillon 
929