这样我们要执行的payload就组装完了,怎么一句话不落地执行呢?看了之前文章的都知道 python3 -c 'codes'
审计固件的时候碰到了一个mips64下uClibc堆管理利用的问题,恰巧网络上关于这个的分析不是很多,于是研究了一下。并不是很全面,做个索引,若有进一步了解时继续补全。
Linux内核给每个进程都提供了一个独立的虚拟地址空间,并且这个地址空间是连续的。Linux的空间又分为内核空间和用户空间,在32位中,内核空间占1G,用户空间占3G;而在64位中,内核空间和用户空间各占128T。如图3-24所示。
个人名言:“同一条河里淹死两次的人,是傻子,淹死三次及三次以上的人是超人”。经历过上次悲催的面试,决定沉下心来,好好的补充一下基础知识点。本文是这一系列第一篇:进程间通讯之mmap。
简单来讲,/dev/mem是系统物理内存的映像文件,这里的 “物理内存” 需要进一步解释。
在Linux系统上查看内存使用状况最常用的命令是"free",其中buffers和cache通常被认为是可以回收的:
随着计算机技术的飞速发展,Linux操作系统作为开源领域的佼佼者,已经深入到了各个应用场景之中。在Linux系统中,内核与用户空间之间的交互是核心功能之一,而设备驱动则是实现这一交互的关键环节。然而,传统的设备驱动开发往往受限于内核空间的限制,无法充分发挥用户空间程序的灵活性和性能优势。为了解决这个问题,Linux内核引入了UIO(Userspace I/O)驱动模型。
本文来源:原创投稿 *爱可生开源社区出品,原创内容未经授权不得随意使用,转载请联系小编并注明来源。
这篇文章讨论如何使用CRIU迁移使用了共享内存的程序,主要讨论其中的前两种共享内存方法,最终介绍一种支持热迁移的C程序共享内存使用方法。
6月1号,我提交了一个linux内核中的任意递归漏洞。如果安装Ubuntu系统时选择了home目录加密的话,该漏洞即可由本地用户触发。如果想了解漏洞利用代码和短一点的漏洞报告的话,请访问https:/
本文依据qemu2.11的源码,把整个初始化和运行虚拟机的代码拿出来,完成一个可以运行的模拟器demo。从中可以很清晰的看出qemu-kvm的初始化以及虚拟机的运行过程。
iomem=str mem=str Fio can use various types of memory as the io unit buffer. The allowed values are: malloc Use memory from malloc(3) as the buffers. shm Use shared memory as the buffers. Allocated through shmget(2). shmhuge Same as shm, but use huge pages as backing. mmap Use mmap to allocate buffers. May either be anonymous memory, or can be file backed if a filename is given after the option. The format is mem=mmap:/path/to/file. mmaphuge Use a memory mapped huge file as the buffer backing. Append filename after mmaphuge, ala mem=mmaphuge:/hugetlbfs/file mmapshared Same as mmap, but use a MMAP_SHARED mapping. The area allocated is a function of the maximum allowed bs size for the job, multiplied by the io depth given. Note that for shmhuge and mmaphuge to work, the system must have free huge pages allocated. This can normally be checked and set by reading/writing /proc/sys/vm/nr_hugepages on a Linux system. Fio assumes a huge page is 4MB in size. So to calculate the number of huge pages you need for a given job file, add up the io depth of all jobs (normally one unless iodepth= is used) and multiply by the maximum bs set. Then divide that number by the huge page size. You can see the size of the huge pages in /proc/meminfo. If no huge pages are allocated by having a non-zero number in nr_hugepages, using mmaphuge or shmhuge will fail. Also see hugepage-size. mmaphuge also needs to have hugetlbfs mounted and the file location should point there. So if it'smountedin/huge,youwouldusemem=mmaphuge:/huge/somefile.iomem_align=intThisindiciatesthememoryalignmentoftheIOmemorybuffers.NotethatthegivenalignmentisappliedtothefirstIOunitbuffer,ifusingiodepththealignmentofthefollowingbuffersaregivenbythebsused.Inotherwords,ifusingabsthatisamultipleofthepagesizedinthesystem,allbufferswillbealignedtothisvalue.Ifusingabsthatisnotpagealigned,thealignmentofsubsequentIOmemorybuffersisthesumoftheiomem_alignandbsused.hugepage-size=intDefinesthesiz
Linux环境下,进程地址空间相互独立,每个进程各自有不同的用户地址空间。任何一个进程的全局变量在另一个进程中都看不到,所以进程和进程之间不能相互访问。
前言: KVM的设备虚拟化,除了前文《PIO技术分析》,还有另外一个核心概念---MMIO。原计划这里分析一下KVM的MMIO虚拟化。考虑到MMIO比PIO复杂很多,涉及更多的概念,作者打算先分析几篇基本的Linux的内存管理概念,再来分析MMIO。 作者大概想了一下,主要由这几篇构成: 1,虚拟内存管理和内存映射。 2,物理内存管理。 3,内存回收。 分析: 1,虚拟内存概念 x86的CPU有两种运行模式---real mode和protected mode。在real mode下,CPU访问的是物理
glibc-2.14中的malloc.c源代码,供研究malloc和free实现使用:
为了进一步加深对线程的操作,本文介绍了使用多线程实现拷贝文件的一个案例,网络上虽然有很多多线程拷贝的案例,但是都存在重大 bug。我们独辟蹊径,首先将一个文件分段映射到内存(mmap),随后将每一段映射的内存通知给线程,由线程去对每一段已经映射的内存进行复制。具体实现代码如下:
| 导语 企鹅FM近几个版本的外网Crash出现很多OutOfMemory(以下简称OOM)问题,Crash的堆栈都在Thread::start方法上。该文详细分析了发生原因。 ---- 有两种栈: 出现次数最多的一种,称之为 堆栈A。 java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Out of memory java.lang.Thread.nativeCreate(Native Method)
Video设备产生的数据较多,传统的缓冲机制已不能满足需求。为此,Linux内核抽象出了videobuf2机制,用于管理存放视频图像的帧缓冲。videobuf2抽象层像一座桥梁,将用户空间和V4L2 driver连接起来。videobuf2抽象层向用户空间提供了标准POSIX I/O系统调用,包括read、poll及mmap等,同时还提供了大量与流式I/O相关的V4L2 ioctl调用,包括缓冲区分配、缓冲区入队、缓冲区出队及流控制。虽然使用videobuf2会给驱动程序强加一些设计决策,但是使用它的收益是videobuf2可以减少驱动程序代码和保持V4L2子系统在用户空间API的一致性,显然使用videobuf2更为合理。
共享内存的优势 采用共享内存通信的一个显而易见的好处是效率高,因为进程可以直接读写内存,而不需要任何数据的拷贝。对于像管道和消息队列等通信方式,则需要在内核和用户空间进行四次的数据拷贝,而共享内存则只拷贝两次数据:一次从输入文件到共享内存区,另一次从共享内存区到输出文件。实际上,进程之间在共享内存时,并不总是读写少量数据后就解除映射,有新的通信时,再重新建立共享内存区域。而是保持共享区域,直到通信完毕为止,这样,数据内容一直保存在共享内存中,并没有写回文件。共享内存中的内容往往是在解除映射时才写回文件的。因
最近在维护一台CentOS服务器的时候,发现内存无端"损失"了许多,free和ps统计的结果相差十几个G,搞的我一度又以为遇到灵异事件了,后来Google了许久才搞明白,特此记录一下,以供日后查询。
本文简要介绍了新增的 15 种执行代码的方式,另外详细介绍了该课程提供的所有实验材料。"
glibc-2.14中的arean.c源代码,供研究malloc和free实现使用:
一、前言 Unix和类Unix操作系统提供的ptrace系统调用支持一个进程控制另一个进程,常被用于程序调试、分析和监测工具,例如gdb、strace等。通过ptrace可以查看和修改被控制进程的内部状态,因此渗透攻击在注入shellcode时也会使用ptrace。本文介绍一种Linux下使用ptrace隐藏注入shellcode的技术和防御方法。 二、背景 不同版本操作系统有各自实现ptrace系统调用的方式,本文只关注Linux环境,因此先简单说明Linux下ptrace系统调用的用法。首先定义控
出于安全原因,使用Android 原生的Camera接口,必须要使用可见的surface显示摄像头的preview图像,即必须要让用户看到你的应用正在使用摄像头。另外Android Camera framework经过层层封装,同时必须调用到显示和MediaPlayer两个模块,数据处理的环节比较多。 在开发过程中,可能会有需求只需要去获取camera数据结合AI进行处理。通过V4L2接口可以直接从驱动获取camera数据,省去了很多中间环节,同时可以在后台处理数据,不需要作为前台应用运行。
在博客 【Linux 内核 内存管理】虚拟地址空间布局架构 ⑦ ( vm_area_struct 结构体成员分析 | vm_start | vm_end | vm_next | vm_prev |vm_rb) 中 , 分析了 vm_start vm_end vm_next vm_prev vm_rb 这
既然 /dev/fb0 被抽象成了显示器,可以在字符终端通过操作映射了 /dev/fb0 的内存在屏幕上画32bit真彩图,那么如何操作鼠标键盘呢?
从操作系统的角度来说,内存就是一块数据存储区域,是可被操作系统调度的资源。在多任务(进程)的操作系统中,内存管理尤为重要,操作系统需要为每一个进程合理的分配内存资源。所以可以从操作系统对内存分配和回收两方面来理解内存管理机制。
原文 https://mp.weixin.qq.com/s/8A_y1dlZrUvpaJfbQrVK3w
OLED显示屏在是智能手环,智能手表上用的非常的多,功耗低,不刺眼,优点特别多。本篇文章就介绍,在Linux系统里如何使用OLED显示屏,要使用OLED显示屏,大致分为两步: (1) 针对OLED显示屏编写一个驱动 (2) 编写应用层程序进行测试。
在 Linux 系统中一切皆文件,除了通常所说的狭义的文件以外,目录、设备、套接字和管道等都是文件。
在前面一篇博客中我们介绍了一些用python3处理表格数据的方法,其中重点包含了vaex这样一个大规模数据处理的方案。这个数据处理的方案是基于内存映射(memory map)的技术,通过创建内存映射文件来避免在内存中直接加载源数据而导致的大规模内存占用问题,这使得我们可以在本地电脑内存规模并不是很大的条件下对大规模的数据进行处理。python3中提供了mmap这样一个仓库,可以直接创建内存映射文件。
前面文章介绍了进程间常用的通信方式: 无名管道和命名管道,这篇文章介绍内存映射,内存映射在多进程访问文件读写的时候非常方便。
可以观察到非常有意思的现象,这个进程占用了124%的内存,实际上Swap为0。总占用也没到100%。这是为什么呢?
众所周知,Linux内核主要包括三种驱动模型,字符设备驱动,块设备驱动以及网络设备驱动。
提示:公众号展示代码会自动折行,建议横屏阅读 「第一部分 前言」 我们都知道,程序的运行离不开内存。很多人都有这种直接朴素的想法,内存越大程序的运行速度越快。对于数据库来说,如果数据都能加载到内存中,不需要从磁盘读取,那速度肯定是杠杠的。但是,对于现在的应用来说,几十GB乃至TB级别的数据,都是常见的情况,但内存多是十几GB。所以,内存就是就是珍贵的资源,要精打细算的使用,那么这次我们就探究一下和内存相关的知识。这些知识将从两个方面着手,一是操作系统方面,从该方面我们讲述内存在这个层面是怎么分布的;二是M
堆是分配给每个程序的一个内存区域。与堆栈不同,堆内存可以动态分配。这意味着程序可以在需要时从堆中 “申请 “和 “释放 “内存。另外,这个内存是全局的,也就是说,它可以从程序中的任何地方被访问和修改,而不是被分配到指定函数上。这是通过使用 “指针 “来引用动态分配的内存来实现的,与使用堆栈上相比,这又导致了性能上的小幅下降。
关于dlinject dlinject是一款针对Linux进程安全的注入测试工具,在该工具的帮助下,广大研究人员可以在不使用ptrace的情况下,轻松向正在运行的Linux进程中注入一个共享代码库(比如说任意代码)。之所以开发该工具,是因为目前社区有非常多的反ptrace技术,而dlinject的功能并不基于ptrace实现,因此渗透测试的效果会更好。 工具运行机制 1、该工具首先会向目标进程发送终止运行的信号,并定位_dl_open()方法。接下来,该工具将会通过/proc/[pid]/sysca
在之前的文章有介绍过调用jump_stack()函数进行bthread上下文的切换(bthread栈的切换),其中涉及了汇编语言。本文来讲一讲与之对应的另外一个操作:调用get_stack()进行上下文的创建(bthread栈的创建),并且同样会涉及汇编语言。
内核使用cgroup对进程进行分组,并限制进程资源和对进程进行跟踪。内核通过名为cgroupfs类型的虚拟文件系统来提供cgroup功能接口。cgroup有如下2个概念:
igb_uio 是 dpdk 内部实现的将网卡映射到用户态的内核模块,它是 uio 模块的一个实例。
我们都知道,对于解释型的语言实现来说,性能是大家关注的焦点。比如,这位 Tondbal ik Ni 曾经还说过:
韩传华,就职于南京大鱼半导体有限公司,主要从事linux相关系统软件开发工作,负责Soc芯片BringUp及系统软件开发,乐于分享喜欢学习,喜欢专研Linux内核源代码。
在Linux内核,对于进程的内存使用与Cgroup的内存使用统计有一些相同和不同的地方。
Docker 下运行的 Java 应用程序中的内存消耗时遇到了一个有趣的问题。该XMX参数被设置为256M,但Docker监控工具显示几乎两倍多使用的内存
最近笔者在看性能分析相关的是知识,就特意针对内存整理了这一篇文章,在这里笔者主要从下面三个方面来介绍这方面的知识: 1.内存的作用是什么,他在操作系统中的基础知识都有哪一些? 2.查看内存和内存相关问题涉及到的工具都有哪一些,他们的使用方式是什么样子的? 3.碰到内存问题的时候,我们需要怎么去定位呢?
帧缓冲(framebuffer)是Linux 系统为显示设备提供的一个接口,它将显示缓冲区抽象,屏蔽图像硬件的底层差异,允许上层应用程序在图形模式下直接对显示缓冲区进行读写操作。用户不必关心物理显示缓冲区的具体位置及存放方式,这些都由帧缓冲设备驱动本身来完成。
在之前的博客 【Linux 内核 内存管理】虚拟地址空间布局架构 ⑦ ( vm_area_struct 结构体成员分析 | vm_start | vm_end | vm_next | vm_prev |vm_rb) 中 , 分析了 vm_start vm_end vm_next vm_prev vm_rb 这
领取专属 10元无门槛券
手把手带您无忧上云