QemuTimer Callback机制

前言

在做2021 HWS FastCP的时候,有这样一个场景.漏洞点是对CP_buffer的溢出读写,可以覆盖掉之后的QEMUTimer结构,自然想到劫持其的callback函数指针.

但又多想了一点,cp_timer的回调函数是在pci_FastCP_realize中调用timer_init_full注册(初始化)过的,说不定callback指针已经在另一个位置保存并作为之后回调使用,并不会调用该结构中的指针.

阅读更多...

HQOS 设计与实现

“THE MAN WHO CHANGED CHROME” 曾经指出如何学习计算机基础知识:

自己写一个CPU,在自己写的CPU上运行自己写的操作系统,然后用自己写的编译器编译运行一个程序.

于是便有了写一个操作系统的想法.在粗略看完一遍《操作系统真相还原》后,感觉从引导操作系统到实现各种操作系统概念的完整过程工作量有点太大了,暂时还没有那么多时间和精力来完成,便暂且搁置了.

感谢MIT的6.828课程,让我能在有限的时间里一步一步地实现一个操作系统雏形JOS.JOS的开发过程请查看 /学习笔记/6.828分类下的文章.

在接下来的一段时间,我会继续开发扩展该操作系统,并重构目前实现模型中我不太喜欢的实现,就叫它HQOS吧.

本博客记录当前版本HQOS的设计与实现,你可以在github上找到其历史文档及代码实现.
github

阅读更多...

MIT6.828 Lab6

Lab 6: Network Driver

Part A: Initialization and transmitting packets

time

在之前的时钟中断调度前加一个对time_tick函数的调用,注意时钟中断每个CPU都会收到,而我们的目的是计时,所以选择固定选择一个CPU来处理就好,bootcpu当然是最合适的.

1
2
3
4
5
6
case IRQ_OFFSET+IRQ_TIMER:
lapic_eoi();
if(thiscpu==bootcpu)
time_tick();
sched_yield();
return;
阅读更多...

MIT6.828 Lab5

最崩溃的一集…Lab倒是很简单,只是文件系统一启用,之前代码的好多问题都显现出来了,然后就是debugggg.

Lab 5: File system, Spawn and Shell

Getting Started

切换分支之后编译有点问题,改一改:


在GNUmakefile中加上-Wno-address-of-packed-member

将fs.h中定义的全局变量改为外部变量,并在fs.c中定义.

1
2
extern struct Super *super;		// superblock
extern uint32_t *bitmap; // bitmap blocks mapped in memory

改下输出,lab4满分通过.

File system preliminaries

文件系统的设计就不在这里说了,详见《HQOS 设计与实现》.

阅读更多...

中华武数杯2023 WP

最喜欢的高版本堆题,挺有意思的.
所以到底叫上海大师杯还是中华武数杯

randomHeap

glibc2.35堆,保护全开

逆向

程序实现了这样的堆管理结构.初始化时,分配了16个堆管理结构和16个大小为0x28字节的堆块,放入chunk_list和chunk_manager_list.正常情况下这两个结构应该是用户不可见的.

阅读更多...

MIT6.828 Lab4

Lec 9

“Locking”

When we say that a lock protects data, we really mean that the lock protects some
collection of invariants that apply to the data. Invariants are properties of data struc-
tures that are maintained across operations. Typically, an operation’s correct behavior
depends on the invariants being true when the operation begins. The operation may
temporarily violate the invariants but must reestablish them before finishing. For ex-
ample, in the linked list case, the invariant is that list points at the first node in the
list and that each node’s next field points at the next node. The implementation of
insert violates this invariant temporarily: in line 15, l points to the next list element,
but list does not point at l yet (reestablished at line 16). The race condition we ex-
amined above happened because a second CPU executed code that depended on the
list invariants while they were (temporarily) violated. Proper use of a lock ensures that
only one CPU at a time can operate on the data structure in the critical section, so
that no CPU will execute a data structure operation when the data structure’s invari-
ants do not hold.

阅读更多...
  • Copyrights © 2022-2024 翰青HanQi

请我喝杯咖啡吧~

支付宝
微信