Switched from Ubuntu-based to Fedora


tl;dr: Fedora’s debugging packages work, Ubuntu’s are out of date.

Linux = Linux = Linux, whether Arch or Slackware or Ubuntu or OpenSUSE or Linux from scratch as I once did (before there were instructions!). Unless and until the kernel forks and someone decides to modify the syscall table, they all use the same basic syscalls, they typically share the same basic libraries and core utilities, etc. They’re all the same.

Why did I use Ubuntu-based distributions? (Note: Not Debian) Because Ubuntu came pre-configured with all the things I did not care to learn or manually configure: ACPI, firmware, X11, a pretty WM theme, etc. I did not particularly care whether I was running Mint, Elementary, Ubuntu MATE or basic Ubuntu (except Unity…nah). As long as it did not do strange things like remove /sbin/ifconfig or have a radically different file structure than I was used to. I felt at home with knowing where the standard file paths were, and knew how to administer my machine. Their package repository was pretty solid. It had almost everything I wanted – and what little was not on it was typically available in Debian-package format. The broader Linux community effectively standardized on this package format. This is crucial. Debian’s apt and FreeBSD’s pkg are in my muscle-memory at this point.

Literally one thing pushed me over: Ubuntu’s SystemTap was broken. Utterly broken!

I got into OS-level programming, specifically, porting a Linux WiFi driver to FreeBSD. I wanted to use SystemTap, Linux’s answer to DTrace, to help understand what is going on during live execution. But SystemTap does not work on Ubuntu – at least currently.

But wait, I thought Linux = Linux = Linux and programs from 20 years ago will still work. Why does SystemTap fail?

SystemTap works by producing C code for a kernel module, compiling it and loading it into memory. Sometime ago, the kernel team changed the get_user_pages() kernel API call. This meant that any code compiled against the old function definition failed. I encountered this in the professional space when the VMWare kernel modules failed to build and I hacked it until it worked. (They think I’m a wizard now). I was on Kernel 4.10 but the version of systemtap Ubuntu used was nearly 2 years old. This meant no one from the Ubuntu team was using it.

I submitted a bug report and installed Fedora 26.

SystemTap was developed by Red Hat and was trivial to get working under Fedora. And while not every single package is available (Bitcoin, Steam thus far), there is enough that moving over was trivial. Also, they come in Cinnamon, which I prefer, with a pretty theme. And it provides a clean terminal out-of-the-box. Which I need. (I would rather use stock XFCE if their terminal was clean than fully-loaded CentOS with an ugly terminal)

dnf took a little getting used to, but a hop-over from apt. So whatever on that front….

I would be willing to try OpenSUSE again, but the latest time I did, they got rid of /sbin/ifconfig for /sbin/ip, which is unacceptable. Silly, perhaps…Does it come in Cinammon? What does it offer? Are the packages as clean and up to date? I may never know, unless another business-need arises. I do not care to run any of these “hardware” distributions, like Arch. I paid my Linux dues around kernel 2.2 on Slackware and its time to move on from that.

Thoughts?

But look, if you’re 99% of the Linux world, any specific distribution is trivial. Pick one and go with it. Unless you’re doing very specific tasks like me, it really does not matter what you use. So stop Distro Hoping!

Advertisements

Breakdown of Christians at my work


