Sponsored Content
Special Forums Cybersecurity root cannot write to Linux RAM Post 302583880 by Corona688 on Wednesday 21st of December 2011 01:33:15 PM
Old 12-21-2011
You agreed not to bump posts when you registered. If we don't answer instantly, wait!

Your program isn't running in real mode. You can't access physical addresses just by plugging in the right pointer.

The kernel keeps a list of what memory belongs to your process, and what address your process uses them at. It could give you physical memory address 0x0000000 but make it appear in your process at 0x80000000. And using any virtual addresses that haven't been assigned just causes SEGV. This is all handled in hardware by your processor.

If you want to access physical addresses in Linux, you have to actually ask for them. There's special device files you can read from to get it. /dev/kmem will be the kernel memory area and nothing but the kernel memory area. /dev/mem, I think, is raw RAM contents -- not that useful since the real pages could be scrambled in any virtual order inside the processes themselves. There's also things like memory holes for I/O to consider.

Code:
char buf[16384];
int fd=open("/dev/kmem", O_RDONLY);
read(fd, buf, 16384); // first 16KB of kernel mem

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Athlon XP + Linux/Unix? and RAM Question

Has anyone had any experience with this new processor and its compatability with Linux/Unix? How did it preform comared to regular Athlons and P4's? I also have one other question. I plan on buying a new dell and fiddling left and right with it. Which type of RAM is better, RDRAM or... (3 Replies)
Discussion started by: KyPeN
3 Replies

2. UNIX for Dummies Questions & Answers

How much RAM does RH Linux need?

I wish to install Red Hat linux 7.1 on a machine with 16mb of EDO Ram. When I enter the instalation process I am told 'You do not have enough memory'. Is there a way to install RHL with only the 16? Or will I have to upgrade and buy some very expensive EDO. ~ Paul (3 Replies)
Discussion started by: KrazyGuyPaul
3 Replies

3. UNIX for Dummies Questions & Answers

How do i access (mount, read & write) a floppy disk from the console, not being root?

welll, the title quite explains what i want to do thanks for your time! (4 Replies)
Discussion started by: kfaday
4 Replies

4. Debian

what is the best linux ver for p100 16 ram

Hello all i own p100 16ram laptop , i would like to run linux on it i need it for gcc compilation and shell scripting , no gui. what version of linux should i install , i dont mind to install old one . tnx allot (5 Replies)
Discussion started by: umen
5 Replies

5. UNIX for Dummies Questions & Answers

Linux for Pentium @ 150 Mhz and 98Mb in RAM?

I don't know a lot of the world of Linux, but i want to start with an old machine; did someone knows if i can install Linux in a computer with a processor Pentium (not celeron) @ 133 Mhz, 98Mb in RAM (PC100) and 3Gb Hard Drive? a friend tell me about Ubuntu and openSUSE, but I don't know if... (5 Replies)
Discussion started by: Omega
5 Replies

6. Shell Programming and Scripting

To find the RAM size for an Linux server.

Hi Gurus, Can someone let me know how to find the RAM size,ROM size and Number of processors for a linux server. Version :Linux 2.4.9-e.57smp Also what does "e.57smp" stands for? Thanks in advance gurus..... cheers. (3 Replies)
Discussion started by: navojit dutta
3 Replies

7. Linux

Installation of Linux in 300 MHz with 128 MB ram

Hi I am very new to Linux, but very keen to learn it. I am having a desktop of 300 MHz with 128 MB RAM and 30 GB hard drive with Windows XP. My first question is - Is there any version/flavour of Linux available that can be installed on above system especially Fedora with less compromise... (6 Replies)
Discussion started by: sanjay1979
6 Replies

8. Red Hat

red hat Linux 5.0 is detecting 3gb ram but physical ram is 16gb

Hi, On server 64bit Hw Arch , Linux 5.0(32bit) is installed it is showing only 3gb of ram though physical is 16gb can u give me idea why? (4 Replies)
Discussion started by: manoj.solaris
4 Replies

9. Linux Benchmarks

AMD Phenom(tm) 9950 Quad-Core Processor, Ram: 3.6 GB, Foxconn 7da-s and Linux 2.6.26-2-amd64

CPU/Speed: AMD Phenom(tm) 9950 Quad-Core Processor Ram: 3.6 GB Motherboard: Foxconn 7da-s Bus: Cache: Controller: Disk: Load: Kernel: Linux 2.6.26-2-amd64 Kernel ELF?: pgms: ============================================================== BYTE UNIX Benchmarks (Version... (0 Replies)
Discussion started by: migracho
0 Replies

10. Linux

Need assistance to enable more that 4GB RAM on Linux 32Bit OS.

How to enable more than 4GB RAM support on Linux 32bit OS? OS: CentOS release 5.4 (Final) Kernel version: 2.6.18-53.el5 Arch: 32Bit I got solution at Innovationframes.com • View topic - How to enable more than 4GB RAM support on Linux 32bit OS? but my question is the steps given... (5 Replies)
Discussion started by: chandranjoy
5 Replies
bcopy(9F)						   Kernel Functions for Drivers 						 bcopy(9F)

NAME
bcopy - copy data between address locations in the kernel SYNOPSIS
#include <sys/types.h> #include <sys/sunddi.h> void bcopy(const void *from, void *to, size_t bcount); INTERFACE LEVEL
Architecture independent level 1 (DDI/DKI). PARAMETERS
from Source address from which the copy is made. to Destination address to which copy is made. bcount The number of bytes moved. DESCRIPTION
bcopy() copies bcount bytes from one kernel address to another. If the input and output addresses overlap, the command executes, but the results may not be as expected. Note that bcopy() should never be used to move data in or out of a user buffer, because it has no provision for handling page faults. The user address space can be swapped out at any time, and bcopy() always assumes that there will be no paging faults. If bcopy() attempts to access the user buffer when it is swapped out, the system will panic. It is safe to use bcopy() to move data within kernel space, since kernel space is never swapped out. CONTEXT
bcopy() can be called from user or interrupt context. EXAMPLES
Example 1: Copying data between address locations in the kernel: An I/O request is made for data stored in a RAM disk. If the I/O operation is a read request, the data is copied from the RAM disk to a buffer (line 8). If it is a write request, the data is copied from a buffer to the RAM disk (line 15). bcopy() is used since both the RAM disk and the buffer are part of the kernel address space. 1 #define RAMDNBLK 1000 /* blocks in the RAM disk */ 2 #define RAMDBSIZ 512 /* bytes per block */ 3 char ramdblks[RAMDNBLK][RAMDBSIZ]; /* blocks forming RAM /* disk ... 4 5 if (bp->b_flags & B_READ) /* if read request, copy data */ 6 /* from RAM disk data block */ 7 /* to system buffer */ 8 bcopy(&ramdblks[bp->b_blkno][0], bp->b_un.b_addr, 9 bp->b_bcount); 10 11 else /* else write request, */ 12 /* copy data from a */ 13 /* system buffer to RAM disk */ 14 /* data block */ 15 bcopy(bp->b_un.b_addr, &ramdblks[bp->b_blkno][0], 16 bp->b_bcount); SEE ALSO
copyin(9F), copyout(9F) Writing Device Drivers WARNINGS
The from and to addresses must be within the kernel space. No range checking is done. If an address outside of the kernel space is selected, the driver may corrupt the system in an unpredictable way. SunOS 5.10 4 August 2003 bcopy(9F)
All times are GMT -4. The time now is 11:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy