From owner-svn-src-projects@FreeBSD.ORG Tue Mar 29 00:47:01 2011 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 81453106566B; Tue, 29 Mar 2011 00:47:01 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6CBC28FC12; Tue, 29 Mar 2011 00:47:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2T0l11k011743; Tue, 29 Mar 2011 00:47:01 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2T0l1Mx011714; Tue, 29 Mar 2011 00:47:01 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201103290047.p2T0l1Mx011714@svn.freebsd.org> From: Marcel Moolenaar Date: Tue, 29 Mar 2011 00:47:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220120 - in projects/altix/sys: amd64/amd64 amd64/include amd64/linux32 boot/pc98/boot2 cddl/contrib/opensolaris/uts/common/fs/zfs compat/freebsd32 compat/linprocfs compat/linux conf d... X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 00:47:01 -0000 Author: marcel Date: Tue Mar 29 00:47:00 2011 New Revision: 220120 URL: http://svn.freebsd.org/changeset/base/220120 Log: Merge svn+ssh://svn.freebsd.org/base/head@220114 Added: projects/altix/sys/geom/raid/ - copied from r220114, head/sys/geom/raid/ projects/altix/sys/modules/geom/geom_raid/ - copied from r220114, head/sys/modules/geom/geom_raid/ Modified: projects/altix/sys/amd64/amd64/identcpu.c projects/altix/sys/amd64/amd64/initcpu.c projects/altix/sys/amd64/amd64/machdep.c projects/altix/sys/amd64/amd64/minidump_machdep.c projects/altix/sys/amd64/amd64/mp_machdep.c projects/altix/sys/amd64/include/pmap.h projects/altix/sys/amd64/include/smp.h projects/altix/sys/amd64/linux32/linux.h projects/altix/sys/amd64/linux32/linux32_dummy.c projects/altix/sys/amd64/linux32/linux32_proto.h projects/altix/sys/amd64/linux32/linux32_syscall.h projects/altix/sys/amd64/linux32/linux32_syscalls.c projects/altix/sys/amd64/linux32/linux32_sysent.c projects/altix/sys/amd64/linux32/linux32_systrace_args.c projects/altix/sys/amd64/linux32/linux32_sysvec.c projects/altix/sys/amd64/linux32/syscalls.master projects/altix/sys/boot/pc98/boot2/boot2.c projects/altix/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c projects/altix/sys/compat/freebsd32/freebsd32_ioctl.c projects/altix/sys/compat/freebsd32/freebsd32_ioctl.h projects/altix/sys/compat/linprocfs/linprocfs.c projects/altix/sys/compat/linux/linux_misc.c projects/altix/sys/compat/linux/linux_misc.h projects/altix/sys/compat/linux/linux_socket.c projects/altix/sys/compat/linux/linux_socket.h projects/altix/sys/conf/NOTES projects/altix/sys/conf/files projects/altix/sys/conf/files.sparc64 projects/altix/sys/conf/files.sun4v projects/altix/sys/conf/ldscript.amd64 projects/altix/sys/conf/options projects/altix/sys/dev/ae/if_ae.c projects/altix/sys/dev/age/if_age.c projects/altix/sys/dev/agp/agp.c projects/altix/sys/dev/aic7xxx/aic79xx_pci.c projects/altix/sys/dev/alc/if_alc.c projects/altix/sys/dev/ale/if_ale.c projects/altix/sys/dev/ath/ah_osdep.c projects/altix/sys/dev/ath/ath_hal/ah.c projects/altix/sys/dev/ath/ath_hal/ah.h projects/altix/sys/dev/ath/ath_hal/ah_eeprom_v14.h projects/altix/sys/dev/ath/ath_hal/ah_internal.h projects/altix/sys/dev/ath/ath_hal/ar5416/ar2133.c projects/altix/sys/dev/ath/ath_hal/ar5416/ar5416.h projects/altix/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c projects/altix/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c projects/altix/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c projects/altix/sys/dev/ath/ath_hal/ar5416/ar5416_interrupts.c projects/altix/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c projects/altix/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c projects/altix/sys/dev/ath/ath_hal/ar5416/ar5416reg.h projects/altix/sys/dev/ath/ath_hal/ar9001/ar9160_attach.c projects/altix/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c projects/altix/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c projects/altix/sys/dev/ath/ath_rate/sample/sample.c projects/altix/sys/dev/ath/if_ath.c projects/altix/sys/dev/ath/if_ath_tx.c projects/altix/sys/dev/ath/if_ath_tx_ht.c projects/altix/sys/dev/ath/if_athvar.h projects/altix/sys/dev/bce/if_bce.c projects/altix/sys/dev/bge/if_bge.c projects/altix/sys/dev/bwn/if_bwn.c projects/altix/sys/dev/bxe/if_bxe.c projects/altix/sys/dev/cxgb/common/cxgb_common.h projects/altix/sys/dev/cxgb/common/cxgb_t3_hw.c projects/altix/sys/dev/cxgb/cxgb_adapter.h projects/altix/sys/dev/cxgb/cxgb_main.c projects/altix/sys/dev/cxgb/cxgb_sge.c projects/altix/sys/dev/cxgb/cxgb_t3fw.h projects/altix/sys/dev/cxgbe/adapter.h projects/altix/sys/dev/cxgbe/t4_main.c projects/altix/sys/dev/cxgbe/t4_sge.c projects/altix/sys/dev/dc/if_dc.c projects/altix/sys/dev/drm/drm_agpsupport.c projects/altix/sys/dev/e1000/e1000_osdep.c projects/altix/sys/dev/e1000/if_em.c projects/altix/sys/dev/e1000/if_lem.c projects/altix/sys/dev/et/if_et.c projects/altix/sys/dev/fxp/if_fxp.c projects/altix/sys/dev/iwn/if_iwn.c projects/altix/sys/dev/ixgbe/ixv.c projects/altix/sys/dev/jme/if_jme.c projects/altix/sys/dev/ksyms/ksyms.c projects/altix/sys/dev/led/led.c projects/altix/sys/dev/led/led.h projects/altix/sys/dev/malo/if_malo_pci.c projects/altix/sys/dev/msk/if_msk.c projects/altix/sys/dev/mvs/mvs_soc.c projects/altix/sys/dev/mxge/if_mxge.c projects/altix/sys/dev/nfe/if_nfe.c projects/altix/sys/dev/nge/if_nge.c projects/altix/sys/dev/pci/hostb_pci.c projects/altix/sys/dev/pci/pci.c projects/altix/sys/dev/pci/pcivar.h projects/altix/sys/dev/re/if_re.c projects/altix/sys/dev/siba/siba_core.c projects/altix/sys/dev/sis/if_sis.c projects/altix/sys/dev/ste/if_ste.c projects/altix/sys/dev/txp/if_txp.c projects/altix/sys/dev/usb/controller/ehci.c projects/altix/sys/dev/usb/input/ums.c projects/altix/sys/dev/usb/wlan/if_zyd.c projects/altix/sys/dev/vge/if_vge.c projects/altix/sys/dev/vr/if_vr.c projects/altix/sys/dev/vte/if_vtevar.h projects/altix/sys/dev/xl/if_xl.c projects/altix/sys/fs/msdosfs/msdosfs_lookup.c projects/altix/sys/fs/nfsclient/nfs_clport.c projects/altix/sys/geom/gate/g_gate.c projects/altix/sys/geom/gate/g_gate.h projects/altix/sys/geom/geom.h projects/altix/sys/geom/geom_dev.c projects/altix/sys/geom/geom_disk.c projects/altix/sys/i386/i386/identcpu.c projects/altix/sys/i386/i386/initcpu.c projects/altix/sys/i386/include/vmparam.h projects/altix/sys/i386/linux/linux.h projects/altix/sys/i386/linux/linux_dummy.c projects/altix/sys/i386/linux/linux_proto.h projects/altix/sys/i386/linux/linux_syscall.h projects/altix/sys/i386/linux/linux_syscalls.c projects/altix/sys/i386/linux/linux_sysent.c projects/altix/sys/i386/linux/linux_systrace_args.c projects/altix/sys/i386/linux/linux_sysvec.c projects/altix/sys/i386/linux/syscalls.master projects/altix/sys/ia64/include/pmap.h projects/altix/sys/kern/kern_descrip.c projects/altix/sys/kern/kern_fork.c projects/altix/sys/kern/kern_malloc.c projects/altix/sys/kern/kern_proc.c projects/altix/sys/kern/kern_resource.c projects/altix/sys/kern/kern_sig.c projects/altix/sys/kern/kern_thread.c projects/altix/sys/kern/subr_acl_nfs4.c projects/altix/sys/kern/subr_param.c projects/altix/sys/kern/subr_uio.c projects/altix/sys/kern/vfs_mount.c projects/altix/sys/kern/vfs_syscalls.c projects/altix/sys/mips/atheros/ar71xx_ehci.c projects/altix/sys/mips/atheros/ar71xx_machdep.c projects/altix/sys/modules/Makefile projects/altix/sys/modules/geom/Makefile projects/altix/sys/net80211/ieee80211_proto.c projects/altix/sys/netinet/tcp_sack.c projects/altix/sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c projects/altix/sys/ofed/drivers/net/mlx4/en_cq.c projects/altix/sys/ofed/drivers/net/mlx4/en_ethtool.c projects/altix/sys/ofed/drivers/net/mlx4/en_main.c projects/altix/sys/ofed/drivers/net/mlx4/en_netdev.c projects/altix/sys/ofed/drivers/net/mlx4/en_port.c projects/altix/sys/ofed/drivers/net/mlx4/en_rx.c projects/altix/sys/ofed/drivers/net/mlx4/fw.c projects/altix/sys/ofed/drivers/net/mlx4/fw.h projects/altix/sys/ofed/drivers/net/mlx4/main.c projects/altix/sys/ofed/drivers/net/mlx4/mlx4_en.h projects/altix/sys/ofed/include/linux/gfp.h projects/altix/sys/ofed/include/linux/mlx4/device.h projects/altix/sys/ofed/include/linux/pci.h projects/altix/sys/ofed/include/linux/scatterlist.h projects/altix/sys/ofed/include/rdma/ib_addr.h projects/altix/sys/pci/if_rl.c projects/altix/sys/sparc64/pci/ofw_pci.h projects/altix/sys/sparc64/pci/ofw_pci_if.m projects/altix/sys/sparc64/pci/ofw_pcibus.c projects/altix/sys/sparc64/pci/psycho.c projects/altix/sys/sparc64/pci/psychovar.h projects/altix/sys/sparc64/pci/schizo.c projects/altix/sys/sparc64/pci/schizoreg.h projects/altix/sys/sparc64/pci/schizovar.h projects/altix/sys/sys/acl.h projects/altix/sys/sys/fcntl.h projects/altix/sys/sys/filedesc.h projects/altix/sys/sys/proc.h projects/altix/sys/sys/systm.h projects/altix/sys/sys/uio.h projects/altix/sys/ufs/ffs/ffs_alloc.c projects/altix/sys/ufs/ffs/ffs_extern.h projects/altix/sys/ufs/ffs/ffs_softdep.c projects/altix/sys/vm/vm_fault.c projects/altix/sys/vm/vm_meter.c projects/altix/sys/vm/vm_pageout.c Directory Properties: projects/altix/lib/libstand/ (props changed) projects/altix/sys/ (props changed) projects/altix/sys/amd64/include/xen/ (props changed) projects/altix/sys/boot/i386/efi/ (props changed) projects/altix/sys/boot/ia64/efi/ (props changed) projects/altix/sys/boot/ia64/ski/ (props changed) projects/altix/sys/boot/powerpc/boot1.chrp/ (props changed) projects/altix/sys/boot/powerpc/ofw/ (props changed) projects/altix/sys/cddl/contrib/opensolaris/ (props changed) projects/altix/sys/conf/ (props changed) projects/altix/sys/contrib/dev/acpica/ (props changed) projects/altix/sys/contrib/octeon-sdk/ (props changed) projects/altix/sys/contrib/pf/ (props changed) projects/altix/sys/contrib/x86emu/ (props changed) projects/altix/sys/kern/subr_busdma.c (props changed) Modified: projects/altix/sys/amd64/amd64/identcpu.c ============================================================================== --- projects/altix/sys/amd64/amd64/identcpu.c Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/amd64/amd64/identcpu.c Tue Mar 29 00:47:00 2011 (r220120) @@ -385,7 +385,7 @@ printcpuinfo(void) ); } - if (cpu_vendor_id == CPU_VENDOR_CENTAUR) + if (via_feature_rng != 0 || via_feature_xcrypt != 0) print_via_padlock_info(); if ((cpu_feature & CPUID_HTT) && @@ -643,25 +643,7 @@ print_via_padlock_info(void) { u_int regs[4]; - /* Check for supported models. */ - switch (cpu_id & 0xff0) { - case 0x690: - if ((cpu_id & 0xf) < 3) - return; - case 0x6a0: - case 0x6d0: - case 0x6f0: - break; - default: - return; - } - - do_cpuid(0xc0000000, regs); - if (regs[0] >= 0xc0000001) - do_cpuid(0xc0000001, regs); - else - return; - + do_cpuid(0xc0000001, regs); printf("\n VIA Padlock Features=0x%b", regs[3], "\020" "\003RNG" /* RNG */ Modified: projects/altix/sys/amd64/amd64/initcpu.c ============================================================================== --- projects/altix/sys/amd64/amd64/initcpu.c Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/amd64/amd64/initcpu.c Tue Mar 29 00:47:00 2011 (r220120) @@ -74,72 +74,47 @@ u_int cpu_mxcsr_mask; /* Valid bits in u_int cpu_clflush_line_size = 32; SYSCTL_UINT(_hw, OID_AUTO, via_feature_rng, CTLFLAG_RD, - &via_feature_rng, 0, "VIA C3/C7 RNG feature available in CPU"); + &via_feature_rng, 0, "VIA RNG feature available in CPU"); SYSCTL_UINT(_hw, OID_AUTO, via_feature_xcrypt, CTLFLAG_RD, - &via_feature_xcrypt, 0, "VIA C3/C7 xcrypt feature available in CPU"); + &via_feature_xcrypt, 0, "VIA xcrypt feature available in CPU"); /* - * Initialize special VIA C3/C7 features + * Initialize special VIA features */ static void init_via(void) { u_int regs[4], val; - u_int64_t msreg; + /* + * Check extended CPUID for PadLock features. + * + * http://www.via.com.tw/en/downloads/whitepapers/initiatives/padlock/programming_guide.pdf + */ do_cpuid(0xc0000000, regs); - val = regs[0]; - if (val >= 0xc0000001) { + if (regs[0] >= 0xc0000001) { do_cpuid(0xc0000001, regs); val = regs[3]; } else - val = 0; + return; - /* Enable RNG if present and disabled */ - if (val & VIA_CPUID_HAS_RNG) { - if (!(val & VIA_CPUID_DO_RNG)) { - msreg = rdmsr(0x110B); - msreg |= 0x40; - wrmsr(0x110B, msreg); - } + /* Enable RNG if present. */ + if ((val & VIA_CPUID_HAS_RNG) != 0) { via_feature_rng = VIA_HAS_RNG; + wrmsr(0x110B, rdmsr(0x110B) | VIA_CPUID_DO_RNG); } - /* Enable AES engine if present and disabled */ - if (val & VIA_CPUID_HAS_ACE) { - if (!(val & VIA_CPUID_DO_ACE)) { - msreg = rdmsr(0x1107); - msreg |= (0x01 << 28); - wrmsr(0x1107, msreg); - } + + /* Enable PadLock if present. */ + if ((val & VIA_CPUID_HAS_ACE) != 0) via_feature_xcrypt |= VIA_HAS_AES; - } - /* Enable ACE2 engine if present and disabled */ - if (val & VIA_CPUID_HAS_ACE2) { - if (!(val & VIA_CPUID_DO_ACE2)) { - msreg = rdmsr(0x1107); - msreg |= (0x01 << 28); - wrmsr(0x1107, msreg); - } + if ((val & VIA_CPUID_HAS_ACE2) != 0) via_feature_xcrypt |= VIA_HAS_AESCTR; - } - /* Enable SHA engine if present and disabled */ - if (val & VIA_CPUID_HAS_PHE) { - if (!(val & VIA_CPUID_DO_PHE)) { - msreg = rdmsr(0x1107); - msreg |= (0x01 << 28/**/); - wrmsr(0x1107, msreg); - } + if ((val & VIA_CPUID_HAS_PHE) != 0) via_feature_xcrypt |= VIA_HAS_SHA; - } - /* Enable MM engine if present and disabled */ - if (val & VIA_CPUID_HAS_PMM) { - if (!(val & VIA_CPUID_DO_PMM)) { - msreg = rdmsr(0x1107); - msreg |= (0x01 << 28/**/); - wrmsr(0x1107, msreg); - } + if ((val & VIA_CPUID_HAS_PMM) != 0) via_feature_xcrypt |= VIA_HAS_MM; - } + if (via_feature_xcrypt != 0) + wrmsr(0x1107, rdmsr(0x1107) | (1 << 28)); } /* @@ -159,9 +134,7 @@ initializecpu(void) wrmsr(MSR_EFER, msr); pg_nx = PG_NX; } - if (cpu_vendor_id == CPU_VENDOR_CENTAUR && - CPUID_TO_FAMILY(cpu_id) == 0x6 && - CPUID_TO_MODEL(cpu_id) >= 0xf) + if (cpu_vendor_id == CPU_VENDOR_CENTAUR) init_via(); } Modified: projects/altix/sys/amd64/amd64/machdep.c ============================================================================== --- projects/altix/sys/amd64/amd64/machdep.c Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/amd64/amd64/machdep.c Tue Mar 29 00:47:00 2011 (r220120) @@ -156,6 +156,11 @@ static void get_fpcontext(struct thread static int set_fpcontext(struct thread *td, const mcontext_t *mcp); SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL); +/* + * The file "conf/ldscript.amd64" defines the symbol "kernphys". Its value is + * the physical address at which the kernel is loaded. + */ +extern char kernphys[]; #ifdef DDB extern vm_offset_t ksym_start, ksym_end; #endif @@ -1417,7 +1422,7 @@ getmemsize(caddr_t kmdp, u_int64_t first /* * block out kernel memory as not available. */ - if (pa >= 0x100000 && pa < first) + if (pa >= (vm_paddr_t)kernphys && pa < first) goto do_dump_avail; /* Modified: projects/altix/sys/amd64/amd64/minidump_machdep.c ============================================================================== --- projects/altix/sys/amd64/amd64/minidump_machdep.c Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/amd64/amd64/minidump_machdep.c Tue Mar 29 00:47:00 2011 (r220120) @@ -53,8 +53,6 @@ CTASSERT(sizeof(struct kerneldumpheader) #define MD_ALIGN(x) (((off_t)(x) + PAGE_MASK) & ~PAGE_MASK) #define DEV_ALIGN(x) (((off_t)(x) + (DEV_BSIZE-1)) & ~(DEV_BSIZE-1)) -extern uint64_t KPDPphys; - uint64_t *vm_page_dump; int vm_page_dump_size; Modified: projects/altix/sys/amd64/amd64/mp_machdep.c ============================================================================== --- projects/altix/sys/amd64/amd64/mp_machdep.c Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/amd64/amd64/mp_machdep.c Tue Mar 29 00:47:00 2011 (r220120) @@ -116,7 +116,6 @@ u_long *ipi_invlrng_counts[MAXCPU]; u_long *ipi_invlpg_counts[MAXCPU]; u_long *ipi_invlcache_counts[MAXCPU]; u_long *ipi_rendezvous_counts[MAXCPU]; -u_long *ipi_lazypmap_counts[MAXCPU]; static u_long *ipi_hardclock_counts[MAXCPU]; #endif @@ -1620,8 +1619,6 @@ mp_ipi_intrcnt(void *dummy) intrcnt_add(buf, &ipi_ast_counts[i]); snprintf(buf, sizeof(buf), "cpu%d:rendezvous", i); intrcnt_add(buf, &ipi_rendezvous_counts[i]); - snprintf(buf, sizeof(buf), "cpu%d:lazypmap", i); - intrcnt_add(buf, &ipi_lazypmap_counts[i]); snprintf(buf, sizeof(buf), "cpu%d:hardclock", i); intrcnt_add(buf, &ipi_hardclock_counts[i]); } Modified: projects/altix/sys/amd64/include/pmap.h ============================================================================== --- projects/altix/sys/amd64/include/pmap.h Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/amd64/include/pmap.h Tue Mar 29 00:47:00 2011 (r220120) @@ -180,6 +180,7 @@ typedef u_int64_t pml4_entry_t; #define PML4map ((pd_entry_t *)(addr_PML4map)) #define PML4pml4e ((pd_entry_t *)(addr_PML4pml4e)) +extern u_int64_t KPDPphys; /* physical address of kernel level 3 */ extern u_int64_t KPML4phys; /* physical address of kernel level 4 */ /* Modified: projects/altix/sys/amd64/include/smp.h ============================================================================== --- projects/altix/sys/amd64/include/smp.h Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/amd64/include/smp.h Tue Mar 29 00:47:00 2011 (r220120) @@ -41,7 +41,6 @@ extern u_long *ipi_invlrng_counts[MAXCPU extern u_long *ipi_invlpg_counts[MAXCPU]; extern u_long *ipi_invlcache_counts[MAXCPU]; extern u_long *ipi_rendezvous_counts[MAXCPU]; -extern u_long *ipi_lazypmap_counts[MAXCPU]; #endif /* IPI handlers */ Modified: projects/altix/sys/amd64/linux32/linux.h ============================================================================== --- projects/altix/sys/amd64/linux32/linux.h Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/amd64/linux32/linux.h Tue Mar 29 00:47:00 2011 (r220120) @@ -695,6 +695,7 @@ union l_semun { #define LINUX_SO_NO_CHECK 11 #define LINUX_SO_PRIORITY 12 #define LINUX_SO_LINGER 13 +#define LINUX_SO_PASSCRED 16 #define LINUX_SO_PEERCRED 17 #define LINUX_SO_RCVLOWAT 18 #define LINUX_SO_SNDLOWAT 19 Modified: projects/altix/sys/amd64/linux32/linux32_dummy.c ============================================================================== --- projects/altix/sys/amd64/linux32/linux32_dummy.c Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/amd64/linux32/linux32_dummy.c Tue Mar 29 00:47:00 2011 (r220120) @@ -54,8 +54,6 @@ DUMMY(sysfs); DUMMY(query_module); DUMMY(nfsservctl); DUMMY(rt_sigqueueinfo); -DUMMY(capget); -DUMMY(capset); DUMMY(sendfile); DUMMY(setfsuid); DUMMY(setfsgid); Modified: projects/altix/sys/amd64/linux32/linux32_proto.h ============================================================================== --- projects/altix/sys/amd64/linux32/linux32_proto.h Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/amd64/linux32/linux32_proto.h Tue Mar 29 00:47:00 2011 (r220120) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 219559 2011-03-12 08:51:43Z avg + * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 220028 2011-03-26 10:51:56Z avg */ #ifndef _LINUX_SYSPROTO_H_ @@ -589,10 +589,12 @@ struct linux_getcwd_args { char bufsize_l_[PADL_(l_ulong)]; l_ulong bufsize; char bufsize_r_[PADR_(l_ulong)]; }; struct linux_capget_args { - register_t dummy; + char hdrp_l_[PADL_(struct l_user_cap_header *)]; struct l_user_cap_header * hdrp; char hdrp_r_[PADR_(struct l_user_cap_header *)]; + char datap_l_[PADL_(struct l_user_cap_data *)]; struct l_user_cap_data * datap; char datap_r_[PADR_(struct l_user_cap_data *)]; }; struct linux_capset_args { - register_t dummy; + char hdrp_l_[PADL_(struct l_user_cap_header *)]; struct l_user_cap_header * hdrp; char hdrp_r_[PADR_(struct l_user_cap_header *)]; + char datap_l_[PADL_(struct l_user_cap_data *)]; struct l_user_cap_data * datap; char datap_r_[PADR_(struct l_user_cap_data *)]; }; struct linux_sigaltstack_args { char uss_l_[PADL_(l_stack_t *)]; l_stack_t * uss; char uss_r_[PADR_(l_stack_t *)]; Modified: projects/altix/sys/amd64/linux32/linux32_syscall.h ============================================================================== --- projects/altix/sys/amd64/linux32/linux32_syscall.h Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/amd64/linux32/linux32_syscall.h Tue Mar 29 00:47:00 2011 (r220120) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 219559 2011-03-12 08:51:43Z avg + * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 220028 2011-03-26 10:51:56Z avg */ #define LINUX_SYS_exit 1 Modified: projects/altix/sys/amd64/linux32/linux32_syscalls.c ============================================================================== --- projects/altix/sys/amd64/linux32/linux32_syscalls.c Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/amd64/linux32/linux32_syscalls.c Tue Mar 29 00:47:00 2011 (r220120) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 219559 2011-03-12 08:51:43Z avg + * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 220028 2011-03-26 10:51:56Z avg */ const char *linux_syscallnames[] = { Modified: projects/altix/sys/amd64/linux32/linux32_sysent.c ============================================================================== --- projects/altix/sys/amd64/linux32/linux32_sysent.c Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/amd64/linux32/linux32_sysent.c Tue Mar 29 00:47:00 2011 (r220120) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 219559 2011-03-12 08:51:43Z avg + * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 220028 2011-03-26 10:51:56Z avg */ #include "opt_compat.h" @@ -203,8 +203,8 @@ struct sysent linux_sysent[] = { { AS(linux_pwrite_args), (sy_call_t *)linux_pwrite, AUE_PWRITE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 181 = linux_pwrite */ { AS(linux_chown16_args), (sy_call_t *)linux_chown16, AUE_CHOWN, NULL, 0, 0, 0, SY_THR_STATIC }, /* 182 = linux_chown16 */ { AS(linux_getcwd_args), (sy_call_t *)linux_getcwd, AUE_GETCWD, NULL, 0, 0, 0, SY_THR_STATIC }, /* 183 = linux_getcwd */ - { 0, (sy_call_t *)linux_capget, AUE_CAPGET, NULL, 0, 0, 0, SY_THR_STATIC }, /* 184 = linux_capget */ - { 0, (sy_call_t *)linux_capset, AUE_CAPSET, NULL, 0, 0, 0, SY_THR_STATIC }, /* 185 = linux_capset */ + { AS(linux_capget_args), (sy_call_t *)linux_capget, AUE_CAPGET, NULL, 0, 0, 0, SY_THR_STATIC }, /* 184 = linux_capget */ + { AS(linux_capset_args), (sy_call_t *)linux_capset, AUE_CAPSET, NULL, 0, 0, 0, SY_THR_STATIC }, /* 185 = linux_capset */ { AS(linux_sigaltstack_args), (sy_call_t *)linux_sigaltstack, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 186 = linux_sigaltstack */ { 0, (sy_call_t *)linux_sendfile, AUE_SENDFILE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 187 = linux_sendfile */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 188 = getpmsg */ Modified: projects/altix/sys/amd64/linux32/linux32_systrace_args.c ============================================================================== --- projects/altix/sys/amd64/linux32/linux32_systrace_args.c Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/amd64/linux32/linux32_systrace_args.c Tue Mar 29 00:47:00 2011 (r220120) @@ -1284,12 +1284,18 @@ systrace_args(int sysnum, void *params, } /* linux_capget */ case 184: { - *n_args = 0; + struct linux_capget_args *p = params; + uarg[0] = (intptr_t) p->hdrp; /* struct l_user_cap_header * */ + uarg[1] = (intptr_t) p->datap; /* struct l_user_cap_data * */ + *n_args = 2; break; } /* linux_capset */ case 185: { - *n_args = 0; + struct linux_capset_args *p = params; + uarg[0] = (intptr_t) p->hdrp; /* struct l_user_cap_header * */ + uarg[1] = (intptr_t) p->datap; /* struct l_user_cap_data * */ + *n_args = 2; break; } /* linux_sigaltstack */ @@ -4051,9 +4057,29 @@ systrace_setargdesc(int sysnum, int ndx, break; /* linux_capget */ case 184: + switch(ndx) { + case 0: + p = "struct l_user_cap_header *"; + break; + case 1: + p = "struct l_user_cap_data *"; + break; + default: + break; + }; break; /* linux_capset */ case 185: + switch(ndx) { + case 0: + p = "struct l_user_cap_header *"; + break; + case 1: + p = "struct l_user_cap_data *"; + break; + default: + break; + }; break; /* linux_sigaltstack */ case 186: Modified: projects/altix/sys/amd64/linux32/linux32_sysvec.c ============================================================================== --- projects/altix/sys/amd64/linux32/linux32_sysvec.c Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/amd64/linux32/linux32_sysvec.c Tue Mar 29 00:47:00 2011 (r220120) @@ -249,8 +249,7 @@ elf_linux_fixup(register_t **stack_base, struct linux32_ps_strings *arginfo; arginfo = (struct linux32_ps_strings *)LINUX32_PS_STRINGS; - uplatform = (Elf32_Addr *)((caddr_t)arginfo - linux_szsigcode - - linux_szplatform); + uplatform = (Elf32_Addr *)((caddr_t)arginfo - linux_szplatform); KASSERT(curthread->td_proc == imgp->proc, ("unsafe elf_linux_fixup(), should be curproc")); Modified: projects/altix/sys/amd64/linux32/syscalls.master ============================================================================== --- projects/altix/sys/amd64/linux32/syscalls.master Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/amd64/linux32/syscalls.master Tue Mar 29 00:47:00 2011 (r220120) @@ -326,8 +326,10 @@ l_uid16_t uid, l_gid16_t gid); } 183 AUE_GETCWD STD { int linux_getcwd(char *buf, \ l_ulong bufsize); } -184 AUE_CAPGET STD { int linux_capget(void); } -185 AUE_CAPSET STD { int linux_capset(void); } +184 AUE_CAPGET STD { int linux_capget(struct l_user_cap_header *hdrp, \ + struct l_user_cap_data *datap); } +185 AUE_CAPSET STD { int linux_capset(struct l_user_cap_header *hdrp, \ + struct l_user_cap_data *datap); } 186 AUE_NULL STD { int linux_sigaltstack(l_stack_t *uss, \ l_stack_t *uoss); } 187 AUE_SENDFILE STD { int linux_sendfile(void); } Modified: projects/altix/sys/boot/pc98/boot2/boot2.c ============================================================================== --- projects/altix/sys/boot/pc98/boot2/boot2.c Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/boot/pc98/boot2/boot2.c Tue Mar 29 00:47:00 2011 (r220120) @@ -137,7 +137,7 @@ static const char *kname = NULL; static uint32_t opts; static int comspeed = SIOSPD; static struct bootinfo bootinfo; -static unsigned ioctrl = IO_KEYBOARD; +static uint8_t ioctrl = IO_KEYBOARD; void exit(int); static void load(void); @@ -445,9 +445,8 @@ load(void) static Elf32_Shdr es[2]; caddr_t p; ino_t ino; - uint32_t addr, x; + uint32_t addr; int i, j; - uint8_t fmt; if (!(ino = lookup(kname))) { if (!ls) @@ -456,15 +455,8 @@ load(void) } if (xfsread(ino, &hdr, sizeof(hdr))) return; - if (N_GETMAGIC(hdr.ex) == ZMAGIC) - fmt = 0; - else if (IS_ELF(hdr.eh)) - fmt = 1; - else { - printf("Invalid %s\n", "format"); - return; - } - if (fmt == 0) { + + if (N_GETMAGIC(hdr.ex) == ZMAGIC) { addr = hdr.ex.a_entry & 0xffffff; p = PTOV(addr); fs_off = PAGE_SIZE; @@ -473,7 +465,7 @@ load(void) p += roundup2(hdr.ex.a_text, PAGE_SIZE); if (xfsread(ino, p, hdr.ex.a_data)) return; - } else { + } else if (IS_ELF(hdr.eh)) { fs_off = hdr.eh.e_phoff; for (j = i = 0; i < hdr.eh.e_phnum && j < 2; i++) { if (xfsread(ino, ep + j, sizeof(ep[0]))) @@ -505,7 +497,11 @@ load(void) } addr = hdr.eh.e_entry & 0xffffff; bootinfo.bi_esymtab = VTOP(p); + } else { + printf("Invalid %s\n", "format"); + return; } + bootinfo.bi_kernelname = VTOP(kname); bootinfo.bi_bios_dev = dsk.daua; __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK), @@ -672,7 +668,7 @@ static void printf(const char *fmt,...) { va_list ap; - char buf[10]; + static char buf[10]; char *s; unsigned u; int c; Modified: projects/altix/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c ============================================================================== --- projects/altix/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Tue Mar 29 00:47:00 2011 (r220120) @@ -2962,11 +2962,6 @@ top: */ if (mask & AT_SIZE) { - err = zfs_zaccess(zp, ACE_WRITE_DATA, 0, skipaclchk, cr); - if (err) { - ZFS_EXIT(zfsvfs); - return (err); - } /* * XXX - Note, we are not providing any open * mode flags here (like FNDELAY), so we may Modified: projects/altix/sys/compat/freebsd32/freebsd32_ioctl.c ============================================================================== --- projects/altix/sys/compat/freebsd32/freebsd32_ioctl.c Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/compat/freebsd32/freebsd32_ioctl.c Tue Mar 29 00:47:00 2011 (r220120) @@ -38,7 +38,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include #include #include #include @@ -55,6 +57,7 @@ __FBSDID("$FreeBSD$"); CTASSERT((sizeof(struct md_ioctl32)+4) == 436); CTASSERT(sizeof(struct ioc_read_toc_entry32) == 8); CTASSERT(sizeof(struct ioc_toc_header32) == 4); +CTASSERT(sizeof(struct mem_range_op32) == 12); static int @@ -64,13 +67,10 @@ freebsd32_ioctl_md(struct thread *td, st struct md_ioctl mdv; struct md_ioctl32 md32; u_long com = 0; - int error; + int i, error; - if (uap->data == NULL) - panic("%s: where is my ioctl data??", __func__); if (uap->com & IOC_IN) { if ((error = copyin(uap->data, &md32, sizeof(md32)))) { - fdrop(fp, td); return (error); } CP(md32, mdv, md_version); @@ -119,9 +119,16 @@ freebsd32_ioctl_md(struct thread *td, st CP(mdv, md32, md_base); CP(mdv, md32, md_fwheads); CP(mdv, md32, md_fwsectors); + if (com == MDIOCLIST) { + /* + * Use MDNPAD, and not MDNPAD32. Padding is + * allocated and used by compat32 ABI. + */ + for (i = 0; i < MDNPAD; i++) + CP(mdv, md32, md_pad[i]); + } error = copyout(&md32, uap->data, sizeof(md32)); } - fdrop(fp, td); return error; } @@ -134,9 +141,6 @@ freebsd32_ioctl_ioc_toc_header(struct th struct ioc_toc_header32 toch32; int error; - if (uap->data == NULL) - panic("%s: where is my ioctl data??", __func__); - if ((error = copyin(uap->data, &toch32, sizeof(toch32)))) return (error); CP(toch32, toch, len); @@ -144,7 +148,6 @@ freebsd32_ioctl_ioc_toc_header(struct th CP(toch32, toch, ending_track); error = fo_ioctl(fp, CDIOREADTOCHEADER, (caddr_t)&toch, td->td_ucred, td); - fdrop(fp, td); return (error); } @@ -157,9 +160,6 @@ freebsd32_ioctl_ioc_read_toc(struct thre struct ioc_read_toc_entry32 toce32; int error; - if (uap->data == NULL) - panic("%s: where is my ioctl data??", __func__); - if ((error = copyin(uap->data, &toce32, sizeof(toce32)))) return (error); CP(toce32, toce, address_format); @@ -175,7 +175,6 @@ freebsd32_ioctl_ioc_read_toc(struct thre PTROUT_CP(toce, toce32, data); error = copyout(&toce32, uap->data, sizeof(toce32)); } - fdrop(fp, td); return error; } @@ -192,7 +191,49 @@ freebsd32_ioctl_fiodgname(struct thread CP(fgn32, fgn, len); PTRIN_CP(fgn32, fgn, buf); error = fo_ioctl(fp, FIODGNAME, (caddr_t)&fgn, td->td_ucred, td); - fdrop(fp, td); + return (error); +} + +static int +freebsd32_ioctl_memrange(struct thread *td, + struct freebsd32_ioctl_args *uap, struct file *fp) +{ + struct mem_range_op mro; + struct mem_range_op32 mro32; + int error; + u_long com; + + if ((error = copyin(uap->data, &mro32, sizeof(mro32))) != 0) + return (error); + + PTRIN_CP(mro32, mro, mo_desc); + CP(mro32, mro, mo_arg[0]); + CP(mro32, mro, mo_arg[1]); + + com = 0; + switch (uap->com) { + case MEMRANGE_GET32: + com = MEMRANGE_GET; + break; + + case MEMRANGE_SET32: + com = MEMRANGE_SET; + break; + + default: + panic("%s: unknown MEMRANGE %#x", __func__, uap->com); + } + + if ((error = fo_ioctl(fp, com, (caddr_t)&mro, td->td_ucred, td)) != 0) + return (error); + + if ( (com & IOC_OUT) ) { + CP(mro, mro32, mo_arg[0]); + CP(mro, mro32, mo_arg[1]); + + error = copyout(&mro32, uap->data, sizeof(mro32)); + } + return (error); } @@ -219,16 +260,25 @@ freebsd32_ioctl(struct thread *td, struc case MDIOCDETACH_32: /* FALLTHROUGH */ case MDIOCQUERY_32: /* FALLTHROUGH */ case MDIOCLIST_32: - return freebsd32_ioctl_md(td, uap, fp); + error = freebsd32_ioctl_md(td, uap, fp); + break; case CDIOREADTOCENTRYS_32: - return freebsd32_ioctl_ioc_read_toc(td, uap, fp); + error = freebsd32_ioctl_ioc_read_toc(td, uap, fp); + break; case CDIOREADTOCHEADER_32: - return freebsd32_ioctl_ioc_toc_header(td, uap, fp); + error = freebsd32_ioctl_ioc_toc_header(td, uap, fp); + break; case FIODGNAME_32: - return freebsd32_ioctl_fiodgname(td, uap, fp); + error = freebsd32_ioctl_fiodgname(td, uap, fp); + break; + + case MEMRANGE_GET32: /* FALLTHROUGH */ + case MEMRANGE_SET32: + error = freebsd32_ioctl_memrange(td, uap, fp); + break; default: fdrop(fp, td); @@ -237,4 +287,7 @@ freebsd32_ioctl(struct thread *td, struc PTRIN_CP(*uap, ap, data); return ioctl(td, &ap); } + + fdrop(fp, td); + return error; } Modified: projects/altix/sys/compat/freebsd32/freebsd32_ioctl.h ============================================================================== --- projects/altix/sys/compat/freebsd32/freebsd32_ioctl.h Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/compat/freebsd32/freebsd32_ioctl.h Tue Mar 29 00:47:00 2011 (r220120) @@ -67,6 +67,12 @@ struct fiodgname_arg32 { caddr_t32 buf; }; +struct mem_range_op32 +{ + caddr_t32 mo_desc; + int mo_arg[2]; +}; + #define CDIOREADTOCENTRYS_32 _IOWR('c', 5, struct ioc_read_toc_entry32) #define CDIOREADTOCHEADER_32 _IOR('c', 4, struct ioc_toc_header32) #define MDIOCATTACH_32 _IOC(IOC_INOUT, 'm', 0, sizeof(struct md_ioctl32) + 4) @@ -74,5 +80,7 @@ struct fiodgname_arg32 { #define MDIOCQUERY_32 _IOC(IOC_INOUT, 'm', 2, sizeof(struct md_ioctl32) + 4) #define MDIOCLIST_32 _IOC(IOC_INOUT, 'm', 3, sizeof(struct md_ioctl32) + 4) #define FIODGNAME_32 _IOW('f', 120, struct fiodgname_arg32) +#define MEMRANGE_GET32 _IOWR('m', 50, struct mem_range_op32) +#define MEMRANGE_SET32 _IOW('m', 51, struct mem_range_op32) #endif /* _COMPAT_FREEBSD32_IOCTL_H_ */ Modified: projects/altix/sys/compat/linprocfs/linprocfs.c ============================================================================== --- projects/altix/sys/compat/linprocfs/linprocfs.c Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/compat/linprocfs/linprocfs.c Tue Mar 29 00:47:00 2011 (r220120) @@ -740,7 +740,6 @@ linprocfs_doprocstatus(PFS_FILL_ARGS) if (P_SHOULDSTOP(p)) { state = "T (stopped)"; } else { - PROC_SLOCK(p); switch(p->p_state) { case PRS_NEW: state = "I (idle)"; @@ -770,7 +769,6 @@ linprocfs_doprocstatus(PFS_FILL_ARGS) state = "? (unknown)"; break; } - PROC_SUNLOCK(p); } fill_kinfo_proc(p, &kp); Modified: projects/altix/sys/compat/linux/linux_misc.c ============================================================================== --- projects/altix/sys/compat/linux/linux_misc.c Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/compat/linux/linux_misc.c Tue Mar 29 00:47:00 2011 (r220120) @@ -1679,6 +1679,100 @@ linux_exit_group(struct thread *td, stru return (0); } +#define _LINUX_CAPABILITY_VERSION 0x19980330 + +struct l_user_cap_header { + l_int version; + l_int pid; +}; + +struct l_user_cap_data { + l_int effective; + l_int permitted; + l_int inheritable; +}; + +int +linux_capget(struct thread *td, struct linux_capget_args *args) +{ + struct l_user_cap_header luch; + struct l_user_cap_data lucd; + int error; + + if (args->hdrp == NULL) + return (EFAULT); + + error = copyin(args->hdrp, &luch, sizeof(luch)); + if (error != 0) + return (error); + + if (luch.version != _LINUX_CAPABILITY_VERSION) { + luch.version = _LINUX_CAPABILITY_VERSION; + error = copyout(&luch, args->hdrp, sizeof(luch)); + if (error) + return (error); + return (EINVAL); + } + + if (luch.pid) + return (EPERM); + + if (args->datap) { + /* + * The current implementation doesn't support setting + * a capability (it's essentially a stub) so indicate + * that no capabilities are currently set or available + * to request. + */ + bzero (&lucd, sizeof(lucd)); + error = copyout(&lucd, args->datap, sizeof(lucd)); + } + + return (error); +} + +int +linux_capset(struct thread *td, struct linux_capset_args *args) +{ + struct l_user_cap_header luch; + struct l_user_cap_data lucd; + int error; + + if (args->hdrp == NULL || args->datap == NULL) + return (EFAULT); + + error = copyin(args->hdrp, &luch, sizeof(luch)); + if (error != 0) + return (error); + + if (luch.version != _LINUX_CAPABILITY_VERSION) { + luch.version = _LINUX_CAPABILITY_VERSION; + error = copyout(&luch, args->hdrp, sizeof(luch)); + if (error) + return (error); + return (EINVAL); + } + + if (luch.pid) + return (EPERM); + + error = copyin(args->datap, &lucd, sizeof(lucd)); + if (error != 0) + return (error); + + /* We currently don't support setting any capabilities. */ + if (lucd.effective || lucd.permitted || lucd.inheritable) { + linux_msg(td, + "capset effective=0x%x, permitted=0x%x, " + "inheritable=0x%x is not implemented", + (int)lucd.effective, (int)lucd.permitted, + (int)lucd.inheritable); + return (EPERM); + } + + return (0); +} + int linux_prctl(struct thread *td, struct linux_prctl_args *args) { @@ -1712,6 +1806,21 @@ linux_prctl(struct thread *td, struct li (void *)(register_t)args->arg2, sizeof(pdeath_signal)); break; + case LINUX_PR_GET_KEEPCAPS: + /* + * Indicate that we always clear the effective and + * permitted capability sets when the user id becomes + * non-zero (actually the capability sets are simply + * always zero in the current implementation). + */ + td->td_retval[0] = 0; + break; + case LINUX_PR_SET_KEEPCAPS: + /* + * Ignore requests to keep the effective and permitted + * capability sets when the user id becomes non-zero. + */ + break; case LINUX_PR_SET_NAME: /* * To be on the safe side we need to make sure to not Modified: projects/altix/sys/compat/linux/linux_misc.h ============================================================================== --- projects/altix/sys/compat/linux/linux_misc.h Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/compat/linux/linux_misc.h Tue Mar 29 00:47:00 2011 (r220120) @@ -37,6 +37,8 @@ * Second arg is a ptr to return the * signal. */ +#define LINUX_PR_GET_KEEPCAPS 7 /* Get drop capabilities on setuid */ +#define LINUX_PR_SET_KEEPCAPS 8 /* Set drop capabilities on setuid */ #define LINUX_PR_SET_NAME 15 /* Set process name. */ #define LINUX_PR_GET_NAME 16 /* Get process name. */ Modified: projects/altix/sys/compat/linux/linux_socket.c ============================================================================== --- projects/altix/sys/compat/linux/linux_socket.c Tue Mar 29 00:36:36 2011 (r220119) +++ projects/altix/sys/compat/linux/linux_socket.c Tue Mar 29 00:47:00 2011 (r220120) @@ -300,6 +300,8 @@ linux_to_bsd_so_sockopt(int opt) return (SO_OOBINLINE); case LINUX_SO_LINGER: return (SO_LINGER); + case LINUX_SO_PASSCRED: + return (LOCAL_CREDS); case LINUX_SO_PEERCRED: return (LOCAL_PEERCRED); case LINUX_SO_RCVLOWAT: @@ -433,6 +435,8 @@ linux_to_bsd_cmsg_type(int cmsg_type) switch (cmsg_type) { case LINUX_SCM_RIGHTS: return (SCM_RIGHTS); + case LINUX_SCM_CREDENTIALS: + return (SCM_CREDS); } return (-1); } @@ -444,6 +448,8 @@ bsd_to_linux_cmsg_type(int cmsg_type) switch (cmsg_type) { case SCM_RIGHTS: return (LINUX_SCM_RIGHTS); + case SCM_CREDS: + return (LINUX_SCM_CREDENTIALS); } return (-1); } @@ -459,7 +465,16 @@ linux_to_bsd_msghdr(struct msghdr *bhdr, bhdr->msg_iov = PTRIN(lhdr->msg_iov); bhdr->msg_iovlen = lhdr->msg_iovlen; bhdr->msg_control = PTRIN(lhdr->msg_control); - bhdr->msg_controllen = lhdr->msg_controllen; + + /* + * msg_controllen is skipped since BSD and LINUX control messages + * are potentially different sizes (e.g. the cred structure used + * by SCM_CREDS is different between the two operating system). + * + * The caller can set it (if necessary) after converting all the + * control messages. + */ + bhdr->msg_flags = linux_to_bsd_msg_flags(lhdr->msg_flags); return (0); } @@ -472,7 +487,16 @@ bsd_to_linux_msghdr(const struct msghdr lhdr->msg_iov = PTROUT(bhdr->msg_iov); lhdr->msg_iovlen = bhdr->msg_iovlen; lhdr->msg_control = PTROUT(bhdr->msg_control); - lhdr->msg_controllen = bhdr->msg_controllen; + + /* + * msg_controllen is skipped since BSD and LINUX control messages + * are potentially different sizes (e.g. the cred structure used + * by SCM_CREDS is different between the two operating system). + * + * The caller can set it (if necessary) after converting all the + * control messages. + */ + /* msg_flags skipped */ return (0); } @@ -1092,6 +1116,7 @@ static int linux_sendmsg(struct thread *td, struct linux_sendmsg_args *args) { struct cmsghdr *cmsg; + struct cmsgcred cmcred; struct mbuf *control; struct msghdr msg; struct l_cmsghdr linux_cmsg; @@ -1099,15 +1124,14 @@ linux_sendmsg(struct thread *td, struct struct l_msghdr linux_msg; struct iovec *iov; socklen_t datalen; + struct sockaddr *sa; + sa_family_t sa_family; void *data; int error; error = copyin(PTRIN(args->msg), &linux_msg, sizeof(linux_msg)); if (error) return (error); - error = linux_to_bsd_msghdr(&msg, &linux_msg); - if (error) - return (error); /* * Some Linux applications (ping) define a non-NULL control data @@ -1116,8 +1140,12 @@ linux_sendmsg(struct thread *td, struct * order to handle this case. This should be checked, but allows the * Linux ping to work. */ - if (msg.msg_control != NULL && msg.msg_controllen == 0) - msg.msg_control = NULL; + if (PTRIN(linux_msg.msg_control) != NULL && linux_msg.msg_controllen == 0) + linux_msg.msg_control = PTROUT(NULL); + + error = linux_to_bsd_msghdr(&msg, &linux_msg); + if (error) + return (error); #ifdef COMPAT_LINUX32 error = linux32_copyiniov(PTRIN(msg.msg_iov), msg.msg_iovlen, @@ -1128,13 +1156,21 @@ linux_sendmsg(struct thread *td, struct if (error) return (error); - if (msg.msg_control != NULL) { + control = NULL; + cmsg = NULL; + + if ((ptr_cmsg = LINUX_CMSG_FIRSTHDR(&linux_msg)) != NULL) { + error = kern_getsockname(td, args->s, &sa, &datalen); + if (error) + goto bad; + sa_family = sa->sa_family; + free(sa, M_SONAME); + error = ENOBUFS; cmsg = malloc(CMSG_HDRSZ, M_TEMP, M_WAITOK | M_ZERO); control = m_get(M_WAIT, MT_CONTROL); if (control == NULL) goto bad; - ptr_cmsg = LINUX_CMSG_FIRSTHDR(&msg); do { error = copyin(ptr_cmsg, &linux_cmsg, @@ -1147,28 +1183,58 @@ linux_sendmsg(struct thread *td, struct goto bad; /* - * Now we support only SCM_RIGHTS, so return EINVAL - * in any other cmsg_type + * Now we support only SCM_RIGHTS and SCM_CRED, + * so return EINVAL in any other cmsg_type */ - if ((cmsg->cmsg_type = - linux_to_bsd_cmsg_type(linux_cmsg.cmsg_type)) == -1) - goto bad; + cmsg->cmsg_type = + linux_to_bsd_cmsg_type(linux_cmsg.cmsg_type); cmsg->cmsg_level = linux_to_bsd_sockopt_level(linux_cmsg.cmsg_level); + if (cmsg->cmsg_type == -1 + || cmsg->cmsg_level != SOL_SOCKET) + goto bad; + + /* + * Some applications (e.g. pulseaudio) attempt to + * send ancillary data even if the underlying protocol + * doesn't support it which is not allowed in the + * FreeBSD system call interface. + */ + if (sa_family != AF_UNIX) + continue; + data = LINUX_CMSG_DATA(ptr_cmsg); datalen = linux_cmsg.cmsg_len - L_CMSG_HDRSZ; + + switch (cmsg->cmsg_type) + { + case SCM_RIGHTS: + break; + + case SCM_CREDS: + data = &cmcred; + datalen = sizeof(cmcred); + + /* *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***