泰晓科技 -- 聚焦 Linux - 追本溯源,见微知著!
网站地址:https://tinylab.org

泰晓RISC-V实验箱,不会吃灰,开箱即用
请稍侯

泰晓资讯·3月 / 第二期 / 2020

Wang Chen 创作于 2020/03/13

“泰晓资讯”,广泛报道 “Linux/开源” 业界资讯。欢迎广大读者投递相关资讯来源和素材,本站将进一步收集整理后发布给大家。

Linux Lab 即将发布 v0.3,新增中文文档

Linux Lab 是一套用于 Linux 内核学习、开发和测试的即时实验室,可以极速搭建和使用,功能强大,用法简单!大家可以用它来高效地学习处理器架构、Linux 内核、嵌入式 Linux 系统、C 语言编程、Linux 汇编、Shell 编程等。

在经历了 rc1、rc2 和 rc3 三个候选版本后,Linux Lab 将很快发布 v0.3 正式版。据统计,本次 v0.3-rc3 ~ v0.3 之间有 119 笔变更,整个 v0.2 ~ v0.3 之间有 366 笔变更,期间有多位贡献者提交了 Pull Request,参与了项目测试和试用,并提出了改进建议,非常感谢大家的参与和贡献。

主要更新包括:

  • 统一了所有组件的公共操作接口更方便记忆
  • 进一步优化了大型仓库的下载体验
  • 通过添加自动依赖关系简化了命令执行并大幅度提升实验效率
  • 为多本知名 Linux 图书新增了 v2.6.10, v2.6.11, v2.6.12, v2.6.14, v2.6.21, v2.6.24 等多个历史版本内核
  • 发布了首份中文版用户手册

更多精彩信息,请关注 “泰晓科技” 主页官宣。

关键词: Linux Lab, v03

给大家推荐一本好书 《A look at “BPF Performance Tools》

BPF has exploded within the Linux world over the last few years, growing from its networking roots into the go-to tool for running custom in-kernel programs. Its role seems to expand with every kernel release into diverse areas such as security and device control. But none of that is the focus of a relatively new book from Brendan Gregg, BPF Performance Tools; it looks, instead, at how BPF provides visibility into the guts of the kernel. Finding performance bottlenecks of various sorts on (generally large) production systems is an area where BPF and the tool set that has grown up around it can excel; Gregg’s book describes that landscape in great depth.

这几年来 BPF(Berkeley Packet Filter)的应用在 Linux 世界中得到了爆发性的增长,它已不再局限在网络通讯领域,而是成长为一个通用的、在内核中运行定制化程序的方法。它的角色随着内核版本的演进不断在扩张,尤其是在安全(security)和设备控制(device control)领域。

不过在 Brendan Gregg 的新书《BPF Performance Tools》中,这些都不是重点,它的重点是希望通过 BPF 引领大家更好地看透内核的行为。另外,BPF 以及围绕该技术出现的相关工具可以更好地帮助我们定位大规模生产系统(production system)中的瓶颈,Gregg 的书在这个领域也有很深入地介绍。因此通过阅读本书既可以深入了解和学习 BPF 是如何增强 Linux 系统的,也可以作为一本参考书,学习由 Gregg 等人开发的用于分析系统运行的许多工具。

该书去年年底在亚马逊一上架就获得五星好评。感兴趣的读者可以:

  • 阅读 Gregg 先生为本书建立的网站主页:http://www.brendangregg.com/bpf-performance-tools-book.html,
  • 或访问亚马逊网上书店地址:https://www.amazon.com/Performance-Tools-Addison-Wesley-Professional-Computing/dp/0136554822。
  • 或者阅读 LWN 上对这本书的详细介绍: “A look at “BPF Performance Tools”

关键词: A look at BPF Performance Tools

一种优化内核内存管理的新方法 - DAMON

To a great extent, memory management is based on making predictions: which pages of memory will a given process need in the near future? Unfortunately, it turns out that predictions are hard, especially when they are about future events. In the absence of useful information sent back from the future, memory-management subsystems are forced to rely on observations of recent behavior and an assumption that said behavior is likely to continue. The kernel’s memory-management decisions are opaque to user space, though, and often result in less-than-optimal performance. A pair of patch sets from SeongJae Park tries to make memory-usage patterns visible to user space, and to let user space change memory-management decisions in response.

Linux 的内存管理子系统的处理逻辑在很大程度上依靠于对系统未来行为的预测:譬如,通过预测内存中哪些物理页会在近期被某个进程所访问。可惜的是,要把预测做好是一件非常困难的事情,尤其针对未来可能发生的一些事件。由于没有人能将这些将来的信息传递给我们,所以内存管理子系统只能通过观察以往一小段时间内系统的行为并假设这种行为模式会保持下去。由于内核在内存管理上的决策对用户空间来看是透明不可见的,因此我们经常发现这些通过推测所得到的结果在性能上的表现并不是最优的。最近 SeongJae Park 提出了两个补丁,试图将内核中对内存的使用方式暴露给用户空间,从而可以让用户空间对内核的决策进行反馈并进而影响内核的内存管理行为。

这个新机制的核心就是引入一个叫做 data access monitor 的新子系统,简称 DAMON。它可以把内核对内存的访问状态暴露给用户空间。从实现原理上来说,这个操作并不复杂,DAMON 会先把一个进程的地址空间分割成许多同等大小的区域,然后监控对每个区域的访问,输出一个直方图来展示对各个区域的访问次数。读取到这个信息的用户(可以是在用户空间也可以是在内核空间)就可以根据自己的需求,对如何使用这个进程的内存提出优化的建议,供内核内存管理子系统参考。

当然,现实实现情况总是会更加复杂。感兴趣的读者可以阅读原文 “Memory-management optimization with DAMON” 来了解更多实现细节以及社区对该补丁的讨论。

关键词: Linux, memory-management, DAMON

对 Linux 内核中的 Capability 功能的再讨论

Capabilities are a longstanding effort to split apart the traditional Unix superuser’s powers into something more fine-grained, allowing administrators to give limited privileges where needed without making the recipients into full superusers. There are 37 capabilities defined in current Linux kernels, controlling the ability to carry out a range of tasks including configuring terminal devices, overriding resource limits, installing kernel modules, or adjusting the system time. Among these capabilities, though, is CAP_SYS_ADMIN, nominally the capability needed to perform system-administration tasks. CAP_SYS_ADMIN has become the default capability to require when nothing else seems to fit; it enables so many actions that it has long been known as “the new root”.

Linux 中引入 Capabiilty 功能的初衷是希望用它把传统 Unix 里的超级用户的权限拆得更细一些,这样可以让系统管理员给相应的人分配一些特定的权限去执行相应的操作,而不用总是提供给他超级用户的权限。目前 Linux 内核中定义了 37 种 capability,可以用来配置各种许可权限。在这么多种 capability 中,CAP_SYS_ADMIN 是用来进行系统管理工作的。由于在其他各种 capability 都不合适的时候会缺省申请 CAP_SYS_ADMIN,所以它涵盖的权限非常多,被人们称之为 “the new root”。

perf event subsystem (用于性能监控)也一直使用 CAP_SYS_ADMIN 来避免被普通用户调用。所以,当某个用户希望调用 perf_event_open() 这个系统调用时,系统管理员需要给他开放 CAP_SYS_ADMIN,但这么做也就对这个用户开放了诸如挂载文件系统,访问 PCI 配置,调整内存管理策略,加载 BPF 程序等等权限。而通常来说不应该给这个仅仅要做 perf tuning 的用户授予这么多权限。为此,最近社区中 Alexey Bundankov 提交了一个补丁,他创建了一个新的名为 CAP_PERFMON 的 capability,希望以后用这个特定的 capability 开关来管控这些专注于性能监控的任务。

乍一看,这个改动没啥大问题,不就是从一个非常强大的 capabiilty 里面分一个相对无害的 capability 出来么,但是问题还是在于 “兼容性问题”。社区围绕这个补丁进行了深入的讨论。同时对 Linux 中的 capability 这个功能做了展望,未来或许会看到更多人对改进 capability 的权限控制粒度产生兴趣。包括从 CAP_SYS_ADMIN 中分化出更多的权限,不过这些都需要非常非常小心地处理。更多有趣的讨论请详见原文 “CAP_PERFMON — and new capabilities in general”

关键词: Linux, Capabiilty

一组和文件系统相关的新系统调用

Filesystems, by design, hide a lot of complexity from users. At times, though, those users need to be able to look inside the black box and extract information about what is going on within a filesystem. Answering this need is David Howells, the creator of a number of filesystem-oriented system calls; in this patch set he tries to add three more, one of which we have seen before and two of which are new.

文件系统的设计目标是为了面向用户隐藏底层的复杂性。不过有些时候用户又确实希望能看到这个黑盒子里面的信息,了解文件系统内部到底发生了些什么事情。为了这个需求,David Howells 开发了一组补丁,增加了一些新的系统调用。其中两个是全新的。这两个新的系统调用是 watch_mount()watch_sb(),进程可以调用它们来注册申请,以后在挂载点发生变化(由 watch_mount() 负责)或者是在某个特定的已经挂载好的文件系统内部发生变化(由 watch_sb() 负责,这里的 sb 指的是 superblock)的时候,这个进程就能收到通知。

最新版本里面,进程可以调用 pipe2(),传入新增的 O_NOTIFICATION_PIPE 选项,来创建一种特殊的 pipe,应用程序只要对这个管道进行 read 操作,就可以接收到事件通知。

这组补丁已经推出到第 17 版了,这应该能说明很多东西了。大家认为有必要从 kernel 获取一些信息出来,不过目前这些 API 还是有点太复杂,用户比较难于理解。社区还要再观察一段时间看看是否能够解决这个问题。更多介绍参考原文 “watch_mount(), watch_sb(), and fsinfo() (again)”

关键词: Linux, filesystems, system calls

英特尔芯片又爆漏洞了,而且还修不好

An error in chipset read-only memory (ROM) could allow attackers to compromise platform encryption keys and steal sensitive information.

By exploiting vulnerability CVE-2019-0090, a local attacker could extract the chipset key stored on the PCH microchip and obtain access to data encrypted with the key. Worse still, it is impossible to detect such a key breach. With the chipset key, attackers can decrypt data stored on a target computer and even forge its Enhanced Privacy ID (EPID) attestation, or in other words, pass off an attacker computer as the victim’s computer. EPID is used in DRM, financial transactions, and attestation of IoT devices.

继“幽灵”、“熔断”和“僵尸负载”之后,英特尔处理器又双叒被爆料发现存在新的安全漏洞。

近日,网络安全公司 Positive Technologies 警告称,除第十代以外,过去五年的英特尔处理器内部都存在一个未被发现的严重安全漏洞,可能会被用来破坏基于硬件密钥的加密系统。更严重的是,由于该漏洞存在于芯片 mask ROM 中(掩膜型只读存储器),英特尔只能缓解其影响,但无法做到完全修复。用户要想完全规避风险,只能更换不受漏洞影响的处理器,比如最新的英特尔第十代酷睿处理器。

针对安全人员的警告,英特尔的回应似乎轻描淡写。其发言人仅仅是简单建议用户保持系统更新到最新状态。

自 2018 年以来,这已经是英特尔芯片第三次被曝出严重漏洞,而且每次都是硬件或设计缺陷,涉及数代产品。这些问题接二连三地打击了用户对它的信任,如果再不重视,很可能成为数据安全领域的反面教材。

关键词: Intel, vulnerability

联系我们

资讯内容部分来自 “LWN.net“。如果您对某些 LWN 文章感兴趣(譬如希望获得全文翻译的)请扫描二维码加微信联系我们:

tinylab wechat



Read Album:

Read Related:

Read Latest: