Note-taking and file sharing with Syncthing and Joplin

You can find many note-taking services, like, Evernote, Google Keep, Notion, Obsidian and online storage services such as, Dropbox, Google Drive, OneDrive, iCloud. They are easy to use and secure. But, secure is not equal to private! A way to keep privacy is host private services by self. Edward Snowden’s Privacy Tips: “Get Rid Of Dropbox,” Avoid Facebook And Google This is how I share/edit notes and files with different devices which service providers are unable to peek and analyze my private contents. Joplin and Syncthing in grey are optional in the diagram, for example notes can be written on the Raspberry Pi through the terminal Joplin application, files can share between the Phone and the PC directly but my Raspberry Pi is online 24/7. ...

June 5, 2022 · 4 min · oopsmonk

Install Perf on Ubuntu 20.04

What is Perf? Perf or perf-event is a Linux profiler and is part of the Linux Kernel which can help you solve advanced performance and troubleshooting functions. It covers hardware level (CPU/PMU, Performance Monitoring Unit) features and software features (software counters, tracepoints) as well. Install on Ubuntu If perf has not installed on the system $ perf WARNING: perf not found for kernel 5.4.0-109 You may need to install the following packages for this specific kernel: linux-tools-5.4.0-109-generic linux-cloud-tools-5.4.0-109-generic You may also want to install one of the following packages to keep up to date: linux-tools-generic linux-cloud-tools-generic $ The perf is part of linux-tools-generic package on Ubuntu: ...

April 28, 2022 · 2 min · oopsmonk

Policy Configuration of SELinux and SEAndroid

A Note for SELinux and SEAndroid policy configuration. SEAndroid Security-Enhanced Linux in Android SELinux for Android 8 - Treble mode SEAndroid安全機制中的文件安全上下文關聯分析 - file_context SEAndroid安全機制中的進程安全上下文關聯分析 - process Android 8 Treble mode: Kernel early mount PRODUCT_FULL_TREBLE, PRODUCT_FULL_TREBLE_OVERRIDE, BOARD_SEPOLICY_DIRS Android 4.3 ~ 6 TE macro define: external/sepolicy/te_macros Android 8 TE macro define: system/sepolicy/te_macros ##################################### # domain_trans(olddomain, type, newdomain) # Allow a transition from olddomain to newdomain # upon executing a file labeled with type. # This only allows the transition; it does not # cause it to occur automatically - use domain_auto_trans # if that is what you want. # define(`domain_trans', ` # Old domain may exec the file and transition to the new domain. allow $1 $2:file { getattr open read execute }; allow $1 $3:process transition; # New domain is entered by executing the file. allow $3 $2:file { entrypoint open read execute getattr }; # New domain can send SIGCHLD to its caller. ifelse($1, `init', `', `allow $3 $1:process sigchld;') # Enable AT_SECURE, i.e. libc secure mode. dontaudit $1 $3:process noatsecure; # XXX dontaudit candidate but requires further study. allow $1 $3:process { siginh rlimitinh }; ') ##################################### # domain_auto_trans(olddomain, type, newdomain) # Automatically transition from olddomain to newdomain # upon executing a file labeled with type. # define(`domain_auto_trans', ` # Allow the necessary permissions. domain_trans($1,$2,$3) # Make the transition occur by default. type_transition $1 $2:process $3; ') ##################################### # tmpfs_domain(domain) # Define and allow access to a unique type for # this domain when creating tmpfs / shmem / ashmem files. define(`tmpfs_domain', ` type $1_tmpfs, file_type; type_transition $1 tmpfs:file $1_tmpfs; allow $1 $1_tmpfs:file { read write getattr }; allow $1 tmpfs:dir { getattr search }; ') ##################################### # init_daemon_domain(domain) # Set up a transition from init to the daemon domain # upon executing its binary. define(`init_daemon_domain', ` domain_auto_trans(init, $1_exec, $1) tmpfs_domain($1) ') apol - SELinux policy analysis tool sudo apt install setools-gui SELinux Configuring the SELinux Policy ...

November 17, 2017 · 5 min · oopsmonk

Faster R-CNN Use Caffe Framework

