{"id":112802,"date":"2026-10-04T23:41:07","date_gmt":"2026-10-04T15:41:07","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/112802.html"},"modified":"2026-10-04T23:41:07","modified_gmt":"2026-10-04T15:41:07","slug":"01-%e5%86%85%e6%a0%b8%e6%a8%a1%e5%9d%97%e5%9f%ba%e7%a1%80","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/112802.html","title":{"rendered":"01-\u5185\u6838\u6a21\u5757\u57fa\u7840"},"content":{"rendered":"<\/p>\n<h4>\u5185\u6838\u6a21\u5757\u57fa\u7840<\/h4>\n<ul>\n<li>\u4e00\u3001Hello World&#xff1a;\u6700\u5c0f\u5185\u6838\u6a21\u5757<\/li>\n<li>\n<ul>\n<li>1.1 \u5b8c\u6574\u4ee3\u7801<\/li>\n<li>1.2 \u6bcf\u4e2a\u90e8\u4ef6\u7684\u4f5c\u7528<\/li>\n<li>1.3 \u5173\u4e8e taints kernel<\/li>\n<\/ul>\n<\/li>\n<li>\u4e8c\u3001\u9a71\u52a8\u4f20\u53c2<\/li>\n<li>\n<ul>\n<li>2.1 \u516d\u79cd\u5e38\u7528\u5199\u6cd5\u5bf9\u7167<\/li>\n<li>2.2 module_param_array<\/li>\n<li>2.3 module_param_string<\/li>\n<li>2.4 charp vs string&#xff1a;\u5185\u5b58\u6a21\u578b\u5b8c\u5168\u4e0d\u540c<\/li>\n<\/ul>\n<\/li>\n<li>\u4e09\u3001\u7b26\u53f7\u5bfc\u51fa<\/li>\n<li>\n<ul>\n<li>3.1 \u4e3a\u4ec0\u4e48\u9700\u8981 &#034;\u5bfc\u51fa&#034;<\/li>\n<li>3.2 Module.symvers&#xff1a;\u7b26\u53f7\u7684 &#034;\u901a\u8baf\u5f55&#034;<\/li>\n<li>3.3 \u4f7f\u7528\u65b9\u600e\u4e48\u5199<\/li>\n<\/ul>\n<\/li>\n<li>\u56db\u3001\u5185\u6838\u542f\u52a8\u8fc7\u7a0b\u4e2d\u7684 initcall \u4f18\u5148\u7ea7<\/li>\n<li>\u4e94\u3001kmod&#xff1a;\u6a21\u5757\u7ba1\u7406\u5de5\u5177\u96c6\u4e0e\u81ea\u52a8\u52a0\u8f7d<\/li>\n<\/ul>\n<h2>\u4e00\u3001Hello World&#xff1a;\u6700\u5c0f\u5185\u6838\u6a21\u5757<\/h2>\n<h3>1.1 \u5b8c\u6574\u4ee3\u7801<\/h3>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;linux\/module.h&gt;<\/span>       <span class=\"token comment\">\/* module_init\/exit\u3001MODULE_LICENSE *\/<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;linux\/kernel.h&gt;<\/span>       <span class=\"token comment\">\/* pr_info \u7b49\u6253\u5370 *\/<\/span><\/span><\/p>\n<p><span class=\"token function\">MODULE_LICENSE<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;GPL&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>          <span class=\"token comment\">\/* \u2190 \u5fc5\u987b\u6709 *\/<\/span><\/p>\n<p><span class=\"token keyword\">static<\/span> <span class=\"token keyword\">int<\/span> __init <span class=\"token function\">hello_init<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span>     <span class=\"token comment\">\/* \u52a0\u8f7d\u65f6\u8c03\u7528\u4e00\u6b21 *\/<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">pr_info<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Hello!\\\\n&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span>                          <span class=\"token comment\">\/* \u8fd4\u56de 0 &#061; \u6210\u529f&#xff0c;\u8d1f\u6570 &#061; \u52a0\u8f7d\u5931\u8d25 *\/<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">static<\/span> <span class=\"token keyword\">void<\/span> __exit <span class=\"token function\">hello_exit<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span>    <span class=\"token comment\">\/* \u5378\u8f7d\u65f6\u8c03\u7528\u4e00\u6b21 *\/<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">pr_info<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Bye!\\\\n&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token function\">module_init<\/span><span class=\"token punctuation\">(<\/span>hello_init<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">module_exit<\/span><span class=\"token punctuation\">(<\/span>hello_exit<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<h3>1.2 \u6bcf\u4e2a\u90e8\u4ef6\u7684\u4f5c\u7528<\/h3>\n<table>\n<tr>\u90e8\u4ef6\u4f5c\u7528\u4e0d\u5199\u4f1a\u600e\u6837<\/tr>\n<tbody>\n<tr>\n<td>module_init(fn)<\/td>\n<td>\u6307\u5b9a insmod \u65f6\u8c03\u7528\u7684\u51fd\u6570<\/td>\n<td>\u6a21\u5757\u52a0\u8f7d\u540e\u4ec0\u4e48\u4e5f\u4e0d\u505a<\/td>\n<\/tr>\n<tr>\n<td>module_exit(fn)<\/td>\n<td>\u6307\u5b9a rmmod \u65f6\u8c03\u7528\u7684\u51fd\u6570<\/td>\n<td>\u6a21\u5757\u65e0\u6cd5\u5378\u8f7d<\/td>\n<\/tr>\n<tr>\n<td>MODULE_LICENSE(&#034;GPL&#034;)<\/td>\n<td>\u58f0\u660e\u8bb8\u53ef\u8bc1<\/td>\n<td>\u7f16\u8bd1\u8b66\u544a&#xff1b;\u4e14\u7528\u4e0d\u4e86 EXPORT_SYMBOL_GPL \u7684\u7b26\u53f7<\/td>\n<\/tr>\n<tr>\n<td>__init<\/td>\n<td>\u628a\u4ee3\u7801\u653e\u8fdb .init.text \u6bb5&#xff0c;\u521d\u59cb\u5316\u540e\u53ef\u91ca\u653e<\/td>\n<td>\u53ea\u662f\u5c11\u4e00\u70b9\u5185\u5b58\u4f18\u5316<\/td>\n<\/tr>\n<tr>\n<td>__exit<\/td>\n<td>\u5378\u8f7d\u7528\u4ee3\u7801\u6bb5<\/td>\n<td>\u6a21\u5757\u82e5\u7f16\u8bd1\u8fdb\u5185\u6838&#xff0c;\u8fd9\u6bb5\u4ee3\u7801\u4f1a\u88ab\u4e22\u5f03<\/td>\n<\/tr>\n<tr>\n<td>pr_info()<\/td>\n<td>\u6253\u5370&#xff08;&#061; printk(KERN_INFO &#8230;)&#xff09;<\/td>\n<td>\u65e0\u8f93\u51fa&#xff0c;\u8c03\u8bd5\u5168\u9760\u731c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5173\u4e8e MODULE_LICENSE&#xff1a;\u5185\u6838\u91cc\u5927\u91cf\u7b26\u53f7\u662f\u7528 EXPORT_SYMBOL_GPL \u5bfc\u51fa\u7684&#xff0c;\u53ea\u6709\u58f0\u660e\u4e86 GPL \u517c\u5bb9\u8bb8\u53ef\u8bc1\u7684\u6a21\u5757\u624d\u80fd\u7528\u3002<\/p>\n<p>\u5173\u4e8e init \u8fd4\u56de\u503c&#xff1a;\u8fd4\u56de 0 \u8868\u793a\u6210\u529f&#xff1b;\u8fd4\u56de\u8d1f\u6570&#xff08;\u5982 -ENODEV&#xff09;\u5185\u6838\u4f1a\u62d2\u7edd\u52a0\u8f7d\u5e76\u81ea\u52a8\u8c03\u7528\u6e05\u7406\u3002\u8fd9\u662f\u9a71\u52a8\u91cc \u201c\u786c\u4ef6\u4e0d\u5b58\u5728\u5c31\u653e\u5f03\u52a0\u8f7d\u201d \u7684\u6807\u51c6\u505a\u6cd5\u3002<\/p>\n<h3>1.3 \u5173\u4e8e taints kernel<\/h3>\n<p>hello: loading out-of-tree module taints kernel.      \u2190 \u5916\u90e8\u6a21\u5757\u63d0\u793a&#xff0c;\u65e0\u5bb3<br \/>\n[hello]: Hello!<br \/>\n[hello]: Bye!<\/p>\n<p>\u52a0\u8f7d\u5916\u90e8\u6a21\u5757\u90fd\u4f1a\u6253\u5370\u8fd9\u4e00\u884c&#xff0c;\u610f\u601d\u662f \u201c\u8fd9\u4e2a\u5185\u6838\u88ab\u7b2c\u4e09\u65b9\u6a21\u5757\u78b0\u8fc7\u4e86\u201d\u3002\u5185\u6838\u7ef4\u62a4\u8005\u6536\u5230 bug \u62a5\u544a\u65f6\u82e5\u53d1\u73b0\u5185\u6838\u88ab\u6c61\u67d3&#xff0c;\u4f1a\u8981\u6c42\u5148\u53bb\u6389\u7b2c\u4e09\u65b9\u6a21\u5757\u518d\u590d\u73b0\u3002<\/p>\n<h2>\u4e8c\u3001\u9a71\u52a8\u4f20\u53c2<\/h2>\n<p><span class=\"token keyword\">static<\/span> <span class=\"token keyword\">int<\/span> times <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span>              <span class=\"token comment\">\/* \u2460 \u4e00\u4e2a\u666e\u901a C \u53d8\u91cf *\/<\/span><br \/>\n<span class=\"token function\">module_param<\/span><span class=\"token punctuation\">(<\/span>times<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">0644<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>    <span class=\"token comment\">\/* \u2461 \u8ba9\u5b83\u5728 sysfs \u91cc\u53ef\u89c1 *\/<\/span><br \/>\n<span class=\"token function\">MODULE_PARM_DESC<\/span><span class=\"token punctuation\">(<\/span>times<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\u8bf4\u660e&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>    <span class=\"token comment\">\/* \u2462 \u4e00\u53e5\u6587\u6863 *\/<\/span><\/p>\n<p>\u5b83\u53ea\u505a\u4e24\u4ef6\u4e8b&#xff1a;\u5b9a\u4e49\u53d8\u91cf &#043; \u5728 \/sys\/module\/&lt;\u6a21\u5757\u540d&gt;\/parameters\/&lt;\u53c2\u6570\u540d&gt; \u5efa\u4e00\u4e2a\u6587\u4ef6\u3002<\/p>\n<h3>2.1 \u516d\u79cd\u5e38\u7528\u5199\u6cd5\u5bf9\u7167<\/h3>\n<table>\n<tr>\u5199\u6cd5\u58f0\u660e\u547d\u4ee4\u884c\u7528\u6cd5<\/tr>\n<tbody>\n<tr>\n<td>\u6574\u578b<\/td>\n<td>static int n; module_param(n, int, 0644);<\/td>\n<td>n&#061;5<\/td>\n<\/tr>\n<tr>\n<td>\u5e03\u5c14<\/td>\n<td>static bool b; module_param(b, bool, 0644);<\/td>\n<td>b&#061;1 \/ Y \/ N<\/td>\n<\/tr>\n<tr>\n<td>\u957f\u6574\u578b<\/td>\n<td>static long l; module_param(l, long, 0644);<\/td>\n<td>l&#061;123456<\/td>\n<\/tr>\n<tr>\n<td>\u6570\u7ec4<\/td>\n<td>static int a[8]; int a_n; module_param_array(a, int, &amp;a_n, 0444);<\/td>\n<td>a&#061;1,2,3<\/td>\n<\/tr>\n<tr>\n<td>\u5b57\u7b26\u4e32<\/td>\n<td>static char s[64]; module_param_string(nm, s, sizeof(s), 0644);<\/td>\n<td>nm&#061;&#034;hi&#034;<\/td>\n<\/tr>\n<tr>\n<td>\u5b57\u7b26\u4e32(\u6307\u9488)<\/td>\n<td>static char *p; module_param(p, charp, 0644);<\/td>\n<td>p&#061;hi<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6743\u9650\u4f4d 0644 &#061; \u62e5\u6709\u8005\u53ef\u8bfb\u5199\u3001\u5176\u4ed6\u53ea\u8bfb\u30020444 &#061; \u8c01\u90fd\u53ea\u80fd\u8bfb\u3002<\/p>\n<p>\u4e0a\u9762\u53ea\u662f\u5e38\u7528\u7684 6 \u79cd\u7ec4\u5408\u3002\u771f\u5b9e\u60c5\u51b5\u662f \u201c\u5b8f \u00d7 \u7c7b\u578b\u201d \u7684\u4e58\u79ef&#xff1a;<\/p>\n<ul>\n<li>\u5b8f&#xff1a;\u5e38\u7528\u7684\u5c31 3 \u4e2a \u2014\u2014 module_param \/ module_param_array \/ module_param_string<\/li>\n<li>\u7c7b\u578b&#xff1a;\u5185\u6838 include\/linux\/moduleparam.h \u91cc\u5b9e\u73b0\u4e86 15 \u79cdbyte  short  ushort  int  uint  long  ulong  ullong<br \/>\nhexint  charp  bool  bool_enable_only  invbool  bint  string<br \/>\n \u5176\u4e2d invbool \u662f \u201c\u53d6\u503c\u53d6\u53cd\u201d&#xff08;\u5199 1 \u5f97\u5230 0&#xff09;&#xff0c;bint \u662f\u5e03\u5c14\u7248 int&#xff0c;\u7528\u5f97\u5c11\u3002<\/li>\n<\/ul>\n<h3>2.2 module_param_array<\/h3>\n<p><span class=\"token keyword\">static<\/span> <span class=\"token keyword\">int<\/span> values<span class=\"token punctuation\">[<\/span><span class=\"token number\">8<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">static<\/span> <span class=\"token keyword\">int<\/span> values_n <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span>                                  <span class=\"token comment\">\/* \u5185\u6838\u56de\u586b&#034;\u5b9e\u9645\u4f20\u4e86\u51e0\u4e2a&#034; *\/<\/span><br \/>\n<span class=\"token function\">module_param_array<\/span><span class=\"token punctuation\">(<\/span>values<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>values_n<span class=\"token punctuation\">,<\/span> <span class=\"token number\">0444<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u4f60\u4e0d\u77e5\u9053\u7528\u6237\u4f1a\u4f20\u51e0\u4e2a\u503c&#xff0c;\u6240\u4ee5\u5185\u6838\u628a\u5b9e\u9645\u6570\u91cf\u5199\u56de values_n\u3002\u904d\u5386\u65f6\u5fc5\u987b\u7528\u5b83&#xff0c;\u4e0d\u80fd\u7528 sizeof(values)&#xff08;\u90a3\u4f1a\u5f97\u5230\u5bb9\u91cf 8&#xff0c;\u8bfb\u51fa\u4e00\u5806\u6ca1\u521d\u59cb\u5316\u7684 0&#xff09;\u3002<\/p>\n<h3>2.3 module_param_string<\/h3>\n<p><span class=\"token keyword\">static<\/span> <span class=\"token keyword\">char<\/span> msg<span class=\"token punctuation\">[<\/span><span class=\"token number\">64<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;hello&#034;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">module_param_string<\/span><span class=\"token punctuation\">(<\/span>message<span class=\"token punctuation\">,<\/span> msg<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>msg<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">0644<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\">\/*                  \u2191\u5bf9\u5916\u540d\u5b57  \u2191\u4f60\u7684\u7f13\u51b2\u533a *\/<\/span><\/p>\n<p>\u7b2c 1 \u4e2a\u53c2\u6570\u662f sysfs\/\u547d\u4ee4\u884c\u91cc\u7528\u7684\u540d\u5b57&#xff0c;\u7b2c 2 \u4e2a\u624d\u662f\u4f60\u7684 C \u53d8\u91cf\u3002<\/p>\n<p>insmod lab_params.ko <span class=\"token assign-left variable\">message<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;hi driver&#034;<\/span>     <span class=\"token comment\"># \u7528 message<\/span><br \/>\n<span class=\"token comment\"># [params] message (string) &#061; hi driver<\/span><\/p>\n<h3>2.4 charp vs string&#xff1a;\u5185\u5b58\u6a21\u578b\u5b8c\u5168\u4e0d\u540c<\/h3>\n<table>\n<tr>module_param(p, charp, &#8230;)module_param_string(nm, buf, len, &#8230;)<\/tr>\n<tbody>\n<tr>\n<td>\u53d8\u91cf\u5f62\u6001<\/td>\n<td>char *p \u6307\u9488<\/td>\n<td>char buf[] \u6570\u7ec4<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u5b58\u5f52\u5c5e<\/td>\n<td>\u5185\u6838\u5206\u914d<\/td>\n<td>\u81ea\u5df1\u7684\u7f13\u51b2\u533a<\/td>\n<\/tr>\n<tr>\n<td>\u957f\u5ea6<\/td>\n<td>\u4e0d\u9650<\/td>\n<td>\u53d7 sizeof(buf) \u9650\u5236&#xff0c;\u8d85\u51fa\u622a\u65ad<\/td>\n<\/tr>\n<tr>\n<td>\u80fd\u6539\u5185\u5bb9\u5417<\/td>\n<td>\u274c \u4e0d\u80fd&#xff08;\u53ea\u8bfb&#xff09;<\/td>\n<td>\u2705 \u80fd<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7edd\u5927\u591a\u6570\u60c5\u51b5\u7528 module_param_string&#xff08;\u6709\u8fb9\u754c\u3001\u5b89\u5168\u3001\u53ef\u6539&#xff09;\u3002<\/p>\n<h2>\u4e09\u3001\u7b26\u53f7\u5bfc\u51fa<\/h2>\n<h3>3.1 \u4e3a\u4ec0\u4e48\u9700\u8981 \u201c\u5bfc\u51fa\u201d<\/h3>\n<p>\u5185\u6838\u662f\u5355\u4e00\u5730\u5740\u7a7a\u95f4&#xff1a;\u6240\u6709\u6a21\u5757\u548c\u5185\u6838\u672c\u4f53\u5171\u4eab\u540c\u4e00\u4efd\u5185\u5b58&#xff0c;\u4f60\u7684\u6a21\u5757\u6280\u672f\u4e0a\u80fd \u201c\u770b\u5230\u201d \u5185\u6838\u7684\u4efb\u4f55\u51fd\u6570\u3002\u4f46\u5185\u6838\u8981\u6c42\u5fc5\u987b\u663e\u5f0f\u5bfc\u51fa\u624d\u80fd\u7528&#xff1a;<\/p>\n<p><span class=\"token comment\">\/* \u5728\u5bfc\u51fa\u65b9&#xff08;mod_a&#xff09; *\/<\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">lab_add<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> a<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> b<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token keyword\">return<\/span> a <span class=\"token operator\">&#043;<\/span> b<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">lab_secret<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> x<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token keyword\">return<\/span> x <span class=\"token operator\">*<\/span> <span class=\"token number\">42<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token function\">EXPORT_SYMBOL<\/span><span class=\"token punctuation\">(<\/span>lab_add<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>              <span class=\"token comment\">\/* \u8c01\u90fd\u80fd\u7528 *\/<\/span><br \/>\n<span class=\"token function\">EXPORT_SYMBOL_GPL<\/span><span class=\"token punctuation\">(<\/span>lab_secret<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>       <span class=\"token comment\">\/* \u53ea\u6709 GPL \u6a21\u5757\u80fd\u7528 *\/<\/span><\/p>\n<p>\u6ca1\u5bfc\u51fa\u7684\u51fd\u6570&#xff0c;\u5176\u4ed6\u6a21\u5757\u7f16\u8bd1\u65f6\u5c31\u4f1a\u62a5\u9519\u3002\u8fd9\u5957\u673a\u5236\u662f\u5185\u6838\u7ef4\u6301\u5185\u90e8\u8fb9\u754c\u7684\u624b\u6bb5\u3002<\/p>\n<table>\n<tr>\u5b8f\u8c01\u80fd\u7528<\/tr>\n<tbody>\n<tr>\n<td>EXPORT_SYMBOL()<\/td>\n<td>\u4efb\u4f55\u6a21\u5757<\/td>\n<\/tr>\n<tr>\n<td>EXPORT_SYMBOL_GPL()<\/td>\n<td>\u53ea\u6709 MODULE_LICENSE \u4e3a GPL \u517c\u5bb9\u7684\u6a21\u5757<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>3.2 Module.symvers&#xff1a;\u7b26\u53f7\u7684 \u201c\u901a\u8baf\u5f55\u201d<\/h3>\n<p>\u7f16\u8bd1\u5b8c mod_a \u540e&#xff0c;\u76ee\u5f55\u91cc\u4f1a\u751f\u6210\u4e00\u4e2a\u6587\u4ef6&#xff08;\u5b9e\u6d4b&#xff09;&#xff1a;<\/p>\n<p>$ cat modules\/06-symbols\/Module.symvers<br \/>\n0x00000000  lab_add     &#8230;\/mod_a  EXPORT_SYMBOL<br \/>\n0x00000000  lab_secret  &#8230;\/mod_a  EXPORT_SYMBOL_GPL<\/p>\n<p>\u5b83\u8bb0\u5f55\u4e86 \u201c\u54ea\u4e2a\u6a21\u5757\u5bfc\u51fa\u4e86\u54ea\u4e9b\u7b26\u53f7\u201d\u3002\u540c\u65f6 mod_b.ko \u91cc\u4e5f\u8bb0\u4e0b\u4e86\u81ea\u5df1\u7684\u4f9d\u8d56&#xff1a;<\/p>\n<p>$ modinfo mod_b.ko<br \/>\nname:      mod_b<br \/>\ndepends:   mod_a                 \u2190 \u81ea\u52a8\u5206\u6790\u51fa\u6765\u7684<br \/>\nvermagic:  6.12.111 SMP mod_unload ARMv7 p2v8<\/p>\n<p>\u26a0\ufe0f \u8de8\u76ee\u5f55\u7f16\u8bd1\u5fc5\u987b\u6307\u5b9a\u7b26\u53f7\u8868<\/p>\n<p>\u5982\u679c\u4e24\u4e2a\u6a21\u5757\u5728\u540c\u4e00\u4e2a Makefile \u91cc&#xff08;obj-m :&#061; mod_a.o mod_b.o&#xff09;&#xff0c;\u4e00\u6b21 make \u4f1a\u81ea\u52a8\u5904\u7406\u5b83\u4eec\u4e4b\u95f4\u7684\u4f9d\u8d56\u3002\u4f46\u5982\u679c\u5206\u5728\u4e0d\u540c\u76ee\u5f55&#xff0c;\u7f16\u8bd1 mod_b \u65f6\u5fc5\u987b\u544a\u8bc9\u5b83\u53bb\u54ea\u627e mod_a \u7684\u7b26\u53f7\u8868&#xff0c;\u5426\u5219&#xff08;\u5b9e\u6d4b&#xff09;&#xff1a;<\/p>\n<p>ERROR: modpost: &#034;lab_add&#034; [&#8230;\/mod_b.ko] undefined!<br \/>\nERROR: modpost: &#034;lab_secret&#034; [&#8230;\/mod_b.ko] undefined!<\/p>\n<p>\u89e3\u51b3\u529e\u6cd5 \u2014\u2014 \u5728 mod_b \u7684 Makefile \u91cc\u52a0\u4e00\u884c&#xff1a;<\/p>\n<p>KBUILD_EXTRA_SYMBOLS :&#061; \/path\/to\/mod_a\/Module.symvers<\/p>\n<h3>3.3 \u4f7f\u7528\u65b9\u600e\u4e48\u5199<\/h3>\n<p><span class=\"token comment\">\/* mod_b.c&#xff1a;\u4e0d\u9700\u8981 include \u4efb\u4f55\u5934\u6587\u4ef6&#xff0c;extern \u58f0\u660e\u5373\u53ef *\/<\/span><br \/>\n<span class=\"token keyword\">extern<\/span> <span class=\"token keyword\">int<\/span> <span class=\"token function\">lab_add<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> a<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> b<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">extern<\/span> <span class=\"token keyword\">int<\/span> <span class=\"token function\">lab_secret<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> x<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">static<\/span> <span class=\"token keyword\">int<\/span> __init <span class=\"token function\">mod_b_init<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">pr_info<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;lab_add(3,4) &#061; %d\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token function\">lab_add<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">4<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">pr_info<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;lab_secret(2) &#061; %d\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token function\">lab_secret<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u5b9e\u6d4b\u8f93\u51fa&#xff1a;<\/p>\n<p>[mod_b]   lab_add(3, 4)    &#061; 7<br \/>\n[mod_b]   lab_secret(2)    &#061; 84  (GPL-only \u7b26\u53f7)<\/p>\n<h2>\u56db\u3001\u5185\u6838\u542f\u52a8\u8fc7\u7a0b\u4e2d\u7684 initcall \u4f18\u5148\u7ea7<\/h2>\n<p>\u6e90\u7801\u8c03\u7528\u94fe&#xff08;init\/main.c&#xff09;&#xff1a;<\/p>\n<p>start_kernel()<br \/>\n  \u2514\u2500 rest_init()                        :\u521b\u5efa\u5185\u6838\u7ebf\u7a0b<br \/>\n       \u2514\u2500 kernel_init()                 :\u5185\u6838\u7ebf\u7a0b\u5165\u53e3<br \/>\n            \u2514\u2500 kernel_init_freeable()<br \/>\n                 \u251c\u2500 do_pre_smp_initcalls()       \u2190 \u53ea\u8dd1 early \u7ea7&#xff08;SMP \u542f\u52a8\u524d&#xff09;<br \/>\n                 \u2514\u2500 do_basic_setup()<br \/>\n                      \u251c\u2500 driver_init()           \u2190 \u8bbe\u5907\u6a21\u578b&#xff1a;bus \/ class \/ devtmpfs<br \/>\n                      \u251c\u2500 init_irq_proc()<br \/>\n                      \u251c\u2500 do_ctors()<br \/>\n                      \u2514\u2500 do_initcalls()          \u2190 8 \u4e2a\u7ea7\u522b\u4f9d\u6b21\u6267\u884c<\/p>\n<p>\u516b\u4e2a\u7ea7\u522b&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ init\/main.c&#096;<\/span><br \/>\n<span class=\"token keyword\">static<\/span> <span class=\"token keyword\">const<\/span> <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>initcall_level_names<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> __initdata <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token string\">&#034;pure&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;core&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;postcore&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;arch&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;subsys&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;fs&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;device&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;late&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u6267\u884c\u662f\u4e24\u5c42\u5faa\u73af&#xff1a;\u5916\u5c42\u6309\u7ea7\u522b 0\u21927&#xff0c;\u5185\u5c42\u8dd1\u8be5\u7ea7\u522b\u7684\u6240\u6709\u51fd\u6570\u3002<\/p>\n<table>\n<tr>\u7f16\u53f7\u7ea7\u522b\u5b8f\u5178\u578b\u7528\u9014<\/tr>\n<tbody>\n<tr>\n<td>\u2014<\/td>\n<td>early<\/td>\n<td>early_initcall()<\/td>\n<td>SMP \u542f\u52a8\u524d\u8dd1&#xff08;\u7531 do_pre_smp_initcalls() \u5355\u72ec\u6267\u884c&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>0<\/td>\n<td>pure<\/td>\n<td>pure_initcall()<\/td>\n<td>\u4e0d\u4f9d\u8d56\u4efb\u4f55\u4e1c\u897f\u7684\u7eaf\u521d\u59cb\u5316<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>core<\/td>\n<td>core_initcall()<\/td>\n<td>\u6838\u5fc3\u5b50\u7cfb\u7edf<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>postcore<\/td>\n<td>postcore_initcall()<\/td>\n<td>\u4f9d\u8d56 core \u7684\u7ec4\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>arch<\/td>\n<td>arch_initcall()<\/td>\n<td>\u67b6\u6784\u76f8\u5173\u521d\u59cb\u5316<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>subsys<\/td>\n<td>subsys_initcall()<\/td>\n<td>\u5404\u5b50\u7cfb\u7edf&#xff08;\u5982 I2C\u3001SPI \u603b\u7ebf\u6838\u5fc3&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>fs<\/td>\n<td>fs_initcall()<\/td>\n<td>\u6587\u4ef6\u7cfb\u7edf\u3001\u7f51\u7edc\u534f\u8bae\u6808<\/td>\n<\/tr>\n<tr>\n<td>6<\/td>\n<td>device<\/td>\n<td>device_initcall() &#061; module_init()<\/td>\n<td>\u8bbe\u5907\u9a71\u52a8&#xff08;\u6570\u91cf\u6700\u591a&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>7<\/td>\n<td>late<\/td>\n<td>late_initcall()<\/td>\n<td>\u6536\u5c3e&#xff08;\u5982\u91ca\u653e __init \u5185\u5b58\u524d\u6700\u540e\u505a\u7684\u4e8b&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5e26 _sync \u540e\u7f00\u7684\u5b8f&#xff08;\u5982 device_initcall_sync&#xff09;\u5728\u540c\u4e00\u7ea7\u522b\u5185&#xff0c;\u6392\u5728\u4e0d\u5e26 sync \u7684\u4e4b\u540e&#xff0c;\u7528\u4e8e\u540c\u4e00\u7ea7\u522b\u5185\u7684\u4e8c\u6b21\u6392\u5e8f\u3002<\/p>\n<p>**module_init \u5230\u5e95\u662f\u54ea\u4e00\u7ea7&#xff1f;\u2014\u2014 \u7b2c 6 \u7ea7 device&#xff0c;\u5b9a\u4e49\u94fe&#xff08;include\/linux\/init.h&#xff09;&#xff1a;<\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">define<\/span> <span class=\"token macro-name function\">module_init<\/span><span class=\"token expression\"><span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">)<\/span>   <span class=\"token function\">__initcall<\/span><span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">define<\/span> <span class=\"token macro-name function\">__initcall<\/span><span class=\"token expression\"><span class=\"token punctuation\">(<\/span>fn<span class=\"token punctuation\">)<\/span>   <span class=\"token function\">device_initcall<\/span><span class=\"token punctuation\">(<\/span>fn<span class=\"token punctuation\">)<\/span><\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">define<\/span> <span class=\"token macro-name function\">device_initcall<\/span><span class=\"token expression\"><span class=\"token punctuation\">(<\/span>fn<span class=\"token punctuation\">)<\/span>  <span class=\"token function\">__define_initcall<\/span><span class=\"token punctuation\">(<\/span>fn<span class=\"token punctuation\">,<\/span> <span class=\"token number\">6<\/span><span class=\"token punctuation\">)<\/span><\/span><\/span><\/p>\n<p>\u6240\u4ee5 module_init \u5c31\u662f device_initcall&#xff0c;\u7f16\u53f7 6&#xff0c;\u6392\u5728\u5012\u6570\u7b2c\u4e8c\u3002<\/p>\n<p>\u8fd9\u4e5f\u89e3\u91ca\u4e86 device \u7ea7\u7684 initcall \u6570\u91cf\u8fdc\u8d85\u5176\u4ed6\u7ea7\u522b \u2014\u2014 \u7edd\u5927\u591a\u6570\u9a71\u52a8\u90fd\u7528\u5b83\u3002<\/p>\n<h2>\u4e94\u3001kmod&#xff1a;\u6a21\u5757\u7ba1\u7406\u5de5\u5177\u96c6\u4e0e\u81ea\u52a8\u52a0\u8f7d<\/h2>\n<p>kmod \u662f Linux \u5b98\u65b9\u7684\u5185\u6838\u6a21\u5757\u7ba1\u7406\u5de5\u5177\u96c6&#xff0c;\u6240\u6709\u547d\u4ee4\u90fd\u662f\u6307\u5411\u540c\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u7684\u7b26\u53f7\u94fe\u63a5&#xff0c;\u9760 \u201c\u88ab\u53eb\u6210\u4ec0\u4e48\u540d\u5b57\u201d \u51b3\u5b9a\u884c\u4e3a&#xff1a;<\/p>\n<p>lsmod \/ modprobe \/ insmod \/ rmmod \/ depmod \/ modinfo \u5168\u90e8 \u2192 \/usr\/bin\/kmod<\/p>\n<p>\u516d\u4e2a\u547d\u4ee4\u5404\u505a\u4ec0\u4e48<\/p>\n<table>\n<tr>\u547d\u4ee4\u4f5c\u7528\u5403\u4ec0\u4e48\u53c2\u6570<\/tr>\n<tbody>\n<tr>\n<td>lsmod<\/td>\n<td>\u5217\u51fa\u5df2\u52a0\u8f7d\u7684\u6a21\u5757&#xff08;\u672c\u8d28\u662f\u683c\u5f0f\u5316 \/proc\/modules&#xff09;<\/td>\n<td>\u65e0<\/td>\n<\/tr>\n<tr>\n<td>insmod<\/td>\n<td>\u52a0\u8f7d\u6a21\u5757&#xff0c;\u4e0d\u7ba1\u4f9d\u8d56<\/td>\n<td>.ko \u6587\u4ef6\u8def\u5f84<\/td>\n<\/tr>\n<tr>\n<td>rmmod<\/td>\n<td>\u5378\u8f7d\u6a21\u5757&#xff0c;\u88ab\u522b\u4eba\u5f15\u7528\u65f6\u4f1a\u5931\u8d25<\/td>\n<td>\u6a21\u5757\u540d<\/td>\n<\/tr>\n<tr>\n<td>modinfo<\/td>\n<td>\u67e5\u770b .ko \u7684\u5143\u4fe1\u606f&#xff08;\u4e0d\u7528\u52a0\u8f7d\u5c31\u80fd\u770b&#xff09;<\/td>\n<td>.ko \u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>depmod<\/td>\n<td>\u626b\u63cf\u6a21\u5757\u76ee\u5f55&#xff0c;\u751f\u6210\u4f9d\u8d56\u8868&#xff08;\u5efa\u7d22\u5f15&#xff0c;\u4e0d\u52a0\u8f7d&#xff09;<\/td>\n<td>\u76ee\u5f55<\/td>\n<\/tr>\n<tr>\n<td>modprobe<\/td>\n<td>\u667a\u80fd\u52a0\u8f7d\/\u5378\u8f7d&#xff1a;\u6309\u540d\u5b57\u6216\u522b\u540d&#xff0c;\u81ea\u52a8\u5904\u7406\u4f9d\u8d56<\/td>\n<td>\u6a21\u5757\u540d\u6216\u522b\u540d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>lsmod \u2014\u2014 \u770b\u73b0\u5728\u88c5\u4e86\u4ec0\u4e48<\/p>\n<p>lsmod<br \/>\n<span class=\"token comment\"># Module        Size   Used by<\/span><br \/>\n<span class=\"token comment\"># mod_b        12288  0<\/span><br \/>\n<span class=\"token comment\"># mod_a        12288  1 mod_b          \u2190 \u88ab mod_b \u5f15\u7528 1 \u6b21<\/span><\/p>\n<ul>\n<li>\u4e09\u5217\u4f9d\u6b21\u662f&#xff1a;\u6a21\u5757\u540d\u3001\u5360\u7528\u5185\u5b58\u3001\u88ab\u5f15\u7528\u6b21\u6570 &#043; \u88ab\u8c01\u5f15\u7528\u3002<\/li>\n<\/ul>\n<p>insmod \u2014\u2014 \u52a0\u8f7d&#xff08;\u4f9d\u8d56\u5f97\u81ea\u5df1\u4fdd\u8bc1&#xff09;<\/p>\n<p>insmod \/mnt\/host\/modules\/01-hello\/hello.ko<\/p>\n<ul>\n<li>\u53c2\u6570\u662f\u6587\u4ef6\u8def\u5f84<\/li>\n<li>\u540e\u9762\u53ef\u4ee5\u76f4\u63a5\u8ddf\u6a21\u5757\u53c2\u6570<\/li>\n<li>\u274c \u4e0d\u89e3\u6790\u4f9d\u8d56\u2014\u2014\u4f9d\u8d56\u6ca1\u52a0\u8f7d\u5c31\u62a5 Unknown symbol<\/li>\n<\/ul>\n<p>rmmod \u2014\u2014 \u5378\u8f7d<\/p>\n<p>rmmod hello<\/p>\n<ul>\n<li>\u53c2\u6570\u662f\u6a21\u5757\u540d<\/li>\n<li>\u88ab\u522b\u7684\u6a21\u5757\u5f15\u7528\u65f6\u5931\u8d25&#xff1a;Resource temporarily unavailable<\/li>\n<\/ul>\n<p>modinfo \u2014\u2014 \u4e0d\u5f00\u673a\u4e5f\u80fd\u770b\u6a21\u5757\u4fe1\u606f<\/p>\n<p>modinfo hello.ko<br \/>\n<span class=\"token comment\"># filename:  &#8230;\/hello.ko<\/span><br \/>\n<span class=\"token comment\"># license:   GPL<\/span><br \/>\n<span class=\"token comment\"># depends:                                     \u2190 \u4f9d\u8d56\u54ea\u4e9b\u6a21\u5757<\/span><br \/>\n<span class=\"token comment\"># vermagic:  6.12.111 SMP mod_unload ARMv7 p2v8   \u2190 \u7248\u672c\u6307\u7eb9<\/span><br \/>\n<span class=\"token comment\"># parm:      times: (int) \u6253\u5370\u6b21\u6570<\/span><\/p>\n<ul>\n<li>\u6700\u5e38\u770b\u4e24\u9879&#xff1a;depends&#xff08;\u4f9d\u8d56&#xff09;\u548c vermagic&#xff08;\u548c\u5185\u6838\u7248\u672c\u5bf9\u4e0d\u5bf9\u5f97\u4e0a&#xff09;\u3002<\/li>\n<\/ul>\n<p>depmod \u2014\u2014 \u5efa\u7acb\u4f9d\u8d56\u8868<\/p>\n<p>depmod <span class=\"token parameter variable\">-a<\/span>          <span class=\"token comment\"># \u626b\u63cf \/lib\/modules\/$(uname -r)\/&#xff0c;\u751f\u6210 modules.dep<\/span><\/p>\n<p>\u5b83\u672c\u8eab\u4e0d\u52a0\u8f7d\u4efb\u4f55\u4e1c\u897f&#xff0c;\u53ea\u662f\u5efa\u7d22\u5f15\u3002\u751f\u6210\u7684 modules.dep \u957f\u8fd9\u6837&#xff1a;<\/p>\n<p>extra\/mod_b.ko: extra\/mod_a.ko      \u2190 \u5192\u53f7\u53f3\u8fb9 &#061; \u5b83\u4f9d\u8d56\u8c01<br \/>\nextra\/mod_a.ko:<\/p>\n<ul>\n<li>modprobe \u5c31\u662f\u9760\u8fd9\u5f20\u8868\u77e5\u9053 \u201c\u88c5 mod_b \u4e4b\u524d\u5f97\u5148\u88c5 mod_a\u201d\u3002<\/li>\n<\/ul>\n<p>modprobe \u2014\u2014 \u65e5\u5e38\u6700\u5e38\u7528<\/p>\n<p>modprobe mod_b        <span class=\"token comment\"># \u53ea\u8bf4\u8981 mod_b&#xff0c;mod_a \u81ea\u52a8\u5e26\u4e0a<\/span><br \/>\nmodprobe <span class=\"token parameter variable\">-r<\/span> mod_b     <span class=\"token comment\"># \u5378\u8f7d&#xff0c;\u5e76\u628a\u4e0d\u518d\u88ab\u4f9d\u8d56\u7684\u4e00\u8d77\u5378\u6389<\/span><\/p>\n<ul>\n<li>\u53c2\u6570\u662f\u6a21\u5757\u540d<\/li>\n<li>\u6a21\u5757\u5fc5\u987b\u653e\u5728 \/lib\/modules\/$(uname -r)\/ \u4e0b<\/li>\n<li>\u2705 \u9012\u5f52\u52a0\u8f7d\u4f9d\u8d56\u3001-r \u53cd\u5411\u5378\u8f7d&#xff0c;\u5168\u81ea\u52a8<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u5185\u6838\u6a21\u5757\u57fa\u7840\u4e00\u3001Hello World&#xff1a;\u6700\u5c0f\u5185\u6838\u6a21\u57571.1 \u5b8c\u6574\u4ee3\u78011.2 \u6bcf\u4e2a\u90e8\u4ef6\u7684\u4f5c\u75281.3 \u5173\u4e8e taints kernel\u4e8c\u3001\u9a71\u52a8\u4f20\u53c22.1 \u516d\u79cd\u5e38\u7528\u5199\u6cd5\u5bf9\u71672.2 module_param_array2.3 module_param_string2.4 charp vs string&#xff1a;\u5185\u5b58\u6a21\u578b\u5b8c\u5168\u4e0d\u540c\u4e09\u3001\u7b26\u53f7\u5bfc\u51fa3.1 \u4e3a\u4ec0\u4e48\u9700\u8981 \\&#8221;\u5bfc\u51fa\\&#8221;3.2 Module.symvers&#xff1a;\u7b26\u53f7\u7684 \\&#8221;\u901a\u8baf\u5f55\\&#8221;3.3 \u4f7f\u7528\u65b9\u600e\u4e48\u5199\u56db\u3001\u5185\u6838\u542f<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[58,371,305,1363],"topic":[],"class_list":["post-112802","post","type-post","status-publish","format-standard","hentry","category-server","tag-linux","tag-371","tag-305","tag-1363"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>01-\u5185\u6838\u6a21\u5757\u57fa\u7840 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/112802.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"01-\u5185\u6838\u6a21\u5757\u57fa\u7840 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u5185\u6838\u6a21\u5757\u57fa\u7840\u4e00\u3001Hello World&#xff1a;\u6700\u5c0f\u5185\u6838\u6a21\u57571.1 \u5b8c\u6574\u4ee3\u78011.2 \u6bcf\u4e2a\u90e8\u4ef6\u7684\u4f5c\u75281.3 \u5173\u4e8e taints kernel\u4e8c\u3001\u9a71\u52a8\u4f20\u53c22.1 \u516d\u79cd\u5e38\u7528\u5199\u6cd5\u5bf9\u71672.2 module_param_array2.3 module_param_string2.4 charp vs string&#xff1a;\u5185\u5b58\u6a21\u578b\u5b8c\u5168\u4e0d\u540c\u4e09\u3001\u7b26\u53f7\u5bfc\u51fa3.1 \u4e3a\u4ec0\u4e48\u9700\u8981 &quot;\u5bfc\u51fa&quot;3.2 Module.symvers&#xff1a;\u7b26\u53f7\u7684 &quot;\u901a\u8baf\u5f55&quot;3.3 \u4f7f\u7528\u65b9\u600e\u4e48\u5199\u56db\u3001\u5185\u6838\u542f\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/112802.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-04T15:41:07+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/112802.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/112802.html\",\"name\":\"01-\u5185\u6838\u6a21\u5757\u57fa\u7840 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-04T15:41:07+00:00\",\"dateModified\":\"2026-10-04T15:41:07+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/112802.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/112802.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/112802.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"01-\u5185\u6838\u6a21\u5757\u57fa\u7840\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"01-\u5185\u6838\u6a21\u5757\u57fa\u7840 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/112802.html","og_locale":"zh_CN","og_type":"article","og_title":"01-\u5185\u6838\u6a21\u5757\u57fa\u7840 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u5185\u6838\u6a21\u5757\u57fa\u7840\u4e00\u3001Hello World&#xff1a;\u6700\u5c0f\u5185\u6838\u6a21\u57571.1 \u5b8c\u6574\u4ee3\u78011.2 \u6bcf\u4e2a\u90e8\u4ef6\u7684\u4f5c\u75281.3 \u5173\u4e8e taints kernel\u4e8c\u3001\u9a71\u52a8\u4f20\u53c22.1 \u516d\u79cd\u5e38\u7528\u5199\u6cd5\u5bf9\u71672.2 module_param_array2.3 module_param_string2.4 charp vs string&#xff1a;\u5185\u5b58\u6a21\u578b\u5b8c\u5168\u4e0d\u540c\u4e09\u3001\u7b26\u53f7\u5bfc\u51fa3.1 \u4e3a\u4ec0\u4e48\u9700\u8981 \"\u5bfc\u51fa\"3.2 Module.symvers&#xff1a;\u7b26\u53f7\u7684 \"\u901a\u8baf\u5f55\"3.3 \u4f7f\u7528\u65b9\u600e\u4e48\u5199\u56db\u3001\u5185\u6838\u542f","og_url":"https:\/\/www.wsisp.com\/helps\/112802.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-04T15:41:07+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/112802.html","url":"https:\/\/www.wsisp.com\/helps\/112802.html","name":"01-\u5185\u6838\u6a21\u5757\u57fa\u7840 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-04T15:41:07+00:00","dateModified":"2026-10-04T15:41:07+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/112802.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/112802.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/112802.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"01-\u5185\u6838\u6a21\u5757\u57fa\u7840"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/112802","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=112802"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/112802\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=112802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=112802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=112802"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=112802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}