0% found this document useful (0 votes)
7 views

UNIT- 2 OS Security

Uploaded by

shivamvts05
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

UNIT- 2 OS Security

Uploaded by

shivamvts05
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

UNIT -II

Memory Layout of a Process in Operating System

An active program which running now on the Operating System is known as the
process. The Process is the base of all computing things. Although process is
relatively similar to the computer code but, the method is not the same as computer
code. A process is a "active" entity, in contrast to the program, which is sometimes
thought of as some sort of "passive" entity. The properties that the process holds
include the state of the hardware, the RAM, the CPU, and other attributes.

The OS is responsible for managing the start, stop, and scheduling of processes,
which are programs running on the system. The operating system uses a number of
methods to prevent deadlocks, facilitate inter-process communication, and
synchronize processes. Efficient resource allocation, conflict-free process
execution, and optimal system performance are all guaranteed by competent
process management. This essential component of an operating system enables the
execution of numerous applications at once, enhancing system utilization and
responsiveness.
How Does a Process Look Like in Memory?
A process in memory is divided into several distinct sections, each serving a
different purpose. Here’s how a process typically looks in memory:

 Text Section: A Process, sometimes known as the Text Section, also includes
the current activity represented by the value of the Program Counter.
 Stack: The stack contains temporary data, such as function parameters, returns
addresses, and local variables.
 Data Section: Contains the global variable.
 Heap Section: Dynamically memory allocated to process during its run time.

Characteristics of a Process
A process has the following attributes.
 Process Id: A unique identifier assigned by the operating system.
 Process State: Can be ready, running, etc.
 CPU Registers: Like the Program Counter (CPU registers must be saved and
restored when a process is swapped in and out of the CPU)
 Accounts Information: Amount of CPU used for process execution, time
limits, execution ID, etc
 I/O Status Information: For example, devices allocated to the process, open
files, etc
 CPU Scheduling Information: For example, Priority (Different processes
may have different priorities, for example, a shorter process assigned high
priority in the shortest job first scheduling)

States of Process
A process is in one of the following states:
 New: Newly Created Process (or) being-created process.
 Ready: After the creation process moves to the Ready state, i.e. the process is
ready for execution.
 Running: Currently running process in CPU (only one process at a time can
be under execution in a single processor).
 Wait (or Block): When a process requests I/O access.
 Complete (or Terminated): The process completed its execution.
 Suspended Ready: When the ready queue becomes full, some processes are
moved to a suspended ready state
 Suspended Block: When the waiting queue becomes full
Process Operations
Process operations in an operating system refer to the various activities the OS
performs to manage processes. These operations include process creation, process
scheduling, execution and killing the process. Here are the key process operations:

Signal Handling In Linux Through The signal() Function

A signal is a message or notification issued to your program by the operating


system or another application (or one of its threads). Each signal is assigned a
number between 1 and 31. Signals are devoid of argument, and most of the time,
their names are self-explanatory. For instance, signal number 9 or SIGKILL
notifies the program that it is being attempted to be killed.
List of Signals
There is a simple method for compiling a list of all the signals your system
supports. Simply type the kill -l command to see all the allowed signals.
kill -l

Types of Signals
 SIGHUP- This signal indicates that the controlling terminal has been killed.
HUP is an abbreviation meaning “hang up.” Locate the terminal to be
controlled or hang up on the control process’s demise. This signal is obtained
when the process is performed from the terminal and that terminal abruptly
terminates.
 SIGINT- This is the signal generated when a user presses Ctrl + C from the
keyboard.
 SIGQUIT- This is the signal generated when a user presses Ctrl + D from the
keyboard.
 SIGILL- Signal for illegal instruction. This is an exception signal provided by
the operating system to your application when it detects unlawful instruction
within your program. For example, if some code is not understandable by your
machine or if your program’s executable file is corrupted. Another possibility
is that your program loads a corrupted dynamic library.
 SIGABRT- Abort signal indicates that you used the abort() API within your
program. It is used to end a program. abort() generates the SIGABRT signal,
which terminates your program (unless handled by your custom handler).
 SIGFPE- Exception for floating point numbers. Another exception signal is
generated by the operating system when your program causes an exception.
 SIGPIPE- Broken pipe. When there is nothing to read on the other end, write
to the pipe.
 SIGCOUNT – for continue any stop signal
 SIGSTOP – for stop any running signal
 SIGTERM – for permanent terminating signal

Process Schedulers in Operating System


In computing, a process is the instance of a computer program that is being executed


