怎样上传网站/如何被百度收录

怎样上传网站,如何被百度收录,哈尔滨最新疫情最新消息活动轨迹,php网站忘记后台密码最近在Linux社区看到一个关于内核链表的讨论原文讨论链接:https://lwn.net/SubscriberLink/885941/01fdc39df2ecc25f/先用例子说明怎么使用内核链表list.h/* SPDX-License-Identifier: GPL-2.0 */ #ifndef LIST_H #define LIST_H/** Copied from include/linux/...*…

最近在Linux社区看到一个关于内核链表的讨论

原文讨论链接:

https://lwn.net/SubscriberLink/885941/01fdc39df2ecc25f/

fc0f6d87e3bc063ab0411c8580f61232.png

先用例子说明怎么使用内核链表

list.h

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef LIST_H
#define LIST_H/** Copied from include/linux/...*/#undef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)/*** container_of - cast a member of a structure out to the containing structure* @ptr: the pointer to the member.* @type: the type of the container struct this is embedded in.* @member: the name of the member within the struct.**/
#define container_of(ptr, type, member) ({ \const typeof( ((type *)0)->member ) *__mptr = (ptr); \(type *)( (char *)__mptr - offsetof(type,member) );})struct list_head {struct list_head *next, *prev;
};#define LIST_HEAD_INIT(name) { &(name), &(name) }#define LIST_HEAD(name) \struct list_head name = LIST_HEAD_INIT(name)/*** list_entry - get the struct for this entry* @ptr: the &struct list_head pointer.* @type: the type of the struct this is embedded in.* @member: the name of the list_head within the struct.*/
#define list_entry(ptr, type, member) \container_of(ptr, type, member)/*** list_for_each_entry - iterate over list of given type* @pos: the type * to use as a loop cursor.* @head: the head for your list.* @member: the name of the list_head within the struct.*/
#define list_for_each_entry(pos, head, member) \for (pos = list_entry((head)->next, typeof(*pos), member); \&pos->member != (head); \pos = list_entry(pos->member.next, typeof(*pos), member))/*** list_for_each_entry_safe - iterate over list of given type safe against removal of list entry* @pos: the type * to use as a loop cursor.* @n: another type * to use as temporary storage* @head: the head for your list.* @member: the name of the list_head within the struct.*/
#define list_for_each_entry_safe(pos, n, head, member) \for (pos = list_entry((head)->next, typeof(*pos), member), \n = list_entry(pos->member.next, typeof(*pos), member); \&pos->member != (head); \pos = n, n = list_entry(n->member.next, typeof(*n), member))/*** list_empty - tests whether a list is empty* @head: the list to test.*/
static inline int list_empty(const struct list_head *head)
{return head->next == head;
}/** Insert a new entry between two known consecutive entries.** This is only for internal list manipulation where we know* the prev/next entries already!*/
static inline void __list_add(struct list_head *_new,struct list_head *prev,struct list_head *next)
{next->prev = _new;_new->next = next;_new->prev = prev;prev->next = _new;
}/*** list_add_tail - add a new entry* @new: new entry to be added* @head: list head to add it before** Insert a new entry before the specified head.* This is useful for implementing queues.*/
static inline void list_add_tail(struct list_head *_new, struct list_head *head)
{__list_add(_new, head->prev, head);
}/** Delete a list entry by making the prev/next entries* point to each other.** This is only for internal list manipulation where we know* the prev/next entries already!*/
static inline void __list_del(struct list_head *prev, struct list_head *next)
{next->prev = prev;prev->next = next;
}#define LIST_POISON1 ((void *) 0x00100100)
#define LIST_POISON2 ((void *) 0x00200200)
/*** list_del - deletes entry from list.* @entry: the element to delete from the list.* Note: list_empty() on entry does not return true after this, the entry is* in an undefined state.*/
static inline void list_del(struct list_head *entry)
{__list_del(entry->prev, entry->next);entry->next = (struct list_head*)LIST_POISON1;entry->prev = (struct list_head*)LIST_POISON2;
}
#endif

test.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "list.h"struct stu_example {struct list_head of_node;int age;
};static LIST_HEAD(stu_list_head);
#define LIST_LEN 10int main( )
{int i = 0;/*初始化链表*/struct stu_example stu_list[LIST_LEN];struct stu_example *tmp = NULL;for  (i=0; i < LIST_LEN; i++) {list_add_tail(&stu_list[i],&stu_list_head);stu_list[i].age = i + 20;}/*遍历链表*/ list_for_each_entry(tmp, &stu_list_head, of_node) {printf("age=%d\n",tmp->age);}/*删除链表*/list_del(&stu_list_head);printf("Hello,world\n");return 0;
}

代码输出

1649a901d6d9ab4102543d88c6b19ffc.png

95704eaafa28acc905c781792668d5ab.png

讨论的重点是?

如下图

