{"id":340458,"date":"2021-02-10T12:34:58","date_gmt":"2021-02-10T04:34:58","guid":{"rendered":"http:\/\/4563.org\/?p=340458"},"modified":"2021-02-10T12:34:58","modified_gmt":"2021-02-10T04:34:58","slug":"linux-%e4%b8%8b%e7%9a%84%e5%91%bd%e5%90%8d%e7%ae%a1%e9%81%93%e5%a6%82%e4%bd%95%e9%99%90%e5%88%b6%e5%85%b6%e5%ae%83%e8%bf%9b%e7%a8%8b%e8%ae%bf%e9%97%ae%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=340458","title":{"rendered":"Linux \u4e0b\u7684\u547d\u540d\u7ba1\u9053\u5982\u4f55\u9650\u5236\u5176\u5b83\u8fdb\u7a0b\u8bbf\u95ee\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Linux \u4e0b\u7684\u547d\u540d\u7ba1\u9053\u5982\u4f55\u9650\u5236\u5176\u5b83\u8fdb\u7a0b\u8bbf\u95ee\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : mingl0280 <\/span>  <span><i><\/i> 2<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6709\u4e2a\u9700\u6c42\u5982\u4e0b\uff1a Linux \u4e0b\u8fdb\u7a0b A \uff08\u7279\u6743\uff09\u662f\u7cfb\u7edf\u5185\u552f\u4e00\u7684\u7ba1\u9053\u8bfb\u53d6\u65b9\uff0c\u5982\u679c\u6709\u5176\u5b83\u8fdb\u7a0b\u8bd5\u56fe\u5728\u540c\u4e00\u4e2a\u7ba1\u9053\u4e0a\u8bd5\u56fe\u8bfb\u53d6\uff0c\u5219\u62a5\u9519\u9000\u51fa\u3002\u5305\u62ec\u5176\u5b83 root \u8fdb\u7a0b\u90fd\u4e0d\u5e94\u8be5\u80fd\u8bfb\u53d6\u8fd9\u4e2a\u7ba1\u9053\u3002<\/p>\n<p>\u6211\u73b0\u5728\u6d4b\u8bd5\u4e86\u4e0b\u5982\u679c\u6211\u6b63\u5e38\u5f00\u7ba1\u9053\u7684\u8bdd\uff0ccat \u8fd8\u662f\u80fd\u8bfb\u53d6\u8be5\u7ba1\u9053\u3002\u5982\u679c\u521b\u5efa\u7ba1\u9053\u540e\u5220\u9664\u7ba1\u9053\u6587\u4ef6\u5e76\u4e14\u8c03\u7528 flock \u52a0\u4e0a\u72ec\u5360\u9501\uff08\u5728\u8bfb\u53d6\u8fdb\u7a0b\u91cc\uff09\uff0c\u53bb \/proc\/pid\/fd \u4e0b\u9762\u4f9d\u65e7\u80fd\u4f7f\u7528 cat \u5bf9\u7ba1\u9053\u6267\u884c\u7b2c\u4e8c\u4e2a\u8bfb\u53d6\u64cd\u4f5c\u2026\u2026\uff08 cat \u597d\u50cf\u662f\u7528\u7684 ioctl \uff1f\uff09 \u8bf7\u95ee\u6709\u6ca1\u6709\u529e\u6cd5\u628a\u8fd9\u4e24\u4e2a\u5730\u65b9\u90fd\u9501\u4e0a\u6216\u8005\u4e0d\u8ba9\u8bfb\u53d6\uff1f\u4f8b\u5982\u4f7f\u7528 ioctl \u4e4b\u7c7b\u7684\uff08\u5bf9\u8fd9\u4e2a\u771f\u7684\u4e0d\u719f\uff09\uff0c\u6216\u8005\u8fd9\u4e2a\u8bbe\u8ba1\u672c\u8eab\u6709\u95ee\u9898\uff0c\u9700\u8981\u6362\u4e00\u79cd\u5b9e\u73b0\u65b9\u5f0f\uff1f<\/p>\n<p>\u8c22\u8c22\u3002<\/p>\n<p>p.s.\u6d4b\u8bd5\u7528\u5230\u7684\u4ee3\u7801\u5982\u4e0b\uff1a https:\/\/gist.github.com\/mingl0280\/c6d7e88bc3e0c8079498b20ab9afddf3<\/p>\n<p>\u8bfb\u53d6\u65b9: https:\/\/gist.github.com\/mingl0280\/c6d7e88bc3e0c8079498b20ab9afddf3#file-reader_side-cpp<\/p>\n<p>\u5199\u5165\u65b9\uff1a https:\/\/gist.github.com\/mingl0280\/c6d7e88bc3e0c8079498b20ab9afddf3#file-writer_side-cpp<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>14<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5263883\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : gyf304 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             flock \u662f advisory \u7684 \u4e0d\u5f3a\u5236\u9501\u4e0a\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5263884\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : mingl0280 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @gyf304 \u8fd9\u5c31\u5f88\u86cb\u75bc\u4e86\uff0cWindows \u4e0b\u9762\u6211\u8bb0\u5f97\u662f\u5f00 named pipe \u7684\u65f6\u5019\u6709\u4e2a flag\uff0c\u53ef\u4ee5\u7981\u6b62\u91cd\u590d\u6253\u5f00\u540c\u4e00\u4e2a\u7ba1\u9053\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5263885\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wevsty <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u4ee5\u7528 apparmor \u6216\u8005 SELinux \u6765\u9650\u5236\u5176\u4ed6\u7a0b\u5e8f open                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5263886\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : BlackL <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             [fcntl]( https:\/\/man7.org\/linux\/man-pages\/man2\/fcntl.2.html)\u6587\u6863\u91cc\u6709\u63d0\u5230\u5f3a\u5236\u9501\uff08 Mandatory locking \uff09\uff0c\u53ef\u4ee5\u770b\u4e00\u4e0b\uff0c\u4f3c\u4e4e\u5f00\u542f\u6761\u4ef6\u6709\u70b9\u82db\u523b\uff0c\u800c\u4e14\u4e5f\u652f\u6301\u7684\u4e0d\u597d\uff0chttps:\/\/gavv.github.io\/articles\/file-locks\/ \u8fd9\u91cc\u6709\u793a\u4f8b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5263887\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : BlackL <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/man7.org\/linux\/man-pages\/man2\/fcntl.2.html                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5263888\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ysc3839 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @mingl0280 \u5370\u8c61\u4e2d Windows \u7684 Named Pipe \u66f4\u7c7b\u4f3c Unix socket\uff0c\u9700\u8981\u670d\u52a1\u5668\u8fdb\u884c\u7c7b\u4f3c accept \u7684\u64cd\u4f5c (ConnectNamedPipe)\uff0c\u5ba2\u6237\u7aef\u624d\u80fd\u8fde\u63a5\u4e0a\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5263889\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : mingl0280 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @BlackL \u5bf9\u7684\uff0c\u8981\u91cd\u65b0\u6302\u8f7d\u6587\u4ef6\u7cfb\u7edf\uff0c\u6839\u672c\u6ca1\u6cd5\u6574\u8fd9\u4e2a\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5263890\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : no1xsyzy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5728\u540c\u4e00\u4e2a\u5185\u6838\uff0c\u5176\u4ed6 root \u4e5f\u4e0d\u80fd\u8bfb\u5c31\u53ea\u6709 AppArmor \u548c SELinux \u4e86\u3002<\/p>\n<p>\u585e\u5bb9\u5668\u91cc\u53ef\u4ee5\u4fdd\u8bc1\u5176\u4ed6\u5bb9\u5668\u91cc\u7684\u8bfb\u4e0d\u4e86\uff0c\u4f46\u662f\u4e3b\u673a\u53ef\u4ee5\u8bfb\u3002<\/p>\n<p>\u6781\u7aef\u70b9\uff0c\u865a\u62df\u673a\uff0c\u90a3\u6837\u7684\u8bdd\u7ba1\u9053\u6240\u5728\u7684\u547d\u540d\u7a7a\u95f4\u90fd\u4e0d\u4e00\u6837\uff08\u751a\u81f3\u4e0d\u5728\u540c\u4e00\u4e2a\u5185\u6838\u91cc\uff09\u3002<\/p>\n<p>@mingl0280 #7 \u91cd\u65b0\u6302\u8f7d\u6587\u4ef6\u7cfb\u7edf\u53ef\u5426\u7528 tmpfs \u6302\u4e00\u4e2a \/run\/xxx \uff1f\u90a3\u6837\u91cd\u65b0\u6302\u8f7d\u7684\u8303\u56f4\u5c0f\u5f88\u591a\u4e86\u3002<\/p>\n<p>\u5982\u679c\u4e24\u8fb9\u7684\u7a0b\u5e8f\u90fd\u53ef\u4ee5\u4fee\u6539\uff0c\u4e5f\u53ea\u9700\u8981\u4fdd\u8bc1 Confidentiality \u7684\u8bdd\uff0c\u53ef\u4ee5\u4e24\u8fb9\u52a0\u4e2a\u5bc6\uff08 D-H \u5bc6\u94a5\u4ea4\u6362 + AES \uff09\uff08\u5927\u6982\u6709\u70b9 overkill \uff09                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5263891\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : mingl0280 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @no1xsyzy \u52a0\u5bc6\u6ee1\u8db3\u4e0d\u4e86\u6027\u80fd\u9700\u6c42\uff08\u677f\u5b50\u6027\u80fd\u5f31\uff0c\u5b9a\u5236\u88c1\u526a\u7248 IOT \u8bbe\u5907\uff09\uff0cramfs \u8003\u8651\u8fc7\u4f46\u662f ramfs \u6302\u8f7d\u5f97\u6539\u7cfb\u7edf\u5185\u6838\uff0c\u4e5f\u5f88\u9ebb\u70e6\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5263892\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : no1xsyzy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @mingl0280 ramfs tmpfs SELinux AppArmor \u6709\u4e00\u4e2a\u5c31\u884c\u4e86\u5427\uff0c\u5185\u6838\u90fd\u88ab\u88c1\u4e5f\u592a\u60e8\u4e86<br \/>\u6216\u8005\u6709 loop \u5f04\u4e2a\u6587\u4ef6 mount -o rw,loop,mand \uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5263893\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : codehz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u662f\uff0c\u4f60\u7ec8\u7aef\u65b9\u9762\u9632\u7834\u89e3\u6709\u7528\u5417\u3002\u3002\u3002\u6709 root \u4eba\u5bb6\u76f4\u63a5\u8bfb\u5199\u5185\u5b58\u5c31\u80fd dump \u51fa\u6765\u4e86\u554a\u3002<br \/>\u8fd9\u4e2a\u601d\u8def\u5c31\u5f88\u6709\u95ee\u9898\u3002\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5263894\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : mingl0280 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @codehz memory dump \u7684\u6280\u672f\u9700\u6c42\u6bd4 cat \u4e00\u4e2a\u6587\u4ef6\u9ebb\u70e6\u591a\u4e86\uff0c\u5982\u679c\u8bf4\u76f4\u63a5\u66b4\u529b\u8bbf\u95ee\u5185\u5b58\u7684\u6280\u672f\u96be\u5ea6\u662f 100\uff0ccat \u4e00\u4e2a\u6587\u4ef6\u7684\u96be\u5ea6\u5c31\u662f 1 \u3002<br \/>\u800c\u4e14\u8fd9\u4e2a\u9700\u6c42\u5176\u5b9e\u662f\u4e2a\u8de8\u5e73\u53f0\u9700\u6c42\uff08\u540c\u6837\u7684\u4ee3\u7801\u9700\u8981\u8dd1\u5728\u4e00\u4e2a\u5f88\u4f4e\u6027\u80fd\u7684\u677f\u5b50\u4e0a\u548c\u4efb\u610f\u4e00\u5957 Linux \u4e0a\uff09\uff0c\u52a0\u4e0a\u9632\u7684\u6839\u672c\u4e0d\u662f\u5185\u5b58 dump \uff08\u5bf9\uff0c\u4f60\u627e\u9519\u4e86\u65b9\u5411\uff0c\u6839\u672c\u4e0d\u662f\u9632\u7834\u89e3\u800c\u662f\u9632\u7684\u5ba2\u6237\u7684\u9017\u903c\u4ee3\u7801\uff09\u800c\u662f\u5ba2\u6237\u5982\u679c\u5199\u4e86\u4e00\u4e2a\u6216\u591a\u4e2a root \u8fdb\u7a0b\u8bd5\u56fe\u4e24\u6b21\u6253\u5f00\u8fd9\u4e2a\u7ba1\u9053\u5e76\u884c\u6267\u884c\u547d\u4ee4\u2026\u2026\u6211\u4eec\u8fd9\u4e2a\u4ee3\u7801\u5e76\u4e0d\u9700\u8981\u9632\u7834\u89e3\uff0c\u53cd\u800c\u56e0\u4e3a\u5ba2\u6237\u8de8\u5168\u7403 N \u79cd\u8bed\u8a00\u9700\u8981\u9632\u7684\u662f\u90a3\u79cd\u5751\u7239\u4ee3\u7801\u5728 ioctl \u4e0a\u6253\u5f00\u591a\u6b21\u8fd9\u4e2a\u7ba1\u9053\u6587\u4ef6\uff0c\u7136\u540e\u4e24\u4e2a\u8fdb\u7a0b\u540c\u65f6\u5411\u540c\u4e00\u4e2a\u7ba1\u9053\u53d1\u9001\u6307\u4ee4\u7684\u8bdd\u4f1a\u76f4\u63a5\u51b2\u7a81\u3002\u8fd9\u79cd\u95ee\u9898\u6c9f\u901a\u6210\u672c\u5f88\u9ad8\u7684\uff0c\u800c\u4e14\u4e5f\u5f88\u96be\u8c03\u8bd5\u3002<br \/>\u8fd8\u6709\u5c31\u5982\u540c\u6211\u4e0a\u9762\u8bf4\u7684\uff0c\u8fd9\u4e2a\u4e1c\u897f\u56e0\u4e3a\u8981\u786e\u4fdd\u4ee3\u7801\u884c\u4e3a\u7684\u4e00\u81f4\u6027\uff0c\u4e0d\u80fd\u7ed9\u4e0d\u540c\u7684\u5e73\u53f0\u653e\u4e0d\u540c\u7684\u4ee3\u7801\uff0c\u4e5f\u4e0d\u80fd\u968f\u4fbf\u5f04\u52a0\u5bc6\uff0c\u4e5f\u4e0d\u53ef\u80fd\u8bf4\u6211\u8981\u4e2a\u6743\u9650\u6302\u8f7d\u4e2a ramdisk \u5c31\u80fd\u6302\u8f7d\u3002\u6211\u5df2\u7ecf\u653e\u5f03\u7528 pipe \u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u4e86\uff0cdomain socket \u9999\u591a\u4e86\u2026\u2026                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5263895\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : mingl0280 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @no1xsyzy \u4e0d\u662f\u4ec0\u4e48\u6709\u6ca1\u6709\u7684\u95ee\u9898\uff0c\u662f\u4f60\u4e0d\u80fd\u5047\u8bbe\u5ba2\u6237\u6709\u8fd9\u4e9b\u4e1c\u897f\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5263896\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : no1xsyzy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @mingl0280 \u53d7\u6211\u7ecf\u5386\u6240\u9650\uff0c\u6211\u62cd\u8111\u888b\u8ba4\u4e3a\u662f\u5b8c\u6574\u7684\u89e3\u51b3\u65b9\u6848\u4e86\u2026\u2026                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Linux \u4e0b\u7684\u547d\u540d\u7ba1\u9053\u5982\u4f55\u9650\u5236\u5176&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/340458"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=340458"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/340458\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=340458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=340458"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=340458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}