Whats new?

October 11, 2009 Leave a comment

Last few days I was busy with different kind of stuff.

The most annoying of them is work on linear algebra that I started yesterday and have to submit tomorrow oO

The less annoying things are:

1. Redesign of my kernel. I got some books on Linux internals and OS design, and I want to redesign my kernel now.

2. Implementation of AVL tree. This is driving me crazy, the documentation is not enough. It looks easy but there are things that I did not take in account that break all my design. The moment Ill finish the linear algebra, Ill add the missing part to my AVL tree and finally will be able to use it as Heap Management structure for my kernel.

I’m also planning to release the kernel under GPL or custom license that is similar to GPL, the moment Ill have some things running (like multitasking that I want to start straight after the heap implementation).

Thats it, enjoy 🙂

Have No Idea What To Post…

October 8, 2009 Leave a comment

Yesterday I didn’t have mood to post something. Today I just don’t know what to post.. Hope tomorrow will be better 🙂

Anyway to not waste a whole page of digital ink, I present you the review of Windows 7

http://www.cracked.com/blog/using-windows-7-may-lead-to-murder

“Its better than Vista”

Have a good day 🙂

Categories: Uncategorized Tags: ,

Who Is skwo?

October 6, 2009 Leave a comment

Have you ever wonder who the hell is skwo? Well I’m wondering too. I see that people come to my blog by googling “skwo”, so I googled “skwo” also, and found interesting things, but about this a bit later (Note to everybody who don’t use google, saying yahooing or binging [like wtf?] sound too bad, so don’t be angry at me, I’m sort of google fun).

The Raise Of skwo’s Empire!

The year was 357B.C. The great king s.kwee discovered the new land of FreeNode.net, the land that was knows as “IRC FreeNode Server”. He wanted to take over this land, by registered his name in the book of FreeNode.net users, but he fucked up, someone already registered this name… So I logged to freenode under the nick s.kwee (or skwee, don’t remember) and freenode nickserv kindly said to me “This nickname already registered…”. So I needed a new one and fast. I decided to change the “ee” in skwee, to “o” and skwo was born! In remember of s.kwee I still hold the old email, and I’m registered as s.kwee or skwee in about 1 or 2 sites over the net.

skwo Today

So who is skwo? Google returns:

Results 110 of about 68,900 for skwo. (0.29 seconds)

68,900?! Omg -.-‘ So lets clear some things.

So who I am not?

I don’t have account on YouTube, at least not for now! I don’t use twitter (and probably won’t use). I don’t put my nickname on Facebook, or other social networks (at least not for now). I definitely don’t use MySpace (and never will).

So who I am?

As you already understood, I like computers, programming, and Linux – Arch Linux. So you can find me in sites like, Arch Linux, programming sites, IRC FreeNode Server, wordpress blog (doh -.-). In some places where username skwo already registered (arrr) I am known as skwo357, good example is DeviantArt (that I don’t really use) and how surprisingly my deviantart is about Arch Linux!

Have doubts if the “skwo” you found is me or not?

No problem, feel free to contact me via email s.kwee357[AT]gmail[dot]com

Categories: Uncategorized Tags:

How I lost all of my source files in less than a minute..

October 5, 2009 Leave a comment

This one is actually pretty old, like about two weeks old, I don’t know why I didn’t post it.

So it was a sunny day, about two weeks ago. All day I tried to setup a normal makefile for my project. I wrote and discarded about 5-6 different versions. Finally after about 10-12hours I got one that was pretty good. The problem was that I couldn’t group the object files that was created, in one directory, so all objects was separated over the project directory. A simple command to remove them:
rm `find ./ -name "*.o"`
And thats it, all objects are gone. You can guess the future from this point, but Ill tell it anyway. So it is late, about 1 AM, my makefile is completed, but I need to remove the object that I might left from previous compilations, so I do:
find ./ -name "*.c"
It gives me a listing of all files that it found. Then I do
rm `find ./ -name "*.c"`
For about 20 seconds I watch the output of the command to understand what the hell I did, and when I understood… it was too late.. Here is the comment or IRC:

16:02:06 <skwo> OH F**CK
16:02:14 <skwo> I just wiped half o my os OO
16:02:24 <skwo> is there anyway to restore files that was removed by rm?
16:02:26 <skwo> omg

(Don’t pay attention to the time, the logs are logged in US time I think).

Of course there were no way to restore the files, cause the designers of EXT filesystem, decided to remove the file at all when its deleted… Yes it was embarrassing 😦 Luckily I had a backup that contained about 80% of the lost code. After this day I setup and SVN for this project, and I wont code for more than 10 hours anymore.

How to reinstall linux 3 times in less than two days

October 5, 2009 Leave a comment

Thursday, 1/10/09, I woke up and said “Enough Windows! I can’t handle it anymore! From now I’m going to use Linux as day-day use and windows only when I need it!”, A voice on my head said “Dejavu my friend”… Seems like I said the same year ago, two years ago, and still came back to windows! Oh Bill why are you doing it?! ;( Anyway this time I’m serious about it (voice in my head: “yea right…”)..

So I found an Arch Linux Install CD that I used a year ago. I actually was able to install it without using the beginners guide they provide on their CD. Everything was fine, and hop! I fucked the home partition… I said “Ok install Linux is fun, lets reinstall!” (and I’m serious now, it real fun!). I reinstall, system up and running. I decided to configure MPD (music player daemon), this bitch needs access to my home directory, so I needed to set permission on my home directory that others and group can read the directory, and I fucked up things, that even I can’t read/write to my OWN home directory… Reinstall.

So now my Arch is running (tfu tfu tfu) and I’m enjoying it!

I had an awesome weekend, and now my PC is running Linux (with windows partition, but windows got only 80GB, and Linux 160GB :p).

Categories: Linux Tags: ,

No Time to post =[

September 19, 2009 Leave a comment

Oh I have no time to post 😦

Sorry for that but I was busy with my kernel development (I’m writing kernel, you didn’t know?).

Anyway I didn’t forget the blog! But come-one read and post comments!

Categories: Uncategorized

void main()? No int main()!

September 16, 2009 2 comments

Today at the morning, on my way to the bus station, I asked my self “What should I post today?”

Few years ago (about 3-4) I posted a question about C on one of the forums. I also included my code, it had void main() in it. People started to yell at me, that this is bad and not according the standard. Later I discovered that ANSI says that main must return a value, so I took it as a rule to follow the standard. I couldn’t really find any reason why void main() is bad, as it worked all the time no matter on what OS.

So, today when I know assembly I could find the answer to the holy war between int main and void main.

So what is the difference between void main() and int main()?

Well first of all lets take a look at the assembly code we get after we compile each version of main:

$cat foo.c
int main() { return 0; }
gcc foo.c -o foo
objdump -d foo
08048374 <main>:
08048374:     55                                 push %ebp
8048375:       89 e5                            mov %esp,%ebp
8048377:       b8 00 00 00 00     mov $0x0,%eax
804837c:       5d                                 pop %ebp
804837d:      c3                                  ret
804837e:      90                                  nop
804837f:       90                                 nop

And the second one

$cat foo.c
void main() {}
gcc foo.c -o foo
objdump -d foo
08048374 <main>:
8048374:        55                         push %ebp
8048375:        89 e5                   mov %esp,%ebp
8048377:       5d                          pop %ebp
8048378:        c3                         ret
8048379:        90                        nop
804837a:        90                        nop
804837b:        90                        nop
804837c:        90                        nop
804837d:       90                        nop
804837e:       90                        nop
804837f:        90                       nop

So the only difference in the line mov $0x0, $eax

How does return mechanism works?

So what really happens when you write return 5? This generates an assembly code of mov eax, 0x5. So we can tell for sure that the value in eax register is the value that the function returns. So why int and not void? The standard says that any application must return an error code to the OS, while 0 represents that the execution was successful and everything else represents an error. What the OS does with this value? Nothing special to be honest, but assume the following scenario:

Application A needs to execute application B. A can not continue without B finishes, however B can fail, in that case A have to fail also. How A will know that B failed? Exactly! It will check the value of the eax register after B finished to execute. If we used void main(), and the end of main eax will be undefined and may have any value! So its like Russian roulette 😛 This why we have to write int main()!

I hope this post was useful and you learned something new! Leave comments and have a good day 🙂

Categories: Programming Tags: , ,

A Security bug in Linux kernel

September 15, 2009 Leave a comment

My morning started as usual, woke up at 7:30, turned the PC one, went to kitchen to bring some food and make coffee, then back to the PC to check emails, facebook, forums, and RSS. So one of the news reports was a Linux kernel bug that existed for about eight years! Can you imagine it?

So in short:

Linux kernel implements different sockets. Each socket have a struct assigned to it called proto_ops. The only thing this struct hold is pointers to implementation of different functions like bind, accept, and so on. Some might not implement one of the functions, in this case they should send a pointer to stub function. But even if the pointer left NULL, most of the times the kernel will validate that it is null.

So where is the bug? In function sock_sendpage(). This function does not validate the pointer and therefore can call for a NULL pointer. In this case an attacker can place a code at page 0 and the kernel will execute this code in SUPERVISOR mode!

I haven’t heard about any patch yet, but I’m sure that there will be one soon.

Categories: Linux Tags: , ,

Come Back, or “Welcome No. 2” Post

September 15, 2009 Leave a comment

Wow, I forgot about my bloggie 😦

Bloggie says: “Write ten times that you are sorry!”

Me: “I’m sorry I’m sorry I’m sorry I’m sorry I’m sorry I’m sorry I’m sorry I’m sorry I’m sorry I’m sorry”

Bloggie: “Good!”

Well for those who wonders who the hell I am. I am a 1337 programmer ^^

Nah not really, I just like computers very much, I like programming, I am good at it. In this blog Ill write stuff about computers the most, some life stuff (don’t worry I wont cry about “how sucky my life is” cause my life is awesome :p ), programming, linux, music (metal at most \m/) and thats it.

You are free to comment, share your blogs, read and enjoy 😛

See you 🙂

Mount VDI file

October 25, 2008 1 comment

Hey!

Well as a part of my studies we learn assembly under Dos (crap >.<). Anyway to ged rid of Windows I decided to install a Virtual Machine with FreeDOS. The problem was that its pretty hard to transfer files between Linux and the virtual drive, and I couldn’t setup network transfer (I wonder if its possible at all with FreeDOS). So I decided to mount my VDI file and be able to read/write to it as it was a directory on my filesystem. I googled for “mount vdi” and found this link

http://forums.virtualbox.org/viewtopic.php?t=52&start=0&postdays=0&postorder=asc&highlight=

So lets start 🙂

Tools:

1. Linux :p

2. VDI file – Create new partition with Virtual Box, I used fixed size of 90MB and Installed FreeDOS on it.

3. khexedit – sudo apt-get install khexedit

The moves:

khexedit .VirtualBox/VDI/FreeDOS.vdi

Note: You should use decimal instead of hex, View->Offest as decimal

Now is the hard part: you should look for the beginning of the partition

Mine looks like this:

0000033216 ……………………………………………………….
0000033280 �<.FRDOS4.1……….��.?…?…a�..�.)..p$FREEDOS    FAT16
0000033344 1�.ؽ.|��..�.�.��..���^|�…`..�.�.f��.~$�u..V$�F�..�F�…^��FĠ
0000033408 c.v..~..v..�..v�.~�.F..�f..�.�.v�.~�.^.�.��.F.1���P.�.�..v�.~�.F
0000033472 �.V�_�^Z�..�~Z�..��}W��_&.E.t..� &.=.u�reP�^Z.~..F�.V��g.X…^\�

As you can see before offset 33216 there are almost nothing, and the partition starts at offset 33280.

So now we know the start offset of the partiton lets mount it:

sudo mkdir /mnt/vdifs

sudo mount -o loop,offset=33280,umask=000 .VirtualBox/VDI/FreeDOS.vdi /mnt/vdifs

And we done 🙂

To understand what loop, offset and umask stands for read this

http://forums.virtualbox.org/viewtopic.php?t=52&start=0&postdays=0&postorder=asc&highlight=

Better then I can explain 🙂

Now you can read/write files from your partition like it was part of your system 🙂

To un mount it use:

sudo umount /mnt/vdifs

Enjoy 🙂

Categories: Linux Tags: , , ,