I am fairly openly Muslim at work and super friendly. I suspect that is why people open up to me about their own personal religious beliefs. Pretty much everyone I work with is a Christian (well, there’s one atheist, one agnostic, one Eastern White Hindu-spiritualist). Here is a breakdown of the types of Christians I work with in no particular order.

  1. The Lutheran who attends a non-denomination Church, former military, attends a charismatic church. He would attend a Mega Church, but lives too far from one. Outwardly, he does not seem particularly outwardly religious in his day to day life (curses, makes sexual jokes, votes Republican) but is still fundamentally into it, cares for the poor, needy, etc, great guy.
  2. The American-born Jamaican, Seventh Day Adventist, follower of Levitical Law, has Muslims in his family and best friend is Muslim, not particularly gung-ho but cares enough that he regrets having sex before marriage, traditionalist, great guy.
  3. The on-again off-again Irish Catholic who seems more interested in social justice movements. He is pro-Palestinian and loves to talk to me about aspects of Islam, but assumes I hold Liberal views (which I do not). Great guy also!
  4. The Republican-Christian, is a convert to Christianity from Buddhism, attends that very Mega-Church referenced above, makes a lot of ultra-conservative talking points about social justice issues, like calling people “snowflakes”, thinks I lean Liberal (do I give off that vibe?), probably not the most versed in his own religion. He’s the type of Christian who probably supports Israel (his minor-celebrity pastor is a Jewish convert, who can’t stop talking about how he’s Jewish). Sometimes he says semi-heartless, ignorant things about people in need, like how they should just get a job, but I’m sure he’s a great guy at heart.
  5. The Greek Orthodox Christian, who knows an amazing amount about Islam and the Ottoman Empire. He carries Worry-Beads (Similar to Muslim’s Tasbeehs, which I carry around), seems more than moderately learned in comparative Christianity. He randomly says Arabic expressions to me, like Eid Mubarak, wonderful person! If I ever got in a debate, he’s the only one I would actually be afraid of.
  6. The proudest Christian who also doesn’t practice. He attends a Church that worshiping on Saturday, shedding pagan practices, and proselytizing. But they do not have any social services, any counselling, just rigidity and”learn the Bible, spread it to others”. He seems burned out by it….At the same time, he prayers over his food, hates on Catholics and the Pope in particular (sometimes with the Irish Catholic present), says homosexuality is wrong, and that sorta, but then does every heterosexual sin under the sun. Okay, we’re all sinners, but he brags about it! With pictures! He’ll regularly talk about how he’ll have sex for 2-3 hours with two different girls at the same time. Then he teases me about not sleeping around (which truly does offend me, but whatever). When I say “Hey, isn’t that a sin in your religion?” he will respond with “Well, we’re all sinners”, as if Jesus dying on the Cross for your sins is a license to sin. He seems more interested in cars, motorcycles, accumulating money, comedy, and sex than anything else. But really, he’s a nice guy and means no harm.
  7. The Black Baptist. Christianity is just part of his culture. Sure, he might go to Church once in a while, but he doesn’t really care. He regularly brags about he used to “smash chicks” and “giving her the D”. I think he perceives my traditionalism as naive and teases me to an amount that is not appropriate for work. But he’s a good guy at heart, and does a lot of great community service projects on the side.
  8. The former marine protestant. He is one of the most respectful men I have ever met at work. He carries himself very well, which is a difficult aspect of being a “conservative” person in a society that is highly antagonistic to your values. He knows his Bible, can quote passages from memory. He’s also very traditional. For example, he has women eat first, gives up his seat for women, raised his son to hold the door for his girlfriend, that sorta. The man donated a kidney! I could learn a lot from him.
  9. The Alabama Black Jew-Christian: Yes, literally! He found out he’s a Jew by ancestry. He knows the Bible beyond the basics without being a scholar in it. He seems to use it as a serious guiding force in his life. He does not celebrate Christmas or other Pagan holidays, follows Leviticus to a degree, calls certain practices demonic, but isn’t really all that strict and is essentially “living in sin” with his girlfriend-to-be-wife. Also an awesome guy.
  10. The open Lesbian military chick realizing she values Christianity – I have not asked her her exact beliefs, but she seems to be “coming back” (did she leave?) to Christianity. I do not know her life story beyond that. Strangely conservative in some ways. Cool chick!

There are others, but these are just the ones I have gotten to know.

Honestly, its really refreshing for people to be so open about their faith!

Anticipating questions from the “modern” Pakistanis


I am (was, it happened) scheduled to give an “Islamic Talk” before a group of largely non-practicing Muslims who are doing a fundraising dinner for Pakistan. How unfortunate of an audience that I was selected to give this talk. I do not mean this to be humble, I mean that sincerely, if they knew how dark and empty my inner-soul was, they be shocked. However, I was authorized by a Shaykh and maybe at least my outward can be of some benefit.

I know this crowd. They tend to have a fairly hostile approach towards outwardly religious people. I once wore a pakol and pashtun clothing (I am Pashtun) and a woman came up to me and asked me “Are you from the Taliban?” It was fairly rude, because she didn’t even greet me or know who I was. When I said no, mostly in shock, she said “okay, then you can stay”. It was worse because I am very much not cultural, so to have my fledgling expression attacked was disheartening. But I won’t play the victim.

