From nobody@FreeBSD.org  Thu Mar 25 11:07:00 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 11532106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 25 Mar 2010 11:07:00 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 0057C8FC0A
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 25 Mar 2010 11:07:00 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o2PB6xjA001869
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 25 Mar 2010 11:06:59 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o2PB6xC9001868;
	Thu, 25 Mar 2010 11:06:59 GMT
	(envelope-from nobody)
Message-Id: <201003251106.o2PB6xC9001868@www.freebsd.org>
Date: Thu, 25 Mar 2010 11:06:59 GMT
From: Oleg Ginzburg <oleg.ginzburg@nevosoft.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: kernel crash by linux.ko module with nooptions COMPAT_FREEBSD32 
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         145024
>Category:       kern
>Synopsis:       [linux] [patch] kernel crash by linux.ko module with nooptions COMPAT_FREEBSD32
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    dchagin
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 25 11:10:02 UTC 2010
>Closed-Date:    Sun Feb 13 08:46:53 UTC 2011
>Last-Modified:  Sun Feb 13 08:46:53 UTC 2011
>Originator:     Oleg Ginzburg
>Release:        9.0-CURRENT
>Organization:
>Environment:
FreeBSD gizmo.nevosoft.local 9.0-CURRENT FreeBSD 9.0-CURRENT #1: Thu Mar 25 16:03:39 MSK 2010     root@:/usr/obj/usr/src/sys/GENERIC-NODEBUG  amd64
>Description:
kernel crash by linux.ko module with nooptions COMPAT_FREEBSD32 
>How-To-Repeat:
have kernel from kernel config like:
--
include GENERIC

ident           GENERIC-NOCOMPAT_FREEBSD32

nooptions      COMPAT_FREEBSD32        # Compatible with i386 binaries
--

and 

linux_load="YES"

in /boot/loader.conf

then try to boot.
>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-emulation 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat Mar 27 05:15:20 UTC 2010 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=145024 
State-Changed-From-To: open->analyzed 
State-Changed-By: arundel 
State-Changed-When: Sun Jan 30 18:13:13 UTC 2011 
State-Changed-Why:  
We have two possibilities in order to fix this issue: 

1) Add something like the following somewhere in sys/amd/linux32: 

#ifndef COMPAT_FREEBSD32 
#error "linux emulation requires COMPAT_FREEBSD32  
option for non 32 bit architectures" 
#endif 

2) Find a way to avoid the freebsd32_exec_copyin_args() call in 
linux32_machdep.c. I believe this is the only place in the sys/amd/linux32 
code that depends on sys/amd64/ia32 code. 

NB: I've removed the panic tag from this PR. I was able to reproduce the issue, 
however a panic didn't occur. The problem is that 
freebsd32_exec_copyin_args() wasn't compiled into the kernel and loading the 
linux kernel module thus fails. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=145024 

From: Alexander Best <arundel@freebsd.org>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: kern/145024: [linux] kernel crash by linux.ko module with nooptions COMPAT_FREEBSD32
Date: Mon, 31 Jan 2011 10:14:20 +0000

 --yrj/dFKFPuw6o+aM
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 this patch should solve the issue.
 
 cheers.
 alex
 
 -- 
 a13x
 
 --yrj/dFKFPuw6o+aM
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="linux-module.diff"
 
 Index: sys/modules/linux/Makefile
 ===================================================================
 --- sys/modules/linux/Makefile	(revision 218125)
 +++ sys/modules/linux/Makefile	(working copy)
 @@ -2,7 +2,7 @@
  
  .if ${MACHINE_CPUARCH} == "amd64"
  SFX= 32
 -CFLAGS+=-DCOMPAT_FREEBSD32 -DCOMPAT_LINUX32
 +CFLAGS+=-DCOMPAT_LINUX32
  .endif
  
  .PATH: ${.CURDIR}/../../compat/linux ${.CURDIR}/../../${MACHINE_CPUARCH}/linux${SFX}
 
 --yrj/dFKFPuw6o+aM--
Responsible-Changed-From-To: freebsd-emulation->dchagin 
Responsible-Changed-By: dchagin 
Responsible-Changed-When: Sun Feb 13 08:40:51 UTC 2011 
Responsible-Changed-Why:  
Take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=145024 
State-Changed-From-To: analyzed->closed 
State-Changed-By: dchagin 
State-Changed-When: Sun Feb 13 08:41:42 UTC 2011 
State-Changed-Why:  
The linux module depends on COMPAT_FREEBSD32 since r205014. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=145024 
>Unformatted:
