Tag: Linux

Yocto Training: Essential Build Packages

build-essential is a metapackage on Debian and Ubuntu that installs the basic tools for compiling software. It typically pulls in:

  • gcc and g++ — C and C++ compilers
  • make — runs build instructions
  • libc6-dev — C library headers and development files
  • dpkg-dev — tools for building Debian packages

chrpath is a small Linux utility for inspecting and changing the RPATH/RUNPATH stored in an ELF executable or shared library. These paths tell the dynamic linker where to look for required shared libraries.

It’s commonly used during packaging to remove or adjust build-time library paths before distributing a program. Use it carefully: changing the path incorrectly can prevent the program from finding its libraries.

chrpath -l ./program # show its RPATH/RUNPATH
chrpath -d ./program # remove it
chrpath -r ‘$ORIGIN/lib’ ./program # set a relative path

cpio is both a command-line utility and a package that provides it. It creates and extracts archive files, often used for backups, packaging, and moving files while preserving metadata.

You may see it in Linux system workflows—for example, in initramfs images used during boot, or in software package archives. It’s similar in purpose to tar, though the archive formats differ.

Create an archive from files under mydir

find mydir -print | cpio -o -v -H newc > mydir.cpio

Extract it into the current directory

cpio -i -v < mydir.cpio

-o creates an archive, -i extracts one, -v lists files as they’re processed, and -H newc selects the commonly used newc archive format.

ASLR (Address Space Layout Randomization)

ASLR (Address Space Layout Randomization) is a security feature that randomizes the memory addresses used by key data areas of a process — such as the stack, heap, libraries, and executable code.

🔍 Purpose:

To make it harder for attackers to predict memory locations during an exploit (e.g., buffer overflow, return-oriented programming).

Without ASLR, attackers can rely on fixed addresses to inject or jump to malicious code.
With ASLR, every reboot or process restart changes memory layout, invalidating most static exploits.

How ASLR Works

Memory RegionWhat’s RandomizedExample
Executable baseProgram’s load address/bin/bash loads at different addresses each run
StackStack start addressPrevents predictable stack-smashing offsets
HeapHeap baseStops heap spraying reliability
Shared librarieslibc, etc.Mapped at different offsets each run

ASLR Compliance Meaning

Being ASLR compliant means:

  1. The OS supports ASLR, and
  2. The application, driver, or firmware image is built and linked to use ASLR.

In other words:

The binary and its runtime environment both must support and not disable ASLR.

Windows

  • ASLR is enabled system-wide via /DYNAMICBASE linker flag.
  • You can verify by running:

dumpbin /headers myapp.exe | find "Dynamic base"

→ If Dynamic base is listed → ASLR enabled.

Policies: Controlled via Exploit Protection or Group Policy.

Windows 10+ also support Force ASLR for all executables.

Linux

  • Controlled via /proc/sys/kernel/randomize_va_space
    • Value Meaning
    • 0 ASLR disabled
    • 1 Conservative randomization
    • 2 Full randomization

With value 1, Linux randomizes these user-space memory areas:

Memory areaRandomized with value 1?Notes
mmap base addressYesAffects shared libraries and memory mappings created with mmap()
Shared librariesYesBecause shared libraries are usually loaded through mmap()
StackYesMain thread stack location is randomized
VDSO pageYesKernel-provided virtual syscall page is randomized
Heap / brk areaUsually NoFull heap randomization needs value 2

randomize_va_space = 1
stack + mmap/libs + VDSO randomized

randomize_va_space = 2
stack + mmap/libs + VDSO + heap/brk randomized

Next-Generation Firewall (NGFW) with Layer 7 Filtering in Embedded Systems

A Next-Generation Firewall (NGFW) extends beyond traditional packet filtering (Layer 3/4) by providing application-level (Layer 7) visibility and control. In embedded systems — such as IoT gateways, industrial controllers, or edge servers — integrating NGFW capabilities presents unique challenges due to limited CPU, memory, and power. Layer 7 filtering inspects the application data payload, not just IP/port.
It can:

1. What Layer 7 Filtering Means

Enforce policy based on app, user, or content type — e.g. “block social media APIs” or “allow only JSON over HTTPS from whitelisted domains.”

Identify protocols like HTTP, MQTT, CoAP, Modbus, OPC-UA, etc.

Detect specific application actions (e.g., login, file upload, API calls).

2. NGFW Core Components for Embedded Systems

To achieve this in a constrained environment, the NGFW must include:

ComponentPurposeLightweight Options
Deep Packet Inspection (DPI) EngineParses protocol layers, identifies appsnDPI, L7-filter, Suricata-lite
Stateful Packet Inspection (SPI)Tracks connection statesNetfilter conntrack (Linux)
Application IdentificationUses pattern matching and heuristicsnDPI, AppID library
Content Filtering / IDSDetects malicious payloadsSnort ruleset subset, Suricata rules
Policy EngineEnforces rules per app/user/deviceCustom rule parser or iptables/nftables extensions
TLS/SSL Inspection (optional)For HTTPS visibilityOpenSSL proxy or embedded MITM TLS proxy


3. Example Embedded Software Stack

A realistic embedded NGFW architecture could look like this:

┌───────────────────────────┐
│ Management UI / CLI │
├───────────────────────────┤
│ Policy & Rule Engine │
├───────────────────────────┤
│ AppID + DPI Engine │
│ (nDPI / custom) │
├───────────────────────────┤
│ SPI / Connection Table │
│ (conntrack) │
├───────────────────────────┤
│ Packet I/O (DPDK/eBPF) │
├───────────────────────────┤
│ Network Drivers / NIC │
└───────────────────────────┘

On Linux-based embedded platforms, this stack could run on:

  • OpenWRT / Yocto Linux
  • ARM-based SoCs (Cortex-A53, NXP Layerscape, NVIDIA Jetson, etc.)
  • DPDK or XDP/eBPF for high-performance packet processing


4. Optimization Techniques
To make NGFW features viable in embedded devices:

Maintain a protocol whitelist to minimize parsing workload

Use zero-copy packet paths (DPDK or AF_XDP)

Offload flow classification to smart NICs (like NVIDIA BlueField)

Implement hardware-assisted encryption (AES-NI, ARM Crypto Extensions)

Employ incremental DPI (scan only first few packets per flow)

5. Example Open Source Projects to Build On

FrameworkUse CaseNotes
nDPILightweight DPI engineC library, used by ntopng
SuricataIDS/IPS with Layer 7 supportCan be trimmed for embedded use
Zeek (Bro)Application traffic analysisToo heavy for small systems, ok for edge
OpenWRT + nftablesBase platform for embedded firewallExtensible with Lua/C modules

6. Example Use Cases

  • Industrial IoT gateway blocking unknown MQTT brokers
  • Edge compute node enforcing API access policies
  • 5G small-cell or MEC node filtering HTTP/REST telemetry
  • Smart camera gateway isolating unauthorized cloud uploads

What is the connectx-7 command to read the transceiver data?

To read transceiver (optics) data such as vendor name, part number, wavelength, or temperature from an NVIDIA ConnectX-7 Ethernet adapter, you can use the mlxlink or mlxconfig tools from the Mellanox/NVIDIA MLNX_OFED or NVIDIA Networking tools package.

🔹 1. Using mlxlink (preferred for transceiver info)

sudo mlxlink -d --port --show_media_info

sudo mlxlink -d /dev/mst/mt4125_pciconf0 --port 1 --show_media_info

This shows detailed optics/transceiver information:

  • Transceiver type (QSFP56, OSFP, etc.)
  • Vendor name and part number
  • Serial number
  • Connector type
  • Supported speeds
  • Module temperature, voltage, TX/RX power, etc.

To list available devices:

mst status

🔹 2. Using ethtool (basic optics data for Ethernet interfaces)

sudo ethtool -m

sudo ethtool -m ens5f0

Outputs (if supported):

  • Vendor, serial, wavelength
  • RX/TX bias, power, temperature

Note: Some ConnectX-7 drivers (esp. for OSFP/QSFP-DD) restrict access via ethtool, so mlxlink gives fuller info.

🔹 3. Using mlxconfig (for configuration and EEPROM access)
sudo mlxconfig -d q

sudo mlxconfig -d -e

mlxconfig is mostly for configuration (e.g., link speed, PCIe settings), not optics monitoring — use mlxlink for that purpose.

🔹 4. Example Output Snippet

MediaInfo:

Module: 400GBASE-DR4
Vendor: FINISAR CORP
Vendor PN: FTL410QE2C
Serial Number: FTL1234A0001
Temp: 36.23°C
Voltage: 3.31V
TX Power: 1.72 dBm
RX Power: 2.01 dBm


Adding HTTP/HTTPS proxy for docker image downloads

As part of development your lab network or corporate network might be under a proxy network to download docker images.
This article explains on how to add HTTP/HTTPS proxy to download the docker images in a corporate environment.

Add the below lines

[Service]
Environment=”HTTP_PROXY=http://proxy.mycompany.com:80/”

in /etc/systemd/system/docker.service.d/http-proxy.conf

and

[Service]
Environment=”HTTPS_PROXY=https://proxy.mycompany.com:443/”

in /etc/systemd/system/docker.service.d/https-proxy.conf

Replace proxy.mycompany.com with your companies proxy server details.

Additionally add nameserver entry also to resolve hostnames.

#Use your DNS server details.
nameserver 172.10.22.1

in /etc/resolv.conf

Once added restart docker daemon and reload. Commands below.

$ sudo systemctl daemon-reload
$ sudo systemctl restart docker

How to solve this Dependencies apt –fix-broken install with raspberry pi OS.

Raspberry pi is based on Debian distribution. This article may assist apt repository upgrade failures. When ever there is a broken install, you can use the below command.

apt –fix-broken install
Whatever library it depends on use the below command to resolve it.

dpkg –force-all –configure -a
dpkg –purge –force-depends <library package name>
apt –fix-broken install
apt-get -f install

 

Source: debian – How to solve this Dependencies apt –fix-broken install – Super User

Raspberry Pi Connection closed while doing remote SSH

Faced an issue of unable to connect remotely to my raspberry pi remotely over ssh. Enabled password based authentication etc in sshd_config file. Still the issue not resolved. Below commands assisted in the resolution of the problem.

sudo rm /etc/ssh/ssh_host_*
sudo dpkg-reconfigure openssh-server
sudo systemctl stop ssh
sudo systemctl start ssh

Source: Raspberry Pi Connection closed SSH – Stack Overflow