Install caffe framework and run Faster R-CNN demo on Ubuntu 16.04. Test environment CPU: Intel(R) Core(TM) i3-4130 CPU @ 3.40GHz 4-Cores GPU: ASUSTeK GeForce GTX 1060 with 6GB Memory HD: WDC WD5000AAKX OS: Ubuntu 16.04 Test Flow Install software requirement Video pre-processing: get jpeg images from source video Image Labeling Use Faster R-CNN to genrate trained model Run Faster R-CNN demo Requirement Hardware: Good graphic card with large memory (6GB memory is okay, but it has problem in VGG traing.) ...

August 31, 2017 · 12 min · oopsmonk

[Paper] - An Evolutionary Study of Linux Memory Management for Fun and Profit

Memory management主要的功能是page mapping, memory protection, and sharing, 但隨著時間不斷的演進已經算是kernel裡不小的subsystem. 這份研究分析2009~2015年之間4587筆有關memory management(mm)的patches, Linux版本由v2.6.32.1 ~ v4.0-rc4. Source: An Evolutionary Study of Linux Memory Management for Fun and Profit Memory Bugs 5種bugs存在mm: memory error, checking, concurrency, logic and programming. 透過heat map可清楚看到主要bug發生地方 主要的bug fix在: Memory Allocation, Garbage Collection (GC), Virtual Memory Management. 大部份memory leak並不是因為忘了free, 而是錯誤的page fault handling和 free page的計算. MM較大的問題是很難去track正確的狀態. Memory optimization 定義3種optimization patches data structure: 避免nested data structure. Scalability的實現, scalability問題是因為locking for atomic access to shared data structures. memory policy: 使用合理的policy design (latency/throughput, sync/async, lazy/non-lazy, local/global, fairness/performance). fast path: 加速頻繁使用的source code, reduction跟lockless optimization是廣泛被使用. Optimistic barrier是為了減少呼叫barrier/fence system call時的synchronous overheads. (Code reduction, lockless optimization, new function, state caching, inline, code shifting, group excution, optimistic barrier) MM常見的Data structure Radix tree: In adress_space, 主要特色是有效率的存放(sparse)資料. Red-black tree: In vm_area_struct, 可快速的search, insert, delete. 相較於AVL 雖然在search上較快但需要額外的空間, insert/delete比較慢, rotation比較困難. Bitmap: 通常用在RAM的page indexing. List: 廣泛使用的DS, 例如LRU(Last Recently Used) list, 用來追蹤active/inactive pages. ...

June 13, 2017 · 2 min · oopsmonk

Linux Graphic Stack相關的名詞

Linux graphic 架構還滿複雜的, 在看時需要大略了解几個名詞及之間的關係. X Window System: 目前來到第11版本所以叫X11, 是以X window System Core protocol為基礎的window system. wayland: 由於X11太過複雜且在embbeded system中的效能不佳, 用來取代X window System Core protocol. weston (wayland compositor): 以wayland protocol來實做的compositor做為參考的範例, 實用上會用Westeros, Clutter…等. KMS/UMS: Kernel mode-setting 及User mode-setting. OpenGL: 由Khronos Group制定的跨平台graphic API. GLX: 是一個extension, 做為OpenGL與X window system之間的橋樑. 就像embedded system的EGL, MacOS的AGL. DRM(Direct Rendering Manager): 為了防止世界被破壞, 保護世界的和平. 防止同時使用graphic buffer. DRI(Direct Rendering Infrastructure): Mesa及DRM之間的橋樑. Ref: Introduction to the Direct Rendering Infrastructure CRTC (CRT Controller): Crtc is in charge of reading the framebuffer memory and routes the data to an encoder. ...

May 30, 2017 · 1 min · oopsmonk

在Shell使用vi-mode

Vi用慣了, 那在shell也可以vi-style嗎? 答案是可以的! 這個方法可使用在常用的shell, 例如bash, ksh, zsh, mksh. btw, mksh 是Android使用的shell, 但Ubuntu預設的dash 是不支援的. 在shell中執行set -o vi 後按’i’進入insert mode, ‘ESC’為normal mode. 回到原本的模式則是set -o emacs 如下圖: Reference: Using vi-mode in your shell

March 28, 2017 · 1 min · oopsmonk