by one or many threads. Scheduling is important in many different computer
environments. One of the most important areas of scheduling is which programs will
work on the CPU. This task is handled by the Operating System (OS) of the
computer and there are many different ways in which we can choose to configure
programs.
Process schedulers are fundamental components of operating systems responsible
for deciding the order in which processes are executed by the CPU. In simpler terms,
they manage how the CPU allocates its time among multiple tasks or processes that
are competing for its attention. In this article, we are going to discuss
What is Process Scheduling?
Process scheduling is the activity of the process manager that handles the removal
of the running process from the CPU and the selection of another process based on
a particular strategy.
Process scheduling is an essential part of a Multiprogramming operating system.
Such operating systems allow more than one process to be loaded into the executable
memory at a time and the loaded process shares the CPU using time multiplexing

Categories of Scheduling
Scheduling falls into one of two categories:
 Non-Preemptive: In this case, a process’s resource cannot be taken before the
process has finished running. When a running process finishes and transitions
to a waiting state, resources are switched.

 Preemptive: In this case, the OS assigns resources to a process for a


predetermined period. The process switches from running state to ready state
or from waiting state to ready state during resource allocation. This switching
happens because the CPU may give other processes priority and substitute the
currently active process for the higher priority process.

Types of Process Schedulers


There are three types of process schedulers:
1. Long Term or Job Scheduler
It brings the new process to the ‘Ready State’. It controls the Degree of Multi-
programming, i.e., the number of processes present in a ready state at any point in
time. It is important that the long-term scheduler make a careful selection of both
I/O and CPU-bound processes. I/O-bound tasks are which use much of their time
in input and output operations while CPU-bound processes are which spend their
time on the CPU. The job scheduler increases efficiency by maintaining a balance
between the two. They operate at a high level and are typically used in batch-
processing systems.

2. Short-Term or CPU Scheduler


It is responsible for selecting one process from the ready state for scheduling it on
the running state. Note: Short-term scheduler only selects the process to schedule
it doesn’t load the process on running. Here is when all the scheduling algorithms
are used. The CPU scheduler is responsible for ensuring no starvation due to high
burst time processes.
3. Medium-Term Scheduler
It is responsible for suspending and resuming the process. It mainly
does swapping (moving processes from main memory to disk and vice versa).
Swapping may be necessary to improve the process mix or because a change in
memory requirements has overcommitted available memory, requiring memory to
be freed up. It is helpful in maintaining a perfect balance between the I/O bound
and the CPU bound. It reduces the degree of multiprogramming.

Privileged and Non-Privileged Instructions in Operating System


In an operating system, instructions executed by the CPU can be classified into


privileged and non-privileged instructions. These classifications help the operating
system ensure security, stability, and efficient resource management. In this article,
we will discuss Privileged and Non-Privileged Instructions in Operating Systems.
What are Privileged Instructions?
Privileged instructions are those that can only be executed by the operating
system kernel or a privileged process, such as a device driver. These instructions
typically perform operations that require direct access to hardware or other
privileged resources, such as setting up memory mappings or accessing I/O devices.
The Instructions that can run only in Kernel Mode are called Privileged Instructions.
Privileged Instructions possess the following characteristics:
 If any attempt is made to execute a Privileged Instruction in User Mode, then it
will not be executed and treated as an illegal instruction. The Hardware traps it
in the Operating System.
 Before transferring the control to any User Program, it is the responsibility of
the Operating System to ensure that the Timer is set to interrupt. Thus, if the
timer interrupts then the Operating System regains control.
 Thus, any instruction which can modify the contents of the Timer is Privileged
Instruction.
 Privileged Instructions are used by the Operating System to achieve correct
operation.
 Various examples of Privileged Instructions include:
o I/O instructions and Halt instructions
o Turn off all Interrupts
o Set the Timer
o Context Switching
o Clear the Memory or Remove a process from the Memory
o Modify entries in the Device-status table
Role of OS in managing Privileged Instructions
 Access control: The operating system employs access control mechanisms to
limit access to privileged instructions. These mechanisms are restricted to
authorized processes or users with elevated privileges. This guarantees that
privileged instructions can only be executed by trusted processes and thwarts
unauthorized access of malicious programs to system resources.
 Memory protection: By deploying memory protection techniques, the
operating system restricts processes from accessing any memory location that
belongs to it or other processes. This aids in preventing tampering with the
operating system or other processes by ensuring that processes cannot do so.
Furthermore, it hinders malevolent programs from resulting in system crashes
or risking the system’s safety.
 Interrupt handling: The execution of privileged instructions like system calls
or exceptions is handled by the operating system through interrupt handling to
ensure safety and accuracy, so when an interrupt occurs during the execution of
a process it’s necessary to save its state before transferring control to a suitable
handler and then restoring it on completion.
 Virtualization: Using virtualization techniques allows the operating system to
create a simulated environment where processes can execute privileged
instructions without having direct access to the underlying hardware thus
creating a more secure and isolated execution environment for privileged
instructions by limiting process access to authorized hardware resources only.
Differences Between Privileged and Non-Privileged Instructions
Non-Privileged
Criteria Privileged Instructions Instructions

Access to Direct access to system Limited access to system


Resources resources resources

Execution
Executed in kernel mode Executed in user mode
Mode

Execution Require special permissions Do not require special


Permissions to execute permissions to execute

Used for performing low- Used for general-purpose


Purpose
level system operations computing
Non-Privileged
Criteria Privileged Instructions Instructions

Higher risk of causing Less risky in terms of


Risks system crashes or security system crashes or security
vulnerabilities vulnerabilities

Threats in OS

The security of a computer system is a crucial task. It is a process of ensuring the


confidentiality and integrity of the OS. Security is one of most important as well
as the major task in order to keep all the threats or other malicious tasks or
attacks or program away from the computer’s software system.
A system is said to be secure if its resources are used and accessed as intended
under all the circumstances, but no system can guarantee absolute security from
several of various malicious threats and unauthorized access.
The security of a system can be threatened via two violations:
 Threat: A program that has the potential to cause serious damage to the
system.
 Attack: An attempt to break security and make unauthorized use of an asset.
Security violations affecting the system can be categorized as malicious and
accidental threats. Malicious threats, as the name suggests are a kind of harmful
computer code or web script designed to create system vulnerabilities leading to
back doors and security breaches. Accidental Threats, on the other hand, are
comparatively easier to be protected against. Example: Denial of Service DDoS
attack.
Security can be compromised via any of the breaches mentioned:
 Breach of confidentiality: This type of violation involves the unauthorized
reading of data.
 Breach of integrity: This violation involves unauthorized modification of
data.
 Breach of availability: It involves unauthorized destruction of data.
 Theft of service: It involves the unauthorized use of resources.
 Denial of service: It involves preventing legitimate use of the system. As
mentioned before, such attacks can be accidental in nature.
Security System Goal:
Henceforth, based on the above breaches, the following security goals are
aimed:
1. Integrity:
The objects in the system mustn’t be accessed by any unauthorized user & any
user not having sufficient rights should not be allowed to modify the important
system files and resources.
2. Secrecy:
The objects of the system must be accessible only to a limited number of
authorized users. Not everyone should be able to view the system files.
3. Availability:
All the resources of the system must be accessible to all the authorized users
i.e. only one user/process should not have the right to hog all the system
resources. If such kind of situation occurs, denial of service could happen. In
this kind of situation, malware might hog the resources for itself & thus
preventing the legitimate processes from accessing the system resources.
Threats can be classified into the following two categories:
1. Program Threats:
A program was written by a cracker to hijack the security or to change the
behavior of a normal process. In other words, if a user program is altered and
further made to perform some malicious unwanted tasks, then it is known as
Program Threats.
2. System Threats:
These threats involve the abuse of system services. They strive to create a
situation in which operating-system resources and user files are misused. They
are also used as a medium to launch program threats.

Types of Program Threats(malicious software)

1. Virus:
An infamous threat, known most widely. It is a self-replicating and malicious
thread that attaches itself to a system file and then rapidly replicates itself,
modifying and destroying essential files leading to a system breakdown.
Further, Types of computer viruses can be described briefly as follows:
– file/parasitic – appends itself to a file
– boot/memory – infects the boot sector
– macro – written in a high-level language like VB and affects MS Office
files
– source code – searches and modifies source codes
– polymorphic – changes in copying each time
– encrypted – encrypted virus + decrypting code
– stealth – avoids detection by modifying parts of the system that can be used
to detect it, like the read system
call
– tunneling – installs itself in the interrupt service routines and device drivers
– multipartite – infects multiple parts of the system

2. Trojan Horse:
A code segment that misuses its environment is called a Trojan Horse. They
seem to be attractive and harmless cover programs but are really harmful
hidden programs that can be used as the virus carrier. In one of the versions of
Trojan, the User is fooled to enter confidential login details on an application.
Those details are stolen by a login emulator and can be further used as a way
of information breaches. One of the major as well as a serious threat or
consequences of the Trojan horse is that it will actually perform proper
damage once installed or run on the computer’s system but at first, a glance
will appear to be useful software and later turns out to be maliciously
unwanted one.
Another variance is Spyware, Spyware accompanies a program that the user
has chosen to install and download ads to display on the user’s system,
thereby creating pop-up browser windows and when certain sites are visited
by the user, it captures essential information and sends it over to the remote
server. Such attacks are also known as Convert Channels.

3. Trap Door:
The designer of a program or system might leave a hole in the software that
only he is capable of using, the Trap Door works on similar principles. Trap
Doors are quite difficult to detect as to analyze them, one needs to go through
the source code of all the components of the system. In other words, if we may
have to define a trap door then it would be like, a trap door is actually a kind
of a secret entry point into a running or static program that actually allows
anyone to gain access to any system without going through the usual security
access procedures.
4. Logic Bomb:
A program that initiates a security attack only under a specific situation. To be
very precise, a logic bomb is actually the most malicious program which is
inserted intentionally into the computer system and that is triggered or
functions when specific conditions have been met for it to work.

5. Worm:
A computer worm is a type of
malware that replicates itself and infects other computers while remaining
active on affected systems. A computer worm replicates itself in order to
infect machines that aren’t already infested. It frequently accomplishes this by
taking advantage of components of an operating system that are automatic and
unnoticed by the user. Worms are frequently overlooked until their
uncontrolled replication depletes system resources, slowing or stopping other
activities.
Types of System Threats –
Aside from the program threats, various system threats are also endangering the
security of our system:
1. Worm:
An infection program that spreads through networks. Unlike a virus, they target
mainly LANs. A computer affected by a worm attacks the target system and
writes a small program “hook” on it. This hook is further used to copy the worm
to the target computer. This process repeats recursively, and soon enough all the
systems of the LAN are affected. It uses the spawn mechanism to duplicate itself.
The worm spawns copies of itself, using up a majority of system resources and
also locking out all other processes.

Concurrency in Operating System


Concurrency in operating systems refers to the capability of an OS to handle more


than one task or process at the same time, thereby enhancing efficiency and
responsiveness. It may be supported by multi-threading or multi-processing whereby
more than one process or threads are executed simultaneously or in an interleaved
fashion.
Thus, more than one program may run simultaneously on shared resources of the
system, such as CPU, memory, and so on. This helps optimize performance and
reduce idle times while improving the responsiveness of applications, generally in
multitasking contexts. Good concurrency handling is crucial for deadlock situations,
race conditions, and usually also for uninterrupted execution of tasks. It helps in
techniques like coordinating the execution of processes, memory allocation, and
execution scheduling for maximizing throughput.
What is Concurrency in OS
Concurrency in an operating system refers to the ability to execute multiple
processes or threads simultaneously, improving resource utilization and system
efficiency. It allows several tasks to be in progress at the same time, either by
running on separate processors or through context switching on a single processor.
Concurrency is essential in modern OS design to handle multitasking, increase
system responsiveness, and optimize performance for users and applications.
There are several motivations for allowing concurrent execution:
 Physical resource Sharing: Multiuser environment since hardware resources
are limited
 Logical resource Sharing: Shared file (same piece of information)
 Computation Speedup: Parallel execution
 Modularity: Divide system functions into separation processes

Inter Process Communication (IPC)


Processes can coordinate and interact with one another using a method called inter-
process communication (IPC) . Through facilitating process collaboration, it
significantly contributes to improving the effectiveness, modularity, and ease of
software systems.
Types of Process
 Independent process
 Co-operating process
An independent process is not affected by the execution of other processes while a
co-operating process can be affected by other executing processes. Though one can
think that those processes, which are running independently, will execute very
efficiently, in reality, there are many situations when cooperative nature can be
utilized for increasing computational speed, convenience, and modularity. Inter-
process communication (IPC) is a mechanism that allows processes to communicate
with each other and synchronize their actions. The communication between these
processes can be seen as a method of cooperation between them. Processes can
communicate with each other through both:
Methods of IPC
 Shared Memory
 Message Passing

An operating system can implement both methods of communication. First, we


will discuss the shared memory methods of communication and then message
passing. Communication between processes using shared memory requires
processes to share some variable, and it completely depends on how the
programmer will implement it. One way of communication using shared memory
can be imagined like this: Suppose process1 and process2 are executing
simultaneously, and they share some resources or use some information from
another process. Process1 generates information about certain computations or
resources being used and keeps it as a record in shared memory. When process2
needs to use the shared information, it will check in the record stored in shared
memory and take note of the information generated by process1 and act
accordingly. Processes can use shared memory for extracting information as a
record from another process as well as for delivering any specific information to
other processes.
Let’s discuss an example of communication between processes using the shared
memory method.
i) Shared Memory Method
Ex: Producer-Consumer problem
There are two processes: Producer and Consumer . The producer produces some
items and the Consumer consumes that item. The two processes share a common
space or memory location known as a buffer where the item produced by the
Producer is stored and from which the Consumer consumes the item if needed.
There are two versions of this problem: the first one is known as the unbounded
buffer problem in which the Producer can keep on producing items and there is no
limit on the size of the buffer, the second one is known as the bounded buffer
problem in which the Producer can produce up to a certain number of items before
it starts waiting for Consumer to consume it. We will discuss the bounded buffer
problem. First, the Producer and the Consumer will share some common memory,
then the producer will start producing items. If the total produced item is equal to
the size of the buffer, the producer will wait to get it consumed by the Consumer.
Similarly, the consumer will first check for the availability of the item. If no item
is available, the Consumer will wait for the Producer to produce it. If there are
items available, Consumer will consume them.

You might also like