因为Linux内核用的是C89标准,不能在for循环里面声明变量,所以导致tmp变量在使用之后的代码中还可以继续使用。

继续使用并不是大问题,大问题是因为继续使用导致了一个USB的BUG,当然,从代码的结构性上来说,我觉得也应该做好封装。

cf30457bdfef7b57b33fdf93633f617a.png

9ae6a9fccd91f96ccceeeb879b4ab877.png

根据这个机制,有可能会被程序攻击到内核代码

具体可以查看这个网址

https://www.vusec.net/projects/kasper/

里面的描述和补丁说明差不多,都是因为没有遍历结束退出的原因。

d01c1db16b5938dd3939971448bf7c39.png

73965ab18d9a40cbd17abf62143be8fa.png

修改后的部分补丁

+/* Override the default implementation from linux/nospec.h. */
+#define select_nospec(cond, exptrue, expfalse) \
+({ \
+ typeof(exptrue) _out = (exptrue); \
+ \
+ asm volatile("test %1, %1\n\t"          \
+ "cmove %2, %0"            \
+ : "+r" (_out) \
+ : "r" (cond), "r" (expfalse)); \
+ _out; \
+})
+/* Prevent speculative execution past this barrier. */#define barrier_nospec() alternative("", "lfence", X86_FEATURE_LFENCE_RDTSC)diff --git a/include/linux/list.h b/include/linux/list.h
index dd6c2041d09c..1a1b39fdd122 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -636,7 +636,8 @@ static inline void list_splice_tail_init(struct list_head *list,*/#define list_for_each_entry(pos, head, member) \for (pos = list_first_entry(head, typeof(*pos), member); \
- !list_entry_is_head(pos, head, member); \
+ ({ bool _cond = !list_entry_is_head(pos, head, member); \
+ pos = select_nospec(_cond, pos, NULL); _cond; }); \pos = list_next_entry(pos, member))

具体网址:

https://lwn.net/ml/linux-kernel/20220217184829.1991035-2-jakobkoschel@gmail.com/

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/464456.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

多图上传乱序php,discuz图片顺序混乱解决方案_php技巧

说明discuz在发表帖子的时候&#xff0c;添加多张图片&#xff0c;然后直接发表帖子&#xff0c;图片顺序有时候会乱掉即使上传图片窗口中图片顺序正确&#xff0c;发布之后还是会乱掉分析看url&#xff0c;程序代码中看不出什么将图片名改为序号上传&#xff0c;顺序乱了&…

在.NET中excel导出方法汇总(收集)

http://search.csdn.net/Expert/topic/2346/2346423.xml?temp.3901941http://search.csdn.net/Expert/topic/2387/2387301.xml?temp3.222293E-02http://search.csdn.net/Expert/topic/2581/2581246.xml?temp.9223444http://search.csdn.net/Expert/topic/2414/2414749.xml?…

MongoDB(4)--MongoDB服务的启动

原始方式 只有启动了MongoDB的服务&#xff0c;才能使用MongoDB的功能&#xff0c;通常情况下会开一个命令窗口&#xff0c;输入下面的命令来启动服务&#xff1a; 配置文件方式 如果不想每次启动的时候都在命令行中输入很多繁琐的参数&#xff0c;可以把参数信息保存在配置文件…

我张哥做的这ARM开发板,真酸爽!

本文导读&#xff1a;市场普及度最高的A7处理器&#xff0c;核心板所有设计资料、生产资料全部开放&#xff01;包含核心板原理图、PCB、BOM、uboot源码、Linux内核所有驱动源码、文件系统等&#xff0c;并提供测试与验证方案&#xff01;武汉万象奥科&#xff08;www.vanxoak.…

从单片机转到嵌入式Linux的跨度大吗?

这是我今天一个同学问我的我再零散的说一些观点&#xff0c;如果大家有这方面的经验&#xff0c;也帮忙在文章下留言&#xff0c;谢谢大家。先说共同点单片机和嵌入式他们最终都是要跑硬件的&#xff0c;所以你也会遇到像GPIO口、I2C、串口、SPI、定时器、看门狗这些问题。所以…

有一种豁达叫开源

当人们在讨论开源的时候&#xff0c;第一时间想到的是索取&#xff0c;开源对很多开发者来说是好的事情&#xff0c;但是闭源对很多科技企业是有技术保护作用的。人们对软件的态度是经历过很多次变化的。在现代计算机研发初期&#xff0c;核心问题是硬件&#xff0c;寻找实现记…

用O(1)的时间复杂度删除单链表中的某个节点

用O(1)的时间复杂度删除单链表中的某个节点 给定链表的头指针和一个结点指针&#xff0c;在O(1)时间删除该结点。链表结点的定义如下&#xff1a; struct ListNode {int m_nKey;ListNode* m_pNext; }; 函数的声明如下&#xff1a; void DeleteNode(ListNode* pListHea…

怎么选工作?