Anyways, before any talk that I present, on any topic, I practice in my car. I also anticipate the sorts of questions that people will ask me afterwards. In particular with this audience, I anticipate someone coming to me and saying that they like Islam, but these Mullahs who study in madrassas are all intellectually backwards and come to foolish conclusions.

I plan to basically criticize modernity, but not do it from a position of ignorance.

Modernists are a very confused group of people. They differ on basic points of morality that I bet even you would disagree with. For example, did you know that they no longer say there is just male or female? Want me to justify it for you from their perspective? (Engage them in a little bit of back and forth, make points they cannot refute).

You think you’re being “modern”? All you’re doing is being a laughable imitation of European culture. Your sleeveless shalwar kameez is not “modern”, its just not Pakistani.

Do you think you’re being educated? Auntie, I have a Masters degree. I’m more educated than you.

Did you know that in modern society, men do not protect women? Men have no obligation towards their wives at all. After all, we’re all just people who happen to have different different biology.

You think technology is so great? Did you know that technological advancement has been slowing down? Most of what we have is basically implementation of existing technologies. The basic principles are the same.

You think we are a golden age of physics? Lets take physics. You argue that physics is a glory to our knowledge and insight. But in modern physics, you have two irreconcilable theories that both explain the world and stand up to empiric observation. How can this be? Similarly, every 100 years or so the entire scientific paradigm changes. And in every period, it is presumed that its current conclusions of science is eternal truth. Then those eternal truths change!

You need to re-evaluate the way you look at the world. This European idolization is backwards.

Custom Kernel Modules for Chromebook


Note: I wrote this about a year and a half ago, but I refer to it all the time. Hopefully the instructions have not changed too much! Enjoy!

I recently purchased a Chromebook. It’s great, it symbolizes the direction the PC market should head – inexpensive, low-powered ARM processor, defense in depth resistance to malware and simple for non-technical users. And with crouton, it functions quite cleanly as a Debian-based workstation.

With its simplicity and low price, there are certain key features that are lacking in the stripped down Linux kernel that can make it frustrating for a power-user. Unfortunately, Chromium addons have not or cannot satisfy some tasks that require kernel-level functionality. Even in crouton, you may find your ability limited to the user-space. Those looking for casual additions, recompiling the kernel may seem like daunting over-kill. Instead, compiling and inserting a single module may serve as an apt alternative. In this guide, I will explain how to compile a custom kernel module to add additional functionality to your Chromebook and how to circumvent the built-in security mechanisms that prevent you from adding into the kernel-space.. This guide is specifically written for an ARM-based CPU using kernel 3.10.18 for the CIFS (SMB) module, but can be trivially ported to any other architecture, kernel and module.

Compiling the Kernel Module

As mentioned, Chromium OS is a stripped down version of Linux. Therefore, you should be able to compile and dynamically link kernel modules from the stock kernel into Chromium.

Per Google’s documentation, you must compile the kernel and modules on an x86_64 CPU, even if you will be compiling an ARM or 32-bit x86 module. This is possible thanks to GNU C Compiler’s cross-platform capability. The documentation also specifies using Ubuntu, but it worked just fine on my Debian 8 workstation.

If you have not already done so, install git, subversion and perform the basic configurations:

sudo apt-get install git subversion
git config --global user.email “name@domain.tld”
git config --global user.name "Your Name"

Google manages its various git repositories with wrapper depot_tools, a custom git wrapper. You can clone the associated git repository and set your PATH environmental variable to include the wrapper scripts as follows.

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

export PATH=`pwd`/depot_tools:"$PATH"

Next, make a directory where your Chromium OS build will reside, download the Chromium source, and synchronize it to the latest updates. This take around 30 minutes to complete.

mkdir chromiumos && cd chromiumos
repo init -u https://chromium.googlesource.com/chromiumos/manifest.git
repo sync

Once completed, you will need to download the cross-platform SDK environment, build the dependencies and enter a chroot(1) environment. This will take another 30 minutes.

cros_sdk

Now that you are inside the chroot(1) environment, you need to specify the hardware configuration for your Chromebook device, either x86-generic, amd64-generic or arm-generic. You can determine your architecture by running uname -m on your Chromebook. For my ARM-based CPU, I did the following:

