LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 04-14-2014, 12:56 AM   #1
ramzi.kahil
LQ Newbie
 
Registered: Apr 2014
Posts: 28

Rep: Reputation: 1
Programming a proof of concept


I'm trying to implement a proof of concept as some academic work, for this I want to manipulate the implementation of linked lists (/include/linux/list.h) in the KVM module. More specifically, I want to execute my code and then delegate it to the real implementation. Now I have thought of two ways to do this and I am not sure which one is preferred (if any).

1. Make a Loadable Linux Module, which has macros named 'add_list2' and 'HAED_LIST_INIT2' and so on, and change the implemenetation of the KVM to address these new functions and macros. This requires me to change every function call and useage of the macros in KVM, and recompile as a module also.

2. Changing the kernels implementation in the list.h file. This will make me compile the hole kernel every time (does it?)

I'll be happy to hear any thoughts about the two options and about other options.
 
Old 04-14-2014, 09:42 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
My read is that list.h is pervasive throughout the entire kernel and therefore you will always need to rebuild the kernel.

If you feel you need to perform your testing using the kernel, then what I'd recommend is to write a wrapper to replace the functions available by list.h and have a global control variable which when un-set directs it to use the classical list functions as offered by the kernel now, and when set directs it to use your replacement functions.

The two problems here are (1) I'm not sure that the list functions are not also used in other loadable modules, therefore it would cause you to need to unload and re-load those, or find some alternative, and (2) adding a test of the variable will therefore add one extra step to all of these functions.

The other alternative is to build the kernel twice, placing in whatever diagnostics you wish for each case and then observing the current implementation during one boot and your proposed implementation with the other boot. As a result, the metrics you'd have to gather would then need to be something which you can compare when you have two different boot instances.

My further assumption is that you're not merely playing with linked lists and really wish to test stability and/or performance of the kernel with your alternative code. Otherwise if you just wish to play with linked lists in general, then there's no reason to involve the kernel, but instead to copy to functions provided by the kernel and make a custom application and then make your changes and rebuild your custom application. That may be a good way to start though, which is to "use" the available linked list capabilities provided by the kernel in an application, and then rewrite that app to use your replacement LL capabilities and do your analysis. Since you haven't described your endgame here, I can only guess what your intentions are.
 
Old 04-14-2014, 11:04 AM   #3
ramzi.kahil
LQ Newbie
 
Registered: Apr 2014
Posts: 28

Original Poster
Rep: Reputation: 1
My end game actually is stated, I want to look at the LL while the KVM is using it, e.g. the vm_list is exactly this type, and I wish to intercept the process while adding, removing an entry, or just doing a list_for_each_entry call. Say I want to go over the list each time and log how many vcpus each VM has (see below). I wanted to copy the implementation to my module, and just recompile it, that would be perfect, but then I realized that I have to copy the whole KVM module to make it work. Thats where my dilemma started.


Code:
#define list_for_each_entry2(kvm, vms_list, vm_list)
{
    printk(KERN_INFO "%d\n", kvm->online_vcpus.counter);
    list_for_each_entry2(kvm, vms_list, vm_list)
}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Proof of concept required business_kid Linux - Software 19 12-26-2012 01:30 PM
Md5 spoof - Proof of concept with sample files! peter1234 General 10 09-25-2010 07:39 AM
New Cross-Platform Virus Proof of Concept win32sux Linux - Security 19 04-18-2006 11:24 PM
LXer: Virus proof of concept can infect both Windows and Linux systems LXer Syndicated Linux News 0 04-08-2006 04:21 PM
LDAP + Proof Of Concept damicatz Linux - Networking 5 11-27-2004 04:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 01:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration