{"id":337834,"date":"2022-09-02T15:00:21","date_gmt":"2022-09-02T15:00:21","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=337834"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=337834","title":{"rendered":"<span>\u041f\u043e\u0441\u043e\u0431\u0438\u0435 \u043f\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u044f\u0434\u0440\u0430 Linux. \u0427.4<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/685168\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/-7\/yl\/hp\/-7ylhpzc6raohz-vopxottyejfu.png\" data-src=\"https:\/\/habrastorage.org\/webt\/-7\/yl\/hp\/-7ylhpzc6raohz-vopxottyejfu.png\"\/><\/div>\n<p><\/a><br \/>  \u041f\u0435\u0440\u0435\u0434 \u0432\u0430\u043c\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430 \u043f\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u044f\u0434\u0440\u0430 \u043e\u0442 2 \u0438\u044e\u043b\u044f 2022 \u0433\u043e\u0434\u0430. \u0422\u0435\u043c\u0430 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u2014 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b. \u0412 \u043d\u0435\u0439 \u0432\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0435\u0441\u044c \u0441 \u044d\u0442\u0438\u043c \u043f\u043e\u043d\u044f\u0442\u0438\u0435\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043e\u0431\u043e\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u0443\u044e <code>sys_open<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c, \u0438\u043d\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044f \u043d\u0430\u0441 \u043e\u0431 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0438\u043c \u0444\u0430\u0439\u043b\u0430\u0445. <a name=\"habracut\"><\/a><\/p>\n<p>  \u0421\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0447\u0430\u0441\u0442\u0438 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430:<\/p>\n<ul>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/681880\/\">\u0427\u0430\u0441\u0442\u044c 1<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/683106\/\">\u0427\u0430\u0441\u0442\u044c 2<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/684382\/\">\u0427\u0430\u0441\u0442\u044c 3<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<h2><font color=\"#3AC1EF\">\u258d 10. \u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b<\/font><\/h2>\n<p>  \u0414\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043e\u0442\u043b\u0430\u0436\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u044f\u0434\u0440\u0430 \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 <code>\/proc<\/code> \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432. \u0418 \u044d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u0447\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u043b\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u044f\u0434\u0440\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430. \u041d\u043e \u043a\u0430\u043a \u0431\u044b\u0442\u044c, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u043e\u0435, \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b? \u0417\u0434\u0435\u0441\u044c \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. <\/p>\n<p>  \u0418 \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u0439\u0434\u0435\u0442\u0435 \u0440\u0438\u0441\u043a\u043e\u0432\u044b\u043c \u043f\u0443\u0442\u0435\u043c, \u043d\u0435 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0432 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u0443, \u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u044f\u0434\u0440\u0430 \u0443\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u0432\u0435\u0441\u044c\u043c\u0430 \u043e\u043f\u0430\u0441\u043d\u044b\u043c \u0437\u0430\u043d\u044f\u0442\u0438\u0435\u043c. \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043d\u0438\u0436\u0435, \u044f \u0443\u0431\u0438\u043b \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <code>open()<\/code> \u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043d\u0435 \u0441\u043c\u043e\u0433 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u0444\u0430\u0439\u043b\u044b, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438 \u0434\u0430\u0436\u0435 \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443. \u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u0443. \u041d\u0438\u043a\u0430\u043a\u0438\u0435 \u0432\u0430\u0436\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u043d\u0435 \u043f\u043e\u0441\u0442\u0440\u0430\u0434\u0430\u043b\u0438, \u043d\u043e \u0435\u0441\u043b\u0438 \u0431\u044b \u044f \u0434\u0435\u043b\u0430\u043b \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0430\u0436\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0438\u0441\u0445\u043e\u0434 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0431\u044b \u0432\u043f\u043e\u043b\u043d\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u0435\u043d. \u0427\u0442\u043e\u0431\u044b \u043e\u0433\u0440\u0430\u0434\u0438\u0442\u044c \u0441\u0435\u0431\u044f \u043e\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0439 \u043f\u043e\u0442\u0435\u0440\u0438 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0444\u0430\u0439\u043b\u043e\u0432, \u0434\u0430\u0436\u0435 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0441\u0440\u0435\u0434\u044b, \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0434\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f <code>insmod<\/code> \u0438 <code>rmmod<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c <code>sync<\/code>.<\/p>\n<p>  \u0417\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043e \u0444\u0430\u0439\u043b\u0430\u0445 <code>\/proc<\/code>, \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043e \u0444\u0430\u0439\u043b\u0430\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u2013 \u044d\u0442\u043e \u043b\u0438\u0448\u044c \u043c\u0435\u043b\u043a\u0438\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u0432 \u043d\u0435\u043e\u0431\u044a\u044f\u0442\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0432\u0441\u0435\u043b\u0435\u043d\u043d\u043e\u0439. \u0420\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u043c \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u044f\u0434\u0440\u043e\u043c, \u0442\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0432\u0441\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b. \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0443 \u044f\u0434\u0440\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0444\u0430\u0439\u043b\u0430, \u0440\u0430\u0437\u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u043b\u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438), \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c. \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u044f\u0434\u0440\u0430, \u0442\u043e \u0432\u043c\u0435\u0448\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u0430\u043a \u0440\u0430\u0437 \u0432 \u043d\u0435\u0433\u043e. \u041a\u0441\u0442\u0430\u0442\u0438, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a: <\/p>\n<pre><code class=\"bash\">strace &lt;arguments><\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u044f\u0434\u0440\u0443, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u043d \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0435\u0433\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u042d\u0442\u043e \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d\u043e \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u043e\u0439 \u0426\u041f\u0423 (\u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u00ab\u0437\u0430\u0449\u0438\u0449\u0435\u043d\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c\u00bb \u0438\u043b\u0438 \u00ab\u0437\u0430\u0449\u0438\u0442\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u00bb).<\/p>\n<p>  \u0418 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u043e\u0431\u0449\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c. \u0422\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438 \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0442\u0430\u043a \u2013 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0441\u043e\u0431\u0443\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0440\u0430\u043d\u0435\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u044f\u0434\u0440\u0430 (\u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u044d\u0442\u0430 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f, \u043d\u043e \u043d\u0435 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438). \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432 Intel \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f <code>0\u044580<\/code>. \u0410\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u0432 \u044d\u0442\u0443 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u044b \u0432\u044b\u0445\u043e\u0434\u0438\u0442\u0435 \u0438\u0437 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u0432 \u044e\u0440\u0438\u0441\u0434\u0438\u043a\u0446\u0438\u0438 \u044f\u0434\u0440\u0430, \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0447\u0435\u043c \u0434\u043b\u044f \u0432\u0430\u0441 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0434\u0432\u0435\u0440\u0438. <\/p>\n<p>  \u041e\u0431\u043b\u0430\u0441\u0442\u044c \u044f\u0434\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u043a\u043e\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>system_call<\/code>. \u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0432 \u044d\u0442\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043d\u043e\u043c\u0435\u0440 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430, \u0441\u043e\u043e\u0431\u0449\u0430\u044f \u044f\u0434\u0440\u0443 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u043b. \u0417\u0430\u0442\u0435\u043c \u043e\u043d\u0430 \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 (<code>sys_call_table<\/code>) \u0432 \u043f\u043e\u0438\u0441\u043a\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 \u043d\u0443\u0436\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u044f\u0434\u0440\u0430. \u0414\u0430\u043b\u0435\u0435 \u043e\u043d\u0430 \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442, \u0438 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0442\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0440\u044f\u0434 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 (\u0438\u043b\u0438 \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443, \u0435\u0441\u043b\u0438 \u0432\u0440\u0435\u043c\u044f \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0441\u0442\u0435\u043a\u043b\u043e). \u041f\u0440\u043e\u043f\u0438\u0441\u0430\u043d \u0432\u0435\u0441\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432 \u0444\u0430\u0439\u043b\u0435 <code>arch\/$(architecture)\/kernel\/entry.S<\/code> \u043f\u043e\u0441\u043b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 <code>ENTRY(system_call)<\/code>.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430, \u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 (\u043e\u0431\u044b\u0447\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f), \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0432 <code>sys_call_table<\/code> \u043d\u0430 \u043d\u0430\u0448\u0443 \u043d\u043e\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u043e\u0437\u0434\u043d\u0435\u0435 \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u0434\u0430\u043b\u0435\u043d\u0430, \u0432\u0430\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b <code>cleanup_module<\/code> \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u043b\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. <\/p>\n<p>  \u0414\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e <code>sys_call_table<\/code> \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u0437\u044f\u0442\u044c \u0432\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u0438\u043b\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0433\u043e \u043e\u0431\u0449\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c. \u0412 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 x86 \u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 <code>cr0<\/code> \u0435\u0441\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0444\u043b\u0430\u0433\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u0421\u0440\u0435\u0434\u0438 \u043d\u0438\u0445 \u0435\u0441\u0442\u044c \u0444\u043b\u0430\u0433 <code>WP<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0437\u0430\u0449\u0438\u0442\u0443 \u043e\u0442 \u0437\u0430\u043f\u0438\u0441\u0438. \u0415\u0441\u043b\u0438 \u043e\u043d \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d, \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c <code>sys_call_table<\/code>, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u044d\u0442\u043e\u0442 \u0444\u043b\u0430\u0433 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c. <\/p>\n<p>  \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Linux v5.3, \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>write_cr0<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0437-\u0437\u0430 \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0431\u0438\u0442 <code>cr0<\/code>, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0445 \u0443\u0433\u0440\u043e\u0437\u0443 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u0421 \u0438\u0445 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u0442\u0430\u043a\u0443\u044e\u0449\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u044f \u0437\u0430\u0449\u0438\u0442\u044b \u0426\u041f\u0423, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u0449\u0438\u0442\u0443 \u043e\u0442 \u0437\u0430\u043f\u0438\u0441\u0438. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0434\u043b\u044f \u043e\u0431\u0445\u043e\u0434\u0430 \u044d\u0442\u043e\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430.<\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0438\u043c\u0432\u043e\u043b <code>sys_call_table<\/code> \u0441 \u0446\u0435\u043b\u044c\u044e \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0442\u0440\u044e\u043a\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u043c. \u041d\u043e \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435 \u0436\u0435 \u0435\u0441\u0442\u044c \u043f\u0430\u0440\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0434\u043b\u044f \u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0440\u0443\u0447\u043d\u043e\u0439 \u043f\u043e\u0438\u0441\u043a \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0438 <code>kallsyms_lookup_name<\/code>. \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u043e\u0438\u0445, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 \u044f\u0434\u0440\u0430.<\/p>\n<p>  \u0412 \u044f\u0434\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c Control-Flow Integrity (CFI), \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0430\u0442\u0430\u043a\u0443\u044e\u0449\u0438\u043c. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043a \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u043c \u0430\u0434\u0440\u0435\u0441\u0430\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0430\u0434\u0440\u0435\u0441\u043e\u0432. \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Linux v5.7, \u0432 \u044f\u0434\u0440\u0435 \u043f\u0440\u043e\u043f\u0430\u0442\u0447\u0438\u043b\u0438 \u0440\u044f\u0434 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 Control-Flow Enforcement (CET) \u0434\u043b\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b x86, \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 GCC, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 GCC 9 \u0438 10 \u0432\u0435\u0440\u0441\u0438\u0438, \u0431\u0443\u0434\u0443\u0442 \u0438\u0434\u0442\u0438 \u0441 CET (\u043e\u043f\u0446\u0438\u044f <code>-fcf-protection<\/code>) \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e GCC \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u044f\u0434\u0440\u0430 \u043f\u0440\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u043c Retpoline \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0438 \u0432 \u044f\u0434\u0440\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 CET. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u043b\u0438 \u043e\u043f\u0446\u0438\u044f <code>-fcf-protection<\/code>, \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"bash\">$ gcc -v -Q -O2 --help=target | grep protection Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=\/usr\/lib\/gcc\/x86_64-linux-gnu\/9\/lto-wrapper ... gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) COLLECT_GCC_OPTIONS='-v' '-Q' '-O2' '--help=target' '-mtune=generic' '-march=x86-64'  \/usr\/lib\/gcc\/x86_64-linux-gnu\/9\/cc1 -v ... -fcf-protection ...  GNU C17 (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu) ...<\/code><\/pre>\n<p>  \u041d\u043e CET \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u0432 \u044f\u0434\u0440\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0440\u0443\u0448\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 Kprobes \u0438 bpf. \u041f\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 v5.11, \u0434\u0430\u043d\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0431\u044b\u043b \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0447\u0442\u043e\u0431\u044b \u0443 \u043d\u0430\u0441 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0440\u0443\u0447\u043d\u043e\u0439 \u043f\u043e\u0438\u0441\u043a \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432\u0435\u0440\u0441\u0438\u0438 \u044f\u0434\u0440\u0430 \u0434\u043e v5.4. <\/p>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Linux v5.7, <code>kallsyms_lookup_name<\/code> \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0430\u0434\u0440\u0435\u0441 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043b\u0438\u0448\u044c \u043e\u0431\u0445\u043e\u0434\u043d\u044b\u043c \u043f\u0443\u0442\u0435\u043c. \u0415\u0441\u043b\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u043e\u043f\u0446\u0438\u044f <code>CONFIG_KPROBES<\/code>, \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u044d\u0442\u043e\u0442 \u0430\u0434\u0440\u0435\u0441, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Kprobes \u0434\u043b\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u044f\u0434\u0440\u0430. Kprobe \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u043e\u0447\u043a\u0443 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0430 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0437\u0430\u043c\u0435\u043d\u044f\u044f \u043f\u0435\u0440\u0432\u044b\u0435 \u0431\u0430\u0439\u0442\u044b \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438. \u041a\u043e\u0433\u0434\u0430 \u0426\u041f\u0423 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442 \u044d\u0442\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0430, \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f, \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 Kprobes. \u041e\u043d \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0430\u0434\u0440\u0435\u0441\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b Kprobe \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043d\u0430\u043c\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0435\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442. Kprobes \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0438\u043b\u0438 \u0430\u0434\u0440\u0435\u0441\u0443. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u043c\u0435\u043d\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0430\u0434\u0440\u0435\u0441 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u044f\u0434\u0440\u043e\u043c.<\/p>\n<p>  \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0430\u0434\u0440\u0435\u0441 <code>sys_call_table<\/code> \u0438\u0437 <code>\/proc\/kallsyms<\/code> \u0438 <code>\/boot\/System.map<\/code> \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 <code>sym<\/code>. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <code>\/proc\/kallsyms<\/code>:<\/p>\n<pre><code class=\"bash\">$ sudo grep sys_call_table \/proc\/kallsyms ffffffff82000280 R x32_sys_call_table ffffffff820013a0 R sys_call_table ffffffff820023e0 R ia32_sys_call_table $ sudo insmod syscall.ko sym=0xffffffff820013a0<\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0430\u0434\u0440\u0435\u0441\u0430 \u0438\u0437 <code>\/boot\/System.map<\/code> \u0431\u0443\u0434\u044c\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b \u043a <code>KASLR<\/code> (\u0440\u0430\u043d\u0434\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u044f\u0434\u0440\u0430). \u042d\u0442\u043e\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u043d\u0434\u043e\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0434\u0440\u0435\u0441\u0430 \u043a\u043e\u0434\u0430 \u044f\u0434\u0440\u0430 \u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u0434\u0440\u0435\u0441, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0432 <code>\/boot\/System.map<\/code>, \u0441\u0434\u0432\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. <\/p>\n<p>  \u0417\u0430\u0434\u0430\u0447\u0430 <code>KASLR<\/code> \u2013 \u0437\u0430\u0449\u0438\u0449\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u044f\u0434\u0440\u0430 \u043e\u0442 \u0430\u0442\u0430\u043a. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u0430\u0442\u0430\u043a\u0443\u044e\u0449\u0435\u043c\u0443 \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0440\u043e\u0449\u0435 \u043e\u0442\u044b\u0441\u043a\u0430\u0442\u044c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0430\u0434\u0440\u0435\u0441, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e. <code>KASLR<\/code> \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c \u0430\u0442\u0430\u043a\u0430\u043c, \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0430\u0442\u0430\u043a\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0440\u044f\u043c\u0438\u043a\u043e\u043c \u0443\u0437\u043d\u0430\u0442\u044c \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0430\u0434\u0440\u0435\u0441. \u0425\u043e\u0442\u044f \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0434\u0431\u043e\u0440\u0430 \u0437\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u0435\u0449\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u0415\u0441\u043b\u0438 \u0430\u0434\u0440\u0435\u0441 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0432 <code>\/proc\/kallsyms<\/code> \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0430\u0434\u0440\u0435\u0441\u0430 \u0432 <code>\/boot\/System.map<\/code>, \u044f\u0434\u0440\u043e \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u0442 <code>KASLR<\/code>.<\/p>\n<pre><code class=\"bash\">$ grep GRUB_CMDLINE_LINUX_DEFAULT \/etc\/default\/grub GRUB_CMDLINE_LINUX_DEFAULT=\"quiet splash\" $ sudo grep sys_call_table \/boot\/System.map-$(uname -r) ffffffff82000300 R sys_call_table $ sudo grep sys_call_table \/proc\/kallsyms ffffffff820013a0 R sys_call_table # \u041f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 $ sudo grep sys_call_table \/boot\/System.map-$(uname -r) ffffffff82000300 R sys_call_table $ sudo grep sys_call_table \/proc\/kallsyms ffffffff86400300 R sys_call_table<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 <code>KASLR<\/code> \u0430\u043a\u0442\u0438\u0432\u043d\u0430, \u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0434\u0435\u043b\u044f\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0430\u0434\u0440\u0435\u0441\u0443 \u0438\u0437 <code>\/proc\/kallsyms<\/code>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u0434\u0440\u0435\u0441\u0430 \u0438\u0437 <code>\/boot\/System.map<\/code> \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e <code>KASLR<\/code> \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0430. \u041e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043f\u0440\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>nokaslr<\/code>: <\/p>\n<pre><code class=\"bash\">$ grep GRUB_CMDLINE_LINUX_DEFAULT \/etc\/default\/grub GRUB_CMDLINE_LINUX_DEFAULT=\"quiet splash\" $ sudo perl -i -pe 'm\/quiet\/ and s\/\/quiet nokaslr\/' \/etc\/default\/grub $ grep quiet \/etc\/default\/grub GRUB_CMDLINE_LINUX_DEFAULT=\"quiet nokaslr splash\" $ sudo update-grub<\/code><\/pre>\n<p>  \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e \u044d\u0442\u043e\u0439 \u0442\u0435\u043c\u0435 \u0447\u0438\u0442\u0430\u0439\u0442\u0435:<\/p>\n<ul>\n<li><a href=\"https:\/\/lwn.net\/Articles\/804849\/\">Cook: Security things in Linux v5.3<\/a><\/li>\n<li><a href=\"https:\/\/lwn.net\/Articles\/12211\/\">Unexporting the system call table<\/a><\/li>\n<li><a href=\"https:\/\/lwn.net\/Articles\/810077\/\">Control-flow integrity for the kernel<\/a><\/li>\n<li><a href=\"https:\/\/lwn.net\/Articles\/813350\/\">Unexporting kallsyms_lookup_name()<\/a><\/li>\n<li><a href=\"https:\/\/www.kernel.org\/doc\/Documentation\/kprobes.txt\">Kernel Probes (Kprobes)<\/a><\/li>\n<li><a href=\"https:\/\/lwn.net\/Articles\/569635\/\">Kernel address space layout randomization<\/a><\/li>\n<\/ul>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0437\u0434\u0435\u0441\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u044f\u0434\u0440\u0430. \u041c\u044b \u0445\u043e\u0442\u0438\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u00ab\u0441\u043b\u0435\u0436\u043a\u0443\u00bb \u0437\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c (<code>pr_info()<\/code>) \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 \u0438\u043c \u0444\u0430\u0439\u043b\u0430. \u0421 \u044d\u0442\u043e\u0439 \u0446\u0435\u043b\u044c\u044e \u043c\u044b \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <code>sys_open<\/code> \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>our_sys_open<\/code>. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 uid \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u0438 \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 uid, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0441\u043b\u0435\u0434\u0438\u043c, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>pr_info()<\/code> \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u0438 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430. \u0417\u0430\u0442\u0435\u043c \u043e\u043d\u0430 \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>sys_open<\/code> \u0441 \u0442\u0435\u043c\u0438 \u0436\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0444\u0430\u0439\u043b.<\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>init_module<\/code> \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u043d\u0443\u0436\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0432 <code>sys_call_table<\/code> \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>cleanup_module<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044d\u0442\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0434\u043b\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u042d\u0442\u043e \u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0435\u0441\u0442\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c, \u0447\u0442\u043e \u0434\u0432\u0430 \u043c\u043e\u0434\u0443\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u044f\u0442 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043c\u043e\u0434\u0443\u043b\u044f, <i>A<\/i> \u0438 <i>B<\/i>. \u0423 <i>\u0410<\/i> \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0434\u043b\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 <code>A_open<\/code>, \u0430 \u0443 <i>\u0412<\/i> \u0438\u043c \u0431\u0443\u0434\u0435\u0442 <code>B_open<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c, \u043f\u0440\u0438 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0438 <i>\u0410<\/i> \u0432 \u044f\u0434\u0440\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043c\u0435\u043d\u0435\u043d \u043d\u0430 <code>A_open<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u0432\u044b\u0437\u043e\u0432\u0435\u0442 <code>sys_open<\/code>. \u0414\u0430\u043b\u0435\u0435 \u0432 \u044f\u0434\u0440\u043e \u0432\u043d\u0435\u0434\u0440\u044f\u0435\u0442\u0441\u044f <i>\u0412<\/i>, \u0437\u0430\u043c\u0435\u043d\u044f\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <i>\u0410<\/i> \u043d\u0430 <code>B_open<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 <code>A_open<\/code>, \u044f\u0432\u043b\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u043c. <\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0435\u043d <i>\u0412<\/i>, \u0442\u043e \u0432\u0441\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u2013 \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u043d\u0430 <code>A_open<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b. \u041d\u043e \u0432\u043e\u0442 \u0435\u0441\u043b\u0438 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0434\u0430\u043b\u0438\u0442\u044c <i>\u0410<\/i>, \u0430 \u0437\u0430\u0442\u0435\u043c <i>\u0412<\/i>, \u0442\u043e \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u0441\u0431\u043e\u0439. \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 <i>\u0410<\/i> \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430, <code>sys_open<\/code>, \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0432 \u0438\u0437 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 <i>B<\/i>. \u0417\u0430\u0442\u0435\u043c, \u043a\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u044f\u0442\u044c\u0441\u044f <i>\u0412<\/i>, \u043e\u043d \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0435\u0442\u0441\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u043d\u0430 \u0442\u043e\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c, \u0442\u043e \u0435\u0441\u0442\u044c <code>A_open<\/code>, \u043d\u043e \u0435\u0433\u043e \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0443\u0436\u0435 \u043d\u0435 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f. <\/p>\n<p>  \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0432, \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u043b\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0441 \u043d\u0430\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u2013 \u0435\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0435\u0433\u043e \u043d\u0435 \u043c\u0435\u043d\u044f\u0442\u044c (\u0447\u0442\u043e\u0431\u044b <i>\u0412<\/i> \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u043b \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438). \u041d\u043e \u044d\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0435\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443. \u041f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 <i>\u0410<\/i> \u0443\u0432\u0438\u0434\u0438\u0442, \u0447\u0442\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0431\u044b\u043b \u0437\u0430\u043c\u0435\u043d\u0435\u043d \u043d\u0430 <code>B_open<\/code> \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 <code>A_open<\/code>, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430 <code>sys_open<\/code>, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0435\u043d \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0432 \u0438\u0442\u043e\u0433\u0435 <i>\u0412<\/i> \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0432\u044b\u0437\u0432\u0430\u0442\u044c <code>A_Open<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0442, \u0442\u0430\u043a \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0431\u0435\u0437 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f <i>\u0412<\/i> \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0434\u0430\u0441\u0442 \u0441\u0431\u043e\u0439.<\/p>\n<p>  \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u0432\u0441\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0434\u0435\u043b\u0430\u044e\u0442 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043d\u0435\u0446\u0435\u043b\u0435\u0441\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u043c \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d-\u0441\u0440\u0435\u0434\u0435. \u0418 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0433\u0440\u0430\u0434\u0438\u0442\u044c \u043b\u044e\u0434\u0435\u0439 \u043e\u0442 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0432\u0440\u0435\u0434\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, <code>sys_call_table<\/code> \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f. \u0422\u043e \u0435\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0435, \u043d\u0435\u0436\u0435\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u043e \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u043f\u0430\u0442\u0447\u0438\u0442\u044c \u044f\u0434\u0440\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0430 <code>sys_call_table<\/code>.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">syscall.c<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">\/*   * syscall.c   *   * \u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430.   *   * \u041e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0437\u0430\u0449\u0438\u0442\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u043f\u0443\u0442\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f   * 16 \u0431\u0438\u0442\u0430 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 cr0 (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043a Intel).   *   * \u041e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u041f\u0438\u0442\u0435\u0440\u0430 \u0414\u0436\u0435\u044f \u0417\u0430\u043b\u044c\u0446\u043c\u0430\u043d\u0430 \u0438  * https:\/\/bbs.archlinux.org\/viewtopic.php?id=139406   *\/    #include &lt;linux\/delay.h>  #include &lt;linux\/kernel.h>  #include &lt;linux\/module.h>  #include &lt;linux\/moduleparam.h> \/* \u0411\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. *\/  #include &lt;linux\/unistd.h> \/* \u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432. *\/  #include &lt;linux\/version.h>    \/* \u0414\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b (\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430). \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u043a\u0442\u043e   * \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c.   *\/  #include &lt;linux\/sched.h>  #include &lt;linux\/uaccess.h>    \/* \u041f\u043e \u0445\u043e\u0434\u0443 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u044f\u0434\u0440\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0438 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \"sys_call_table\"   * - \u0434\u043e v5.4       : \u0440\u0443\u0447\u043d\u043e\u0439 \u043f\u043e\u0438\u0441\u043a \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432   * - \u0441 v5.5 \u043f\u043e v5.6: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 kallsyms_lookup_name()   * - v5.7+         : Kprobes \u043b\u0438\u0431\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043c\u043e\u0434\u0443\u043b\u044f \u044f\u0434\u0440\u0430   *\/    \/* \u0412 Linux v5.11+ \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u044f\u0434\u0440\u0430 \u043a ksys_close() \u0431\u044b\u043b\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u044b.   *\/  #if (LINUX_VERSION_CODE &lt; KERNEL_VERSION(5, 7, 0))    #if LINUX_VERSION_CODE &lt;= KERNEL_VERSION(5, 4, 0)  #define HAVE_KSYS_CLOSE 1  #include &lt;linux\/syscalls.h> \/* \u0414\u043b\u044f ksys_close() *\/  #else  #include &lt;linux\/kallsyms.h> \/* \u0414\u043b\u044f kallsyms_lookup_name *\/  #endif    #else    #if defined(CONFIG_KPROBES)  #define HAVE_KPROBES 1  #include &lt;linux\/kprobes.h>  #else  #define HAVE_PARAM 1  #include &lt;linux\/kallsyms.h> \/* \u0414\u043b\u044f sprint_symbol *\/  \/* \u0410\u0434\u0440\u0435\u0441 sys_call_table, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u043f\u043e   * \"\/boot\/System.map\" \u0438\u043b\u0438 \"\/proc\/kallsyms\". \u0412 \u044f\u0434\u0440\u0435 v5.7+, \u043a\u043e\u0433\u0434\u0430   * CONFIG_KPROBES \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442, \u043c\u043e\u0436\u043d\u043e \u0432\u0432\u043e\u0434\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u0438\u043d\u0430\u0447\u0435 \u043c\u043e\u0434\u0443\u043b\u044c   * \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u043f\u043e \u0432\u0441\u0435\u0439 \u043f\u0430\u043c\u044f\u0442\u0438.   *\/  static unsigned long sym = 0;  module_param(sym, ulong, 0644);  #endif \/* CONFIG_KPROBES *\/    #endif \/* Version &lt; v5.7 *\/    static unsigned long **sys_call_table;    \/* UID, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u2013 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0438\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. *\/  static int uid;  module_param(uid, int, 0644);    \/* \u0423\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432. \u041c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0435\u0433\u043e, \u0430 \u043d\u0435  * \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e (sys_open), \u0442\u0430\u043a \u043a\u0430\u043a \u043a\u0442\u043e-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u043c\u043e\u0433   * \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0434\u043e \u043d\u0430\u0441. \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442   * 100% \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443, \u0435\u0441\u043b\u0438 \u0434\u043e \u044d\u0442\u043e\u0433\u043e sys_open \u0443\u0436\u0435 \u0431\u044b\u043b   * \u0437\u0430\u043c\u0435\u043d\u0435\u043d \u0434\u0440\u0443\u0433\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u0435\u043c, \u0442\u043e \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442   * \u043a \u0432\u044b\u0437\u043e\u0432\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0442\u043e\u043c \u043c\u043e\u0434\u0443\u043b\u0435 - \u0430 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u0436\u0435 \u0443\u0434\u0430\u043b\u0435\u043d.   *   * \u0415\u0449\u0435 \u043e\u0434\u043d\u0430 \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c sys_open, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443   * \u044d\u0442\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u0438 \u043e\u043d\u0430 \u043d\u0435 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f.   *\/  static asmlinkage int (*original_call)(const char *, int, int);    \/* \u0424\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c sys_open. \u0414\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0442\u043e\u0447\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430  * \u0441 \u0447\u0438\u0441\u043b\u043e\u043c \u0438 \u0442\u0438\u043f\u043e\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e  * (\u0432 fs\/open.c).   *   * \u0412 \u0442\u0435\u043e\u0440\u0438\u0438 \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u044b \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u044b \u043a \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u044f\u0434\u0440\u0430. \u041d\u0430    * \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0436\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u043f\u043e\u0447\u0442\u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f (\u044d\u0442\u043e \u0431\u044b \u0432\u043d\u0435\u0441\u043b\u043e   * \u0431\u0435\u0441\u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e \u043f\u0435\u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b   * \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c \u043c\u0435\u0436\u0434\u0443 \u044f\u0434\u0440\u043e\u043c \u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438).   *\/  static asmlinkage int our_sys_open(const char *filename, int flags, int mode)  {      int i = 0;      char ch;        \/* \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u043e\u0431 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435. *\/      pr_info(\"Opened file by %d: \", uid);      do {          get_user(ch, (char __user *)filename + i);          i++;          pr_info(\"%c\", ch);      } while (ch != 0);      pr_info(\"\\n\");        \/* \u0412\u044b\u0437\u043e\u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 sys_open \u2013 \u0438\u043d\u0430\u0447\u0435 \u043c\u044b \u043f\u043e\u0442\u0435\u0440\u044f\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c       * \u0444\u0430\u0439\u043b\u044b.       *\/      return original_call(filename, flags, mode);  }    static unsigned long **aquire_sys_call_table(void)  {  #ifdef HAVE_KSYS_CLOSE      unsigned long int offset = PAGE_OFFSET;      unsigned long **sct;        while (offset &lt; ULLONG_MAX) {          sct = (unsigned long **)offset;            if (sct[__NR_close] == (unsigned long *)ksys_close)              return sct;            offset += sizeof(void *);      }        return NULL;  #endif    #ifdef HAVE_PARAM      const char sct_name[15] = \"sys_call_table\";      char symbol[40] = { 0 };        if (sym == 0) {          pr_alert(\"For Linux v5.7+, Kprobes is the preferable way to get \"                   \"symbol.\\n\");          pr_info(\"If Kprobes is absent, you have to specify the address of \"                  \"sys_call_table symbol\\n\");          pr_info(\"by \/boot\/System.map or \/proc\/kallsyms, which contains all the \"                  \"symbol addresses, into sym parameter.\\n\");          return NULL;      }      sprint_symbol(symbol, sym);      if (!strncmp(sct_name, symbol, sizeof(sct_name) - 1))          return (unsigned long **)sym;        return NULL;  #endif    #ifdef HAVE_KPROBES      unsigned long (*kallsyms_lookup_name)(const char *name);      struct kprobe kp = {          .symbol_name = \"kallsyms_lookup_name\",      };        if (register_kprobe(&amp;kp) &lt; 0)          return NULL;      kallsyms_lookup_name = (unsigned long (*)(const char *name))kp.addr;      unregister_kprobe(&amp;kp);  #endif        return (unsigned long **)kallsyms_lookup_name(\"sys_call_table\");  }    #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)  static inline void __write_cr0(unsigned long cr0)  {      asm volatile(\"mov %0,%%cr0\" : \"+r\"(cr0) : : \"memory\");  }  #else  #define __write_cr0 write_cr0  #endif    static void enable_write_protection(void)  {      unsigned long cr0 = read_cr0();      set_bit(16, &amp;cr0);      __write_cr0(cr0);  }    static void disable_write_protection(void)  {      unsigned long cr0 = read_cr0();      clear_bit(16, &amp;cr0);      __write_cr0(cr0);  }    static int __init syscall_start(void)  {      if (!(sys_call_table = aquire_sys_call_table()))          return -1;        disable_write_protection();        \/* \u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f. *\/      original_call = (void *)sys_call_table[__NR_open];        \/* \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. *\/      sys_call_table[__NR_open] = (unsigned long *)our_sys_open;        enable_write_protection();        pr_info(\"Spying on UID:%d\\n\", uid);        return 0;  }    static void __exit syscall_end(void)  {      if (!sys_call_table)          return;        \/* \u0412\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430. *\/      if (sys_call_table[__NR_open] != (unsigned long *)our_sys_open) {          pr_alert(\"Somebody else also played with the \");          pr_alert(\"open system call\\n\");          pr_alert(\"The system may be left in \");          pr_alert(\"an unstable state.\\n\");      }        disable_write_protection();      sys_call_table[__NR_open] = (unsigned long *)original_call;      enable_write_protection();        msleep(2000);  }    module_init(syscall_start);  module_exit(syscall_end);    MODULE_LICENSE(\"GPL\");<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435<\/font><\/h2>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u0430 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0432\u0438\u0434\u0430\u043c\u0438 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u0438 \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438.<\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0447\u0430\u0441\u0442\u0438<\/font><\/h2>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/681880\/\">\u0427\u0430\u0441\u0442\u044c 1<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/683106\/\">\u0427\u0430\u0441\u0442\u044c 2<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/684382\/\">\u0427\u0430\u0441\u0442\u044c 3<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<blockquote><p><b><font color=\"#3AC1EF\"><a href=\"https:\/\/bit.ly\/3bDQroY\">\u041a\u043e\u043d\u043a\u0443\u0440\u0441 \u0441\u0442\u0430\u0442\u0435\u0439 \u043e\u0442 RUVDS.COM<\/a>. \u0422\u0440\u0438 \u0434\u0435\u043d\u0435\u0436\u043d\u044b\u0435 \u043d\u043e\u043c\u0438\u043d\u0430\u0446\u0438\u0438. \u0413\u043b\u0430\u0432\u043d\u044b\u0439 \u043f\u0440\u0438\u0437 \u2014 100 000 \u0440\u0443\u0431\u043b\u0435\u0439. <\/font><\/b><\/p><\/blockquote>\n<p><a href=\"http:\/\/ruvds.com\/ru-rub?utm_source=habr&amp;utm_medium=article&amp;utm_campaign=Bright_Translate&amp;utm_content=posobie_po_programmirovaniyu_modulej_yadra_linux._ch.4\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/sz\/7j\/pf\/sz7jpfj8i1pa6ocj-eia09dev4q.png\" data-src=\"https:\/\/habrastorage.org\/webt\/sz\/7j\/pf\/sz7jpfj8i1pa6ocj-eia09dev4q.png\"\/><\/a><\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/685168\/\"> https:\/\/habr.com\/ru\/company\/ruvds\/blog\/685168\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/685168\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/-7\/yl\/hp\/-7ylhpzc6raohz-vopxottyejfu.png\" data-src=\"https:\/\/habrastorage.org\/webt\/-7\/yl\/hp\/-7ylhpzc6raohz-vopxottyejfu.png\"\/><\/div>\n<p><\/a><br \/>  \u041f\u0435\u0440\u0435\u0434 \u0432\u0430\u043c\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430 \u043f\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u044f\u0434\u0440\u0430 \u043e\u0442 2 \u0438\u044e\u043b\u044f 2022 \u0433\u043e\u0434\u0430. \u0422\u0435\u043c\u0430 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u2014 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b. \u0412 \u043d\u0435\u0439 \u0432\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0435\u0441\u044c \u0441 \u044d\u0442\u0438\u043c \u043f\u043e\u043d\u044f\u0442\u0438\u0435\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043e\u0431\u043e\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u0443\u044e <code>sys_open<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c, \u0438\u043d\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044f \u043d\u0430\u0441 \u043e\u0431 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0438\u043c \u0444\u0430\u0439\u043b\u0430\u0445. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-337834","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/337834","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=337834"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/337834\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=337834"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=337834"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=337834"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}