export BOARD=arm-generic

Now you must prepare the core packages associated with your board.

./setup_board --board=${BOARD}
./build_packages --board=${BOARD}

Change directory to ~/trunk/src/third_party/kernel/ and then to whichever subdirectory is associated with your kernel (ie, v3.10 for 3.10.18). You can determine your kernel version by running uname -r on your Chromebook.

Next, we will need to tell the kernel which hardware platform you are on and start with the base configuration of the kernel. A list the options of base configurations by running find ./chromeos/config. In my case I am using NVIDIA’s Tegra motherboard, which is ./chromeos/config/armel/chromeos-tegra.flavour.config, so I use chromeos-tegra as follows:

./chromeos/scripts/prepareconfig chromeos-tegra

If you are compiling for a non x86_64 CPU, set the architecture and compiler settings as follows:

export ARCH=arm
export CROSS_COMPILE=armv7a-cros-linux-gnueabi-

This next portion is the same as compiling any other kernel module. Configure the kernel by running make menuconfig

Select whichever controls you would like to install and save. Once completed you will have a .config file that corresponds to your hardware. Since we are only compiling the kernel modules, you can either run make modules to compile all kernel modules, or make fs/cifs/cifs.ko to build only a specific module. I prefer the former because your module may require other dependencies in other modules, such as with crypto/md4.ko for cifs. You can verify that the file was built for the right architecture by running file fs/cifs/cifs.ko. Great! On to inserting the module!

ChromiumOS’s Security Mechanisms

ChromeOS is the official signed release of ChromiumOS, which is what you run in developer mode. Even in developer mode, Google implemented multiple defensive mechanisms to slow down a would-be attacker from gaining access the underlying system. To protect the kernel, Google utilized the Linux Security Module (LSM), which validates files from the root partition against a list of cryptographic hash values stored in the kernel, thereby preventing an attacker from loading a malicious kernel modules. In effect, the only way to insert a kernel module is to have it stored on the root partition. But by default, the root partition is set to read-only, so you cannot simply move a file to the root partition and load it.

Therefore, we must disable the root partition verification running the following script.

sudo /usr/share/vboot/bin/make_dev_ssd.sh --remove_rootfs_verification --partitions 4

Now, reboot the machine and from ChromiumOS remount the root partition to be read-writeable, as follows:

sudo mount -o remount,rw /

From here, you should be able to simply insert the kernel module with insmod. Now, you can install
Enjoy!

Draw this shape without picking up your pen


For many years, while in a meeting or in a moment of free time, I have tried to draw this shape without picking up my pen or drawing over the same two points twice.

shape

At best I would get 1 line away, but never completed the shape.

I wanted to know if it was even possible. So I wrote some python code to try every possible combination.

But, the code is below.

#!/usr/bin/env python3

import copy
import sys

lines = {
        1:[2,3],
        2:[1,3,4,6,7],
        3:[1,2,5,6,7],
        4:[2,5,6,7],
        5:[3,7],
        6:[2,3,4,7,8],
        7:[2,3,5,6,8],
        8:[6,7]
    }

def check(cstate):
    for offset in lines:
        if sorted(lines[offset]) != sorted(cstate[offset]):
            return
    print("Solution!")
    sys.exit()

def iteration(clocation, cstate):

    if len(cstate) == 8:
        check(cstate)

    for ilocation in lines[clocation]:
        nstate = copy.deepcopy(cstate)
        y = nstate.get(clocation, [])
        x = nstate.get(ilocation, [])

        if ilocation in y:
            continue

        y = y + [ilocation]
        x = x + [clocation]

        nstate[clocation] = y
        nstate[ilocation] = x
        iteration(ilocation, nstate)

iteration(1, {})
iteration(2, {})

The lines list is an abstraction of the possible points in the shape and where they can connect to. Point 1 is the top point, 2 and 3 are the top corners of the square, 4 and 5 are the far left and right points of the triangle, etc.

Starting at points 1 and 2. Point 1 is functionally the same as points 4, 5 and 8, while point 2 is the same as 2, 3, 6 and 7. No need for unnecessary iterations. Give its current location, the code recursively builds lines to all possible connection points. If no points are available, it just returns.

It breaks when all possible links are met, as seen by the check function. This is done by checking if every point is touched at least one, and then iterating through all points to see if that point is connected to every possible other line.

Turns out it is not possible.

Sucks.

Atheists Cannot Make a Moral Claim


Yes, I mean it. Atheists cannot be moral.

Why? Because if they applied their lack-of-beliefs (for lack of a better words) to its logical conclusions, they would recognize that morality is not objective. It cannot be measured, observed, or even speculated about. It is a non-rational concept.

Typically, atheists appeal to things like “universally” accepted human rights or notions like “harm no one and do as you please”. But these concepts are arbitrarily, they have no basis. They do not rest upon anything tangible or objectively measurable.

Most atheists presume that, absent of religion, we will all fall into a secular utopia, where humanistic values are self-evident and adopted by all. But this isn’t true. Removing religion does not default to humanism, in fact it does not default to anything.

For this reason, when I hear “that is wrong” from an atheist, my immediate question is “wrong based by what standard?” And I never get an answer.

There only thing holding morality is the last vestiges of Christianity – although, even that is on a sharp decline.

May the “New Atheists” live to see the results of their project.

FreeBSD and Linux Remote Dual Booting


The following is a quick and dirty guide on how to setup remote dual booting for FreeBSD (12.0-CURRENT) and Linux (Ubuntu 16.04). Granted, this method is slightly a hack, but it works and suits my needs.

Why remote dual-booting? I am currently developing a FreeBSD kernel module for a PCIe card. The device is supported on Linux and I am using the Linux implementation as documentation. As such, I find myself frequently rebooting into Linux to look printk() outputs, or booting into FreeBSD to test kernel code. This device is located at my house, and I typically work on it during my downtime at work.

Why not use Grub? I would have preferred Grub! But for whatever reason, Grub failed to install on FreeBSD. I do not know why, but even a very minimalistic attempt gave a non-descriptive error message.

efibootmgr? Any change I made with efibootmgr failed to survive a reboot. This is apparently a known problem. Also, this tool only exists on Linux, as FreeBSD does not seem to have an efibootmgr equivalent.

Ugh, so what do I do???

The solution I came up with was to manually swap EFI files on the EFI partition no an as-needed basis.

First, I went into the BIOS and disabled legacy BIOS booting, enabled EFI booting, and disabled secure booting.

Then, I installed Ubuntu. I had to manually create the partition tables, since by default the installer would consume the entire disk. However, this does not automatically create the EFI partition. So, you must manually create one. I set mine to 200MBs as the first partition. After installation, I booted up, mounted the /dev/sda1. I found that ubuntu had created /EFI/ubuntu/grubx64.efi and other related files. Great!

Next, I installed FreeBSD and while manually setting up the partition tables, FreeBSD auto-created an EFI partition. One already exists, so I safely deleted it, and proceeded with the rest of the install. Right before rebooting, I mounted /dev/ada0p1 (sda1 on Linux) as /boot.local/ and /dev/da0p1 as /boot.installer/. I then copied /boot.installer/EFI/BOOT/BOOTX64.EFI too /boot.local/EFI/BOOT/EFIBOOT/BOOTX64.EFI (I think I had to re-create EFI/BOOT, I’m forgetting off-hand). Then I rebooted.

When I rebooted the machine, Ubuntu still came up. This is because Ubuntu edits the EFI boot order and places ubuntu as the first partition. Ordinarily you should be able to use efibootmgr here to boot into FreeBSD and use the non-existent FreeBSD equivalent to boot back, but with the lack of that option, I mounted the EFI partition (/dev/sda1) as /boot/efi, and when I wanted boot into FreeBSD, I renamed /boot/efi/EFI/ubuntu/grubx64.efi to ubuntu.efi and then copied /boot/efi/EFI/BOOT/BOOTX64.EFI to /boot/efi/EFI/ubuntu/grubx64.efi. When I rebooted, FreeBSD came back up! Then on the FreeBSD side, I mounted /dev/sda1 to /boot/efi and did copied /boot/efi/EFI/ubuntu/ubuntu.efi to /boot/efi/EFI/ubuntu/grubx64.efi.

And that’s it! I can now remotely boot back and forth between the two systems.

Ugly? Yes. But it does the job.

Linux could fix this problem by debugging their efibootmgr utility and FreeBSD could fix this by having an efibootmgr equivalent at all.

Thoughts?