From owner-freebsd-hackers@FreeBSD.ORG Tue Mar 10 16:05:53 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 735841065674 for ; Tue, 10 Mar 2009 16:05:53 +0000 (UTC) (envelope-from bsd.quest@googlemail.com) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.186]) by mx1.freebsd.org (Postfix) with ESMTP id 0A9198FC1F for ; Tue, 10 Mar 2009 16:05:52 +0000 (UTC) (envelope-from bsd.quest@googlemail.com) Received: by nf-out-0910.google.com with SMTP id d21so331192nfb.33 for ; Tue, 10 Mar 2009 09:05:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=PmG1YxYICK/mLIH0a1HsyYflxfCiwi1vFJnGGYeA6VI=; b=ow6FZAjbwOEV2hmx8jRcL5fE8L49VoDzcLOSqENIcdm9Iuw8bhS2tITn0EZx/IUze1 9+nMe8hKZx6tzpG0wdUMxhlR69Ej9InuzQ3yj/PHLJoYQxHERKPl+MlG/Mi2lTsDfO89 OKxWBmR54rNGRdXj8CCUHk1BAZytueSJoD6ls= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=Jej0b816d2xCftVD2vdDn44F046FsQhqmxZ+weZ4o8rzmYqNaDF8e2UPLp/Mn1uZfR IP/OnbNH7sV+nkg6716SiiQRgsVJKOuBdYq/uxgm3rrsJ94DlJu7ThyCv7dOnfKwPsS7 gQnyHaVD57n56HjeFuCGj2HolBqWx438p2lvo= MIME-Version: 1.0 Received: by 10.210.56.7 with SMTP id e7mr535411eba.21.1236701152103; Tue, 10 Mar 2009 09:05:52 -0700 (PDT) Date: Tue, 10 Mar 2009 17:05:52 +0100 Message-ID: <671bb5fc0903100905u7484cd1dp9faefc8bc208a6a6@mail.gmail.com> From: Alexej Sokolov To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: write protection by mmap of /dev/mem doesn't work X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Mar 2009 16:05:53 -0000 hello, How can I mmap some memory regions with PROT_WRITE protection flag ? What i do: /* Open mem device */ if ((devmem_fd = open("/dev/mem", O_RDWR)) == -1){ perror("/dev/mem"); exit (1); } then if I try to mmap some memory region with PROT_READ it goes Ok. But by PROT_WRITE it doesn't work: sp = mmap ( 0, MCLBYTES, /* Size of remapped buffer = size of mbuf cluster */ PROT_WRITE, MAP_SHARED, devmem_fd, phys_addr /* Physical addres of packet buffer from descriptor */ ); I get by PROT_WRITE " segmentation fault" What is the problem here ? And question again: How can I do it possible to remapp the kernel memory region to user space process through /dev/mem and give to this user process write permissions to remmaped space ? Thanx