The hacker post in question offers an in-depth explanation of how task scheduling and threading are implemented in the Linux kernel, focusing on the task_struct data structure and various scheduling policies. It demonstrates a strong technical understanding of Linux internals, including details on the Normal scheduling class (using the Completely Fair Scheduler) and the RealTime class (using Round-Robin or FIFO policies). The post also covers concepts such as priority adjustments through nice values and kernel syscall interactions like setpriority for manipulating task priorities.
The level of detail shows an advanced proficiency in Linux systems, with applications in cyber operations. Insights into task scheduling are used to craft malware that manipulates process priorities to evade detection or enhance persistence. Additionally, understanding task_struct and scheduling algorithms is critical for developing rootkits capable of hiding malicious processes or injecting code. The knowledge optimizes the timing and execution of payloads in exploitation scenarios.
The structured and detailed explanation points to the possibility that the author has received formal training, potentially linked to institutions like Ravin Academy or Eeleyanet Gostar, known for their involvement in Iranian cyber activities. Furthermore, posts like this indicate a broader trend within Iranian hacking communities of sharing advanced technical knowledge to build skills and support cyber operations. The communities, possibly tied to state-sponsored groups like APT33 or APT34, often use such educational material to recruit talent and demonstrate their expertise.
Beyond skill-sharing, they are part of broader influence operations, showcasing technical prowess to intimidate adversaries while attracting new recruits. The combination of technical depth and strategic intent aligns with the emphasis on education and skill development observed in Iranian state-linked cyber initiatives.
Original below
شیوهی زمانبندی اجرای پروسه و نخ در لینوکس
قبل از توضیح این بخش لازمه مجدد اشاره کنم که thread/process در کرنل لینوکس با task_struct پیادهسازی شدهاند و در این پست بجای تکرار «اجرای پروسه و نخ» در لینوکس از عبارت اجرای وظیفه یا task استفاده میکنیم. با این مقدمه برسیم به اصل موضوع این پست:
یکی از وظایفی که سیستمهای عامل بر عهده دارند کنترل اجرای پروسهها/نخها بر روی پردازنده است. اینکار توسط Scheduler سیستمعامل انجام شده و ترتیب و زمان شروع اجرا و مدت زمانی که آنها حق استفاده از پردارنده را دارند مشخص میکند.
لینوکس برای مشخص کردن اولویت اجرای taskها بر روی پردازنده و مدت زمانی که میتوانند از پردازنده استفاده کنند الگوریتمهای مختلفی دارد که به آنها class یا policy زمانبندی میگوید. در هر کلاس نیز به کمک یک عدد، اولویت اجرای taskها را مشخص میکند. به عنوان مثال زمانبند پیشفرض لینوکس که در کلاس Normal قرار دارد با عنوان Completely Fair Scheduler شناخته میشود که در پیادهسازی آن از Red-Black Tree که یک درخت جستجوی دودویی Balance میباشد کمک گرفته شده است.
یک کلاس دیگری که در لینوکس وجود دارد کلاس RealTime میباشد. البته منظور از RealTime در این مورد این است که وظایف تحت یک Time Frame مشخص اجرا میشوند. در این کلاس امکان استفاده از روشهای Round-Robin یا FIFO وجود دارد.
تنظیم کردن اولویت وظایف در کلاس نرمال توسط مقدار nice مشخص میشود که عددی در بازهی منفی ۲۰ تا مثبت ۱۹ میباشد. در کرنل لینوکس مقدار نهایی اولویت برای الگوریتمهای مختلف میتواند عددی بین صفر تا ۱۳۹ باشد و موارد مختلفی مثل Boost کردن اولویت برای پاسخدهی سریعتر برنامههای گرافیکی یا وظایفی که وابستگی خاصی به آنها وجود دارد نیز در اولویت نهایی تاثیر دارند. برای داشتن مقدار تنظیم شده برای اولویت و مقداری که کرنل تصمیم میگیرد اولویت وظیفه در زمان جاری باشد فیلدهای متفاوتی در task_struct وجود دارند.
به عنوان نکتهی پایانی باید اشاره کنم که تنظیم کردن اولویت وظایف به کمک syscall ای به اسم setpriority انجام میشود که دستور renice نیز از آن استفاده میکند. به کمک دستور chrt نیز میتوان تنظیمات مربوط به کلاس RealTime را تغییر داد.
شرح کامل موارد ذکر شده، نمایش دمو از شیوهی استفاده از آنها و نمایش کد کرنل مربوط به setpriotity مواردی هستند که در این ویدئو به آنها میپردازیم. برای مشاهدهی ویدئو از لینکهای زیر استفاده کنید:
لینک ویدئو در یوتیوب:
https://youtu.be/Q6zjeE3Ad_U
لینک ویدئو در آپارات:
https://aparat.com/v/ykmy2r4
پ.ن: اگر شیوهی پیادهسازی پروسه/نخ در لینوکس و کاربرد task_struct برای شما شفاف نیست به پست زیر مراجعه کنید:
