如何使@NotNull抛出运行时异常?(How to make @NotNull throw runtime exception?)
如果我将null作为参数传递给
@NotNull
注释,是否有任何框架可以引发异常? 我不是指静态分析,而是运行时检查。如果没有,如何实施呢?
Is there any framework that can throw exception if I pass null as parameter to
@NotNull
annotation? I don't mean static analysis but run-time checks.If not, how to implement it?
原文:https://stackoverflow.com/questions/26393129
更新时间:2023-08-26 12:08
最满意答案
你在
linux/mm.h
寻找linux/mm.h
。/* Look up the first VMA which satisfies addr < vm_end, NULL if none. */ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long addr);
这应该是诀窍:
struct vm_area_struct *vma = find_vma(task->mm, 0x13000); if (vma == NULL) return -EFAULT; if (0x13000 >= vma->vm_end) return -EFAULT;
You're looking for
find_vma
inlinux/mm.h
./* Look up the first VMA which satisfies addr < vm_end, NULL if none. */ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long addr);
This should do the trick:
struct vm_area_struct *vma = find_vma(task->mm, 0x13000); if (vma == NULL) return -EFAULT; if (0x13000 >= vma->vm_end) return -EFAULT;
相关问答
更多-
LINUX 如何查看JPG文件[2022-06-13]
find -
linux内核是否认为它位于特定的物理地址?(Does linux kernel assume that it is located at a particular physical address?)[2021-09-14]
内核确实希望位于特定位置。 该位置是特定于架构的。 您可以重新配置并重新编译内核以进行调整。 我最近正在为x86 / x86_64进行研究,这是有据可查的 。 我希望在那里找到Sparc文档,虽然它不会跳出来。 但是,有些信息可以在这里找到。 相关的一点似乎是: 加载的引导扇区是您在Linux-Sparc系统中的/boot/first.b中找到的,并且是512字节。 它被加载到0x4000地址,它的作用是从磁盘/boot/second.b中检索并将其放入地址0x280000(2.5兆); 选择该地址是因为S ... -
linux内核 - pte_xxx()API在模块编程中不起作用(linux kernel - pte_xxx() API is not working in module programming)[2023-09-16]
对不起,我的源代码另一部分(过程)发生内核恐慌。 以上代码运行良好。 抱歉。 Sorry, my source code another part(procedure) occured kernel panic. Above code works well. sorry. -
为什么内核为用户页面有单独的虚拟地址?(Why does the kernel have a separate virtual address for a user page?)[2021-12-22]
要访问页面,需要将其映射到当前的虚拟地址空间。 因此,如果内核想要访问用户页面,则有两种解决方案: 在我们当前的地址空间,内核的地址空间中映射页面,并确保两个页面表条目保持一致(您不必严格保持一致,但您真的想要)。 切换到已映射该页面的地址空间,即用户自己的地址空间 你的内核似乎在挑选选项1,这对性能来说是一件好事。 切换到另一个地址空间并返回需要相当多的时间。 它可以选择选项2,并在每次想要访问用户页面时切换到用户的地址空间,这可能会通过避免一些簿记使代码更简单,但这将非常慢。 To access a p ... -
linux平台上的mmap查询(mmap query on linux platform)[2022-03-11]
您使用哪种方法取决于您要完成的任务。 (1)设备驱动程序是内核的一部分,因此区分这种方式并没有多大意义。 对于这些情况,设备驱动程序要求从整个内核可用的(物理)内存资源中为自己的内存分配内存。 使用(a),正在分配物理上连续的空间。 如果有一些外部硬件(例如PCI设备)将读取或写入该内存,则可以执行此操作。 kmalloc的返回值已经映射到内核虚拟地址空间。 remap_pfn_range用于将页面映射到当前进程的用户虚拟地址空间。 对于(b),正在分配几乎连续的空间。 如果没有涉及外部硬件,这就是您通常使 ... -
大多数系统定义内核和用户地址空间的逻辑地址范围。 在某些系统上,范围完全取决于操作系统(如何设置页表),而其他系统则由硬件完成。 对于前者,页表通常是嵌套的。 在这种情况下,多个页表共享相同的entires。 对于后者,通常有用户和内核地址空间的单独页表。 如果ELF定义了虚拟地址空间,那么ELF是否也定义了内核虚拟地址空间? 怎么样? [我假设内核虚拟地址空间在运行时动态映射?] 可执行文件仅定义用户地址空间的初始布局。 如果内核地址空间映射到进程地址空间那么为什么进程大小(虚拟)也不包括内核大小呢? 这 ...
-
无法在虚拟地址处理内核分页请求 - 内核OOPS(Unable to handle kernel paging request at virtual address - Kernel OOPS)[2023-06-20]
经过一些折磨之后,我们意识到这很可能是内存控制器的硬件问题,因此很难理解其中存在的是什么以及发生了什么,因为它是随机内存损坏。 After some torture we have realized that this was most likely a hardware issue with memory controller, so the reason why it is very hard to understand what's there and what is happening is tha ... -
传统上,可编译器在编译时被分配固定的虚拟地址映射。 然而,近年来,显而易见的是,这对于安全性是不利的 - 攻击者可以利用他们对内存中事物的确切知识作为漏洞利用的一部分。 为了帮助缓解这种情况,可以使用与位置无关或可重定位的可执行文件来允许加载地址随机化(至少在Linux上)。 但是,这有一个缺点 - 启动程序需要更多时间,因为动态加载程序必须执行重定位(或者在运行时从位置无关的机器代码中存在额外的开销)。 对于OS内核,与其余的引导时间相比,额外的开销是微不足道的; 实际上,Windows内核实际上动态地链 ...
-
使用Linux Kernel Cryptography API for IPSec(Using Linux Kernel Cryptography API for IPSec)[2022-04-16]
仅供记录。 我深入研究了内核代码,发现它只能在那里使用一些特定的加密算法(根据IPSec RFC),并且添加新的块加密算法也会涉及操纵IKE(例如Racoon)。 顺便说一句,只有一个RFC草案用于为IPSec ESP使用流密码(如salsa20),因此使用它们将涉及在其他修改之上实现RFC草案。 Just for record. I dig into the kernel code and found that it's only possible to use some specific encrypt ... -
LInux Kernel API查找vma对应的虚拟地址(LInux Kernel API to find the vma corresponds to a virtual address)[2023-06-12]
你在linux/mm.h寻找linux/mm.h 。 /* Look up the first VMA which satisfies addr < vm_end, NULL if none. */ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long addr); 这应该是诀窍: struct vm_area_struct *vma = find_vma(task->mm, 0x13000); if ...