Re: Shared memory question

From: Lev Walkin (vlm_at_netli.com)
Date: 08/30/03

  • Next message: Doug Barton: "Re: Call for thread testers"
    Date: Fri, 29 Aug 2003 20:31:18 -0700
    To: zera holladay <zera_holladay@yahoo.com>
    
    

    zera holladay wrote:
    > When one uses the term "shared memory" while
    > discussing Unix, then what is generally the meaning of
    > that term? I have read that some Unixes have "shared
    > memory" for "shared objects."
    >
    > However, I believe the term "shared memory" more
    > generically refers to user space as opposed to kernel
    > space? Further, the kernel should allocate and
    > deallocate memory for user space as requested so as
    > not to crash the system. If this is correct, then it
    > is very unlikely that a program running in user space
    > will ever crash a properly configured unix system?

    Shared memory is just a chunk of memory which may be
    created by one program and attached to (by) many other programs.
    Yes, the management (allocation and deallocation) of shared
    memory chunks are done in kernel. User space applications
    have to use shmget(2), shmat(2), shmdt(2) system calls
    to obtain, attach and release the chunk of shared memory.

    When the memory is attached by several processes, the
    pages of memory are physically the same, so any change made
    by one of the participating programs immediately becomes
    visible by others.

    If user space program crashes, kernel detaches the shared
    memory from this particular program, but it still remains
    available for any other program that is using this shared memory
    segment. The problem lies in the different space: if the
    the program has high privileges and does not properly handle
    shared memory permissions, than it is possible for some other
    program to maliciously modify the data in that shared memory
    segment to somehow affect program's behavior, up to executing
    arbitrary programs with enhanced privileges, and so on.
    So, it is possible that some damage to the system can be done
    through exploiting unsafely coded process with too much privileges,
    which could result in a crash of a properly configured unix system.

    "Shared objects", most certainly, were used to refer
    to shared libraries (roughly corresponding to .DLL files
    in Windows). If many programs use the same shared libraries,
    than it is wise to share their code to not to waste
    [virtual] memory. To solve this problem, certain regions
    of library code is mapped into the memory and shared between
    many applications. Of course in this case permissions are
    set appropriately to not to allow arbitrary program
    to change the shared portion of the library (alternatively,
    any change will result in a copy-on-write, and only the
    program itsel will see the changed portion).

    > Thank you for your patience.
    >
    > Zera

    -- 
    Lev Walkin
    vlm@netli.com
    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
    

  • Next message: Doug Barton: "Re: Call for thread testers"

    Relevant Pages

    • Re: + edac-new-opteron-athlon64-memory-controller-driver.patch added to -
      ... So we can kill the processes using that memory. ... What is the chipsets idea of which DIMM the memory error occurred on. ... There has always been enough information to determine the hardware ... some that are not easily accessible to user space so a kernel driver ...
      (Linux-Kernel)
    • Re: user_to_phys() without mmap?
      ... |> ram, not some PCI or AGP video card), but mmap'ing from kernel space ... |> into user space is causing large latencies and unsightly artifacts. ... | virtual memory locations from user space, ... Directly mapping physical memory to a process _can_, of course, be very ...
      (comp.os.linux.development.system)
    • [PATCH 2.6.9-rc1-mm4 4/6] [m32r] Update uaccess.h
      ... + * Test whether a block of memory is a valid user space address. ... * Context: User context only. ... * Checks if a pointer to a block of memory in user space is valid. ... * Returns zero on success, ...
      (Linux-Kernel)
    • Re: MmMapLockedPages with UserMode pointer
      ... I want to reserve a large ... The PC has 32GByte of memory. ... Both the FPGA and the CPU are processing a large data set ... contiguous user space address range. ...
      (microsoft.public.development.device.drivers)
    • [PATCH 25/39] merge common parts of uaccess.
      ... * Test whether a block of memory is a valid user space address. ... * Checks if a pointer to a block of memory in user space is valid. ... * These are the main single-value transfer routines. ...
      (Linux-Kernel)