选择offer&#xff0c;一直是很困难的事&#xff0c;工作不是餐桌上的美食&#xff0c;你品尝了这个菜还可以去尝那一道菜&#xff0c;所以大家都害怕因为选错一方而失去了更好的机会。而那句「选择大于努力」&#xff0c;让很多人更看重选择。我会经常遇到同学向我咨询offer选…

为了兴趣爱好,我该选嵌入式么?

“绝对不要&#xff01;&#xff01;”“绝对不要&#xff01;&#xff01;”“绝对不要&#xff01;&#xff01;”喜欢听结论的同学们&#xff0c;我说的够清楚了吧&#xff1f;接下来&#xff0c;是为那些喜欢问“为什么”的小好奇们解答疑问的环节。为了让道理变得简单明了…

Sublime Text3(mac)一些插件和快捷键

Sublime Text3&#xff08;mac&#xff09;一些插件和快捷键 楚简约 关注 2017.02.24 17:02* 字数 1216 阅读 412评论 0喜欢 2下载地址http://www.sublimetext.com/3一、安装Package Control按Ctrl 调出console&#xff0c;粘贴下列安装代码到底部命令行并回车&#xff1a; 重…

没去公司上班的这两天

这周得到通知是居家办公&#xff0c;但因为项目的事&#xff0c;前两天去了公司&#xff0c;今天情况特殊&#xff0c;我需要去合作的公司调试&#xff0c;就没去公司。早上还是9点起来&#xff0c;因为合作的公司离我家很近&#xff0c;可以多休息一会。但早早就睁开了眼&…

linux pdm 查看工具,linux系统监控工具

通过系统监控可以了解系统的运行状态、及时发现异常、分析原因、提早解决&#xff0c;避免系统故障&#xff0c;确保用户对系统的感知度和满意度。IPTV系统一般是通过告警管理、日志管理、信令跟踪、探针、诊断测试来实现对系统的监控。小编为大家分享了linux系统监控工具&…

USB抓包

安装的时候需要选上安装完之后&#xff0c;会提示让你重启电脑&#xff0c;如果不重启电脑的话也看不到USB的设备。之后可以通过usb.src来过滤自己想dump的设备信息当然&#xff0c;有一个技巧是&#xff0c;你可以先停止读写你的USB&#xff0c;然后再操作你的USB设备&#xf…

Appium的环境搭建和配置

Appium的环境搭建和配置 一、安装Nodejs 下载nodejs安装包&#xff08;https://nodejs.org/en/download/&#xff09;安装 下载后&#xff0c;双击安装文件&#xff0c;按提示来安装。 测试安装是否成功&#xff1a;运行cmd&#xff0c;输入node –v 二、安装android的SDK 安装…

sqlite3的基本操作

转自&#xff1a;http://blog.chinaunix.net/uid-26833883-id-3239313.html一、数据库基本概念 A.数据(Data)能够输入计算机并能被计算机程序识别和处理的信息集合。B.数据库(Database)数据库是在数据库管理系统管理和控制之下&#xff0c;存放在存储介质上的数据集合。注意&am…

收藏这些芯片原厂的代码仓库

本次给大家分享一些芯片原厂的代码仓库&#xff0c;这些资源已收录到咱们嵌入式大杂烩的资源仓库里了&#xff1a;https://gitee.com/zhengnianli/EmbedSummary我们用到一个新的芯片时&#xff0c;一般在它们的官网都可以找到一些入门、上手的资料。除此之外&#xff0c;有些原…

javascript计算小数保留两位小数,多位小数的方法

<SCRIPT LANGUAGE"JavaScript"><!--functionformatFloat(src, pos){ return Math.round(src*Math.pow(10, pos))/Math.pow(10, pos);}alert(formatFloat("1212.2323", 2));//--></SCRIPT>转载于:https://www.cnblogs.com/catxp/archi…

Android dumpsys命令详细使用

Android dumpsys命令详细使用 一、dumpsys命令介绍 1.命令说明 Dumpsys用户系统诊断&#xff0c;它运行在设备上&#xff0c;并提供系统服务状态信息 命令格式&#xff1a; adb shell dumpsys [system serbices] 2.系统服务查询 如果直接运行adb shell dumpsys&#xff0c;将会…

基于 esp32 + lvgl8.0 的小电视

一个有趣的作品&#xff0c;转给需要的小伙伴。详情可阅读&#xff1a;https://gitee.com/wangpeng25/the-little-bili-tv输入图片说明支持功能微信配网&#xff08;完成&#xff09;时间显示&#xff08;完成&#xff09;三日天气显示&#xff08;完成&#xff09;温湿度显示&…

同步滚动两个DataGrid

拿到这个首先想到的就是重写Scroll方法&#xff0c;可是想想工作量有些大&#xff0c;所以想在Form级别上做做手脚&#xff0c;看看DataGrid的成员列表可以看到这样两个保护性的方法&#xff1a;GridHScrolled Listens for the horizontal scrollbars scroll even…