Re: Diploma project with the Linux kernel

2018-10-04 Thread Mike Krinkin
On Fri, Oct 5, 2018 at 3:09 AM  wrote:

> On Fri, 05 Oct 2018 02:58:23 +0100, Mike Krinkin said:
>
> > This might be of interest to you: https://www.criu.org
>
> That's got two problems - first, it's userspace.


Well, it's called userspace, but it does require a significant kernel
support.


> And second, it's fairly
> mature software, which means it's not suitable for a student project
> by itself, and all the low-hanging fruit for improvements has probably
> already been done (meaning that further extensions will be technically
> challenging...)
>

I guess, that someone from the CRIU team might be a better person to tell
whether it's the case. It doesn't take a lot of
effort to ask whether they have tasks that might become a student project,
especially considering that the team doing
CRIU did in the past at least collaborate with univeristies in Russia where
students actually worked on CRIU.


>
> A better source for project ideas is to do a literature search and find
> proof-of-concept projects that *didn't* turn into mature software, and
> need work to turn them into actual running code
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Diploma project with the Linux kernel

2018-10-04 Thread Mike Krinkin
This might be of interest to you: https://www.criu.org

On Thu, Oct 4, 2018 at 8:23 PM  wrote:

> On Thu, 04 Oct 2018 21:44:14 +0300, Boian Karatotev said:
>
> > I am a Computer Science student and for my last year I need to make and
> > present a 'diploma project' at the end of June. So far I want to make a
> > kernel module, whose description is in the following paragraph. I feel
> > comfortable with C and my OS knowledge is maybe slightly better than my
> OS
> > course. My question is: Would it possible to pull this off? I have no
> > experience with the kernel and I want to get into kernel development, so
> > this would be a perfect opportunity for that. My only issue is that this
> > may be too complex for my experience.
>
> > My idea: Something along the lines of checkpoint-restart as a kernel
> > module. I want to ultimately be able to migrate a running process to a
> > different machine (assuming same at least some basic similarity). I know
> of
> > BLCR <
> http://crd.lbl.gov/departments/computer-science/CLaSS/research/BLCR/>
> > and I am planning on using it as a guide, although I am unsure about
> > working on it directly. As far as I know, the grading process does not
> > require this to be 100% complete, so I am aiming at transferring at least
> > all the memory, restoring file descriptors and maybe child
> > processes/threads.
>
> You mean you want to re-invent the current checkpoint-restart code that's
> been
> in the kernel since v3.10 back in June 2013? (see kernel/kcmp.c for the
> gory
> details).
>
> Note that migrating a running process to a different machine is a *lot*
> trickier, especially if it has things like open files or network
> connections.
> "Assume at least some basic similarity" isn't anywhere *near* good enough
> - if
> the process has /home/fred/wombats/my_terabyte_database open, you're going
> to
> need to have it at the same place in the filesystem and data synced across
> to
> the new target (particularly fun if the process scribbles some more on the
> file
> while you're busy migrating it, or if it hasn't done an fsync). Similarly,
> if
> it has a TCP connection open to someplace else, you're going to have to
> figure
> out what to do with the IP 4-tuple and sequence numbers to avoid breaking
> the
> connection. And if it's HPC software using MPI configured to do RDMA over
> Infiniband, that's even uglier
>
> In fact, migrating an entire virtual machine is easier than migrating one
> process, because you don't have to worry about recovering the process
> state,
> that's all in kernel memory that you migrate with the VM.  Move the VM,
> take
> down the IP on the old hypervisor, set up the IP on the new one, toss out a
> gratuitous ARP packet so other machines on the subnet notice, and you're
> ready
> to go...
>
> There's a *reason* why VMWare gets away with charging lots of money for
> their
> enterprise-class software that supports migrating a live VM across
> hypervisors.
> It's a lot harder to do than you think.
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Inject custom code or data into running process

2017-01-03 Thread Mike Krinkin
On Tue, Jan 03, 2017 at 10:54:55PM +0300, Sayutin Dmitry wrote:
> This sounds like a solution, but it's a bit complicated one.
> 
> I would prefer to implement injection in kernel space, because it should be 
> more simple.
> Thank you for your idea nevertheless =)

you are welcome, if you really want to implement injection in kernel
space (IMHO, i'm not sure that it would be easier), you can look at
here:

http://man7.org/linux/man-pages/man7/vdso.7.html

Kernel maps vdso in user space app memory (though it's possible to
disable vdso all together, AFAIK), so if you can add your injection
in vdso, kernel will map your code in an application address space.

> 
> 03.01.2017, 22:45, "Mike Krinkin" :
> > On Tue, Jan 03, 2017 at 10:24:11PM +0300, Sayutin Dmitry wrote:
> >>  Hello, how one should inject code or data into allready running process?
> >
> > If you have enough priviledges to use ptrace you can write in a target
> > process memory. Though, AFAIK, you can only overwrite existing memory and
> > can't create new mapping using ptrace, so in order to overcome this you
> > need to save original code first, rewrite it with your injection bootstrap
> > code (bootstrap code for example can load a shared library), execute it
> > and then return original code back.
> >
> >>  There is no need to start code execution at this point, but it should 
> >> appear in it's virtual memory.
> >>
> >>  Moreover, i want this data to persist across execve's or clone's 
> >> (probably can be implemented as hook on appropriate kernel methodes)
> >>
> >>  (If you want to know motivation for this -- I want to implement some new 
> >> idea on sandboxing).
> >>
> >>  Thanks in advance, Sayutin Dmitry 
> >>
> >>  ___
> >>  Kernelnewbies mailing list
> >>  Kernelnewbies@kernelnewbies.org
> >>  https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> 
> - 
> Sayutin Dmitry 

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Inject custom code or data into running process

2017-01-03 Thread Mike Krinkin
On Tue, Jan 03, 2017 at 10:24:11PM +0300, Sayutin Dmitry wrote:
> Hello, how one should inject code or data into allready running process?

If you have enough priviledges to use ptrace you can write in a target
process memory. Though, AFAIK, you can only overwrite existing memory and
can't create new mapping using ptrace, so in order to overcome this you
need to save original code first, rewrite it with your injection bootstrap
code (bootstrap code for example can load a shared library), execute it
and then return original code back.

> 
> There is no need to start code execution at this point, but it should appear 
> in it's virtual memory.
> 
> Moreover, i want this data to persist across execve's or clone's (probably 
> can be implemented as hook on appropriate kernel methodes)
> 
> (If you want to know motivation for this -- I want to implement some new idea 
> on sandboxing).
> 
> 
> Thanks in advance, Sayutin Dmitry 
> 
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: How to compile Linux kernel with -O0 flag

2016-08-13 Thread Mike Krinkin
On Sat, Aug 13, 2016 at 09:56:05PM +0300, Aleksander Alekseev wrote:
> > The kernel will not run with -O0, sorry, just live with the build
> > optimization levels that is currently used and you should be fine.
> 
> Oh, I see. Fortunately I'm not afraid of assembler :) Thanks.
> 
> Just out of curiosity - is there a technical reason why -O0 couldn't
> be used in Linux kernel? I don't know, spinlocks would not work in this
> case because it's how GCC was written or something. Or just nobody
> compiles and tests kernel like this so it most likely would not work?

Just fixed Makefile and tried to build it with -O0, it doesn't even
compile, i got errors like this:

./include/linux/compiler-gcc.h:243:38: error: impossible constraint in ‘asm’
 #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
  ^
./arch/x86/include/asm/cpufeature.h:146:3: note: in expansion of macro 
‘asm_volatile_goto’
   asm_volatile_goto("1: jmp 6f\n"

Probably gcc cannot figure out that an macro argument can be evaluated at
compile time with optimizations disabled.

> 
> > But why do you want to use a debugger on the kernel?  That's not a
> > normal task unless you are bringing up a new hardware platform.
> 
> It's just something I always do when I learn new things. Trying to
> figure out how to debug something in this new environment. No real task
> so far.
> 
> -- 
> Best regards,
> Aleksander Alekseev
> 
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: help please first module

2016-07-25 Thread Mike Krinkin
On Mon, Jul 25, 2016 at 08:04:41PM +0200, hinawa wrote:
> hello i am starting to write modules and this code does not compile
> 
> hello.c:
> 
> /
> 
>   Modulo experimental
> 
> /*

Probably, error is in the line above.

> 
> #include 
> #include 
> #include 
> 
> MODULE_LICENSE("GPL");
> MODULE_AUTHOR("Alberto Cerezo ");
> MODULE_DESCRIPTION("\"Hola Mundo\" Modulo experimental");
> MODULE_VERSION("printk");
> 
> static int __init hola_init(void)
> {
>   printk(KERN_INFO "Hola mundo\n");
>   return 0;
> }
> 
> 
> static void __exit hola_exit(void)
> {
>   printk(KERN_INFO "Adios, me marcho\n");
> }
> 
> module_init(hola_init);
> module_exit(hola_exit);
> 
> 
> Makefile:
> 
> obj-m += hello.o
> 
> all:
>   make -C /lib/modules/$(shell uname -r)/build M=${PWD} modules
> clean:
>   make -C /lib/modules/$(shell uname -r)/build M=${PWD} clean
> 
> 
> error:
> 
> In file included from 
> /usr/src/linux-headers-4.6.0-1-common/include/linux/init.h:4:0,
>   from 
> /home/hinawa/Documentos/programasC/modulos/mod1/hello.c:9:
> /usr/src/linux-headers-4.6.0-1-common/include/linux/compiler.h:89:1: 
> error: expected identifier or ‘(’ before ‘struct’
>   struct ftrace_branch_data {
>   ^
> make[4]: *** [/home/hinawa/Documentos/programasC/modulos/mod1/hello.o] 
> Error 1
> make[3]: *** [_module_/home/hinawa/Documentos/programasC/modulos/mod1] 
> Error 2
> make[2]: *** [sub-make] Error 2
> make[1]: *** [all] Error 2
> make: *** [all] Error 2
> 
> 
> 
> I do not get to find the error because the code appears to be correct ...
> 
> thks
> 
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Finding GPIO names under Linux

2016-05-23 Thread Mike Krinkin
On Mon, May 23, 2016 at 04:05:23PM +0200, Johannes Thoma wrote:
> Dear list,
> 
> I am writing a driver which uses the "new" descriptor interface of the 
> GPIO library. As far as I have understood it, gpiod_get(8) is the way to 
> allocate (and also lock?) GPIOs pins for use. My question is how do I 
> find what to pass as the con_id parameter (this should identify the pin 
> but please correct me if I am wrong, in that case how to I tell 
> gpiod_get which pin I want?). Is there a file somewhere where I can find 
> the pin names of my hardware (which is a raspberry 1 for now), something 
> like /sys/class/gpio/xxx/gpio_pin_names or so, or do I have to look them 
> up in the device tree or somewhere else? Or do I have to
> configure the pin somewhere in the device tree? What I would like to
> do is offer an interface (via configfs) where the pins the sensor is
> attached can be configured dynamically at run-time.
> 
> The driver itself is OpenSource (GPL) and can be obtained at
> 
> http://github.com/johannesthoma/linux-hc-sro4
> 
> (iio branch is currently the dev branch where this problem occurs).
> 
> Thanks a lot,

A while ago i was trying to understand how to use descriptor based interface
playing with my RPi, you can find ressults here:

https://github.com/krinkinmu/rpi-gpio-example

(*.tex files are in russian, sorry), IFAIU, you have to specify name in
device tree before you can use it.

> 
> - Johannes
> 
> 
> 
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Attach my own pid

2016-03-22 Thread Mike Krinkin
On Sun, Mar 20, 2016 at 02:07:29AM -0700, Nitin Varyani wrote:
> Hi,
>  The linux kernel attaches a pid to newly forked process. I want to
> create a facility by which a process has the option of attaching a new pid
> to its child which is not in the pid space.
>   Any suggestions of how this can be achieved?
> Nitin

Don't know what you are trying to accomplish, but have a look at this:

https://criu.org/Pid_restore

> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Virtual and physical page address

2016-02-08 Thread Mike Krinkin
On Mon, Feb 08, 2016 at 08:57:01AM -0500, Mohammad A Khasawneh wrote:
> Thank you for your answer. Is there a way to get the virtual address by
> traversing the pgd->pte->page hierarchy?

Well, position of pte in the hierarchy defines the virtual address, so yes,
there is way. I'm not sure that a portable across different architetures way
exists though. You can look at this reference:

https://www.kernel.org/doc/gorman/html/understand/understand006.html

> I'm not sure I can use the phys_to_virt() function.

In general you can't.

> 
> Thanks,
> Mohammad
> On Feb 7, 2016 16:43, "Mike Krinkin"  wrote:
> 
> > On Sun, Feb 07, 2016 at 04:24:08PM -0500, Mohammad A Khasawneh wrote:
> > > Hello everyone,
> > >
> > > I am attempting to dump the page table of a process in terms of virtual
> > > addresses and the corresponding physical addresses. I am looking for
> > > information whether the pointers I am using are correct for this purpose:
> > >
> > > 1. Can I say that pte_page(pte_t) returns the virtual address of the page
> > > that the PTE points at?
> >
> > pte_page returns struct page pointer (virtual address of the struct page,
> > but
> > i suppose it's not the virtual address you need), it has nothing to do
> > with a
> > virtual address the pte corresponds to.
> >
> > >
> > > 2. can I say that page_to_phys(struct page) returns the physical address
> > of
> > > that same entry?
> >
> > page_to_phys returns physical address the struct page corresponds to, so
> > yes.
> >
> > >
> > > Thank you,
> > > Mohammad
> >
> > > ___
> > > Kernelnewbies mailing list
> > > Kernelnewbies@kernelnewbies.org
> > > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> >
> >

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Virtual and physical page address

2016-02-07 Thread Mike Krinkin
On Sun, Feb 07, 2016 at 04:24:08PM -0500, Mohammad A Khasawneh wrote:
> Hello everyone,
> 
> I am attempting to dump the page table of a process in terms of virtual
> addresses and the corresponding physical addresses. I am looking for
> information whether the pointers I am using are correct for this purpose:
> 
> 1. Can I say that pte_page(pte_t) returns the virtual address of the page
> that the PTE points at?

pte_page returns struct page pointer (virtual address of the struct page, but
i suppose it's not the virtual address you need), it has nothing to do with a
virtual address the pte corresponds to.

> 
> 2. can I say that page_to_phys(struct page) returns the physical address of
> that same entry?

page_to_phys returns physical address the struct page corresponds to, so yes.

> 
> Thank you,
> Mohammad

> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Inexplicable PROT_EXEC flag set on mmap callback

2016-01-16 Thread Mike Krinkin
On Sat, Jan 16, 2016 at 01:16:42PM -0500, Kenneth Adam Miller wrote:
> Ok, so you think that the format of the binary would influence the kernel
> to change the permissions on the user's behalf? There's not much prose
> explanation here, and I don't understand why the kernel would do something
> like this.

That personality falg was introduced here with quite a detail explanation
(which i don't understand though):
http://lwn.net/Articles/94068/

> I just wanted to use a static binary to eliminate library
> dependency issues between my host machine and the target machine. I had no
> idea that settings like this would carry over to my task at hand.

I compiled simple hello world with -static flag, and GNU_STACK in the binary
has no executable flag set, so static has probably nothing to do with this.

> 
> On Sat, Jan 16, 2016 at 1:08 PM, Mike Krinkin  wrote:
> 
> > On Sat, Jan 16, 2016 at 12:45:17PM -0500, Kenneth Adam Miller wrote:
> > > I got the strace output of my non-C binary (I filtered the noise out of
> > the
> > > output for you):
> > >
> > > mmap(NULL, 8192, PROT_READ | PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
> > 0)
> > >
> > > I also have readelf -l output:
> > >
> > > Elf file type is EXEC (Executable file)
> > > Entry point 0x401311
> > > There are 7 program headers, starting at offset 64
> > >
> > > Program Headers:
> > >   Type   Offset VirtAddr   PhysAddr
> > >  FileSizMemSiz  Flags  Align
> > >   LOAD   0x 0x0040 0x0040
> > >  0x000db604 0x000db604  R E1000
> > >   LOAD   0x000dc1c0 0x004dd1c0 0x004dd1c0
> > >  0x6220 0x91dc  RW 1000
> > >   NOTE   0x01c8 0x004001c8 0x004001c8
> > >  0x0024 0x0024  R  4
> > >   GNU_EH_FRAME   0x000d5680 0x004d5680 0x004d5680
> > >  0x5f84 0x5f84  R  4
> > >   GNU_STACK  0x 0x 0x
> > >  0x 0x  RWE0
> >
> > Well, probably this is a bit more relevant:
> > http://lxr.free-electrons.com/source/mm/mmap.c#L1281
> >
> > As far as i can see, kernel sets READ_IMPLIES_EXEC flag here:
> > http://lxr.free-electrons.com/source/fs/binfmt_elf.c#L844
> >
> > if executable_stack != EXSTACK_DISABLE_X, and executable_stack initialized
> > here:
> > http://lxr.free-electrons.com/source/fs/binfmt_elf.c#L781
> >
> > if GNU_STACK has an executable flag set (and i suppose, that RWE means,
> > that
> > in your case GNU_STACK indeed has exectuable flag set).
> >
> > It may be a reason, i'm not shure though. May be this can help:
> > http://man7.org/linux/man-pages/man2/personality.2.html
> >
> >
> > >   TLS0x000dc1c0 0x004dd1c0 0x004dd1c0
> > >  0x0100 0x0100  R  10
> > >   GNU_RELRO  0x000dc1c0 0x004dd1c0 0x004dd1c0
> > >  0x5e40 0x5e40  RW 20
> > >
> > >  Section to Segment mapping:
> > >   Segment Sections...
> > >00 .note.gnu.build-id .init .text .fini .gcc_except_table .rodata
> > > .debug_gdb_scripts .eh_frame .eh_frame_hdr
> > >01 .tdata .data.rel.ro.local .data.rel.ro .init_array .got
> > .got.plt
> > > .data .bss
> > >02 .note.gnu.build-id
> > >03 .eh_frame_hdr
> > >04
> > >05 .tdata
> > >06 .tdata .data.rel.ro.local .data.rel.ro .init_array .got
> > .got.plt
> > >
> > > Some notes:
> > >
> > > As a test, I changed the non-C binary's target device file to /dev/zero,
> > > and then I could see that the non-C mmap attempt would succeed just fine.
> > >
> > > After further verification and debugging based on guidance from another
> > > forum, I have convinced that the vm_flags change must be occuring
> > somewhere
> > > in kernel land after control flow has left user land. Now I need to
> > figure
> > > out how to use a kernel debugger or kprobes to walk through the execution
> > > of mmap callback delegation and see where the flags paramete

Re: Inexplicable PROT_EXEC flag set on mmap callback

2016-01-16 Thread Mike Krinkin
On Sat, Jan 16, 2016 at 12:45:17PM -0500, Kenneth Adam Miller wrote:
> I got the strace output of my non-C binary (I filtered the noise out of the
> output for you):
> 
> mmap(NULL, 8192, PROT_READ | PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
> 
> I also have readelf -l output:
> 
> Elf file type is EXEC (Executable file)
> Entry point 0x401311
> There are 7 program headers, starting at offset 64
> 
> Program Headers:
>   Type   Offset VirtAddr   PhysAddr
>  FileSizMemSiz  Flags  Align
>   LOAD   0x 0x0040 0x0040
>  0x000db604 0x000db604  R E1000
>   LOAD   0x000dc1c0 0x004dd1c0 0x004dd1c0
>  0x6220 0x91dc  RW 1000
>   NOTE   0x01c8 0x004001c8 0x004001c8
>  0x0024 0x0024  R  4
>   GNU_EH_FRAME   0x000d5680 0x004d5680 0x004d5680
>  0x5f84 0x5f84  R  4
>   GNU_STACK  0x 0x 0x
>  0x 0x  RWE0

Well, probably this is a bit more relevant:
http://lxr.free-electrons.com/source/mm/mmap.c#L1281

As far as i can see, kernel sets READ_IMPLIES_EXEC flag here:
http://lxr.free-electrons.com/source/fs/binfmt_elf.c#L844

if executable_stack != EXSTACK_DISABLE_X, and executable_stack initialized
here:
http://lxr.free-electrons.com/source/fs/binfmt_elf.c#L781

if GNU_STACK has an executable flag set (and i suppose, that RWE means, that
in your case GNU_STACK indeed has exectuable flag set).

It may be a reason, i'm not shure though. May be this can help:
http://man7.org/linux/man-pages/man2/personality.2.html


>   TLS0x000dc1c0 0x004dd1c0 0x004dd1c0
>  0x0100 0x0100  R  10
>   GNU_RELRO  0x000dc1c0 0x004dd1c0 0x004dd1c0
>  0x5e40 0x5e40  RW 20
> 
>  Section to Segment mapping:
>   Segment Sections...
>00 .note.gnu.build-id .init .text .fini .gcc_except_table .rodata
> .debug_gdb_scripts .eh_frame .eh_frame_hdr
>01 .tdata .data.rel.ro.local .data.rel.ro .init_array .got .got.plt
> .data .bss
>02 .note.gnu.build-id
>03 .eh_frame_hdr
>04
>05 .tdata
>06 .tdata .data.rel.ro.local .data.rel.ro .init_array .got .got.plt
> 
> Some notes:
> 
> As a test, I changed the non-C binary's target device file to /dev/zero,
> and then I could see that the non-C mmap attempt would succeed just fine.
> 
> After further verification and debugging based on guidance from another
> forum, I have convinced that the vm_flags change must be occuring somewhere
> in kernel land after control flow has left user land. Now I need to figure
> out how to use a kernel debugger or kprobes to walk through the execution
> of mmap callback delegation and see where the flags parameter is being
> changed.
> 
> I was pointed out to this:
> http://lxr.free-electrons.com/source/mm/mmap.c#L1312
> 
> But why would my vm_flags be changed by the kernel? And what can I do to
> get this to stop? Why is the kernel changing the vm_flags for a non-C
> binary using my device file, but not for either a C binary using my device
> file or any type of binary that's not using my device file?
> 
> On Thu, Jan 14, 2016 at 12:28 PM, Kenneth Adam Miller <
> kennethadammil...@gmail.com> wrote:
> 
> >
> >
> > On Thu, Jan 14, 2016 at 12:00 PM, Mike Krinkin 
> > wrote:
> >
> >> Hi, i have a couple of questions to clarify, if you don't mind
> >>
> >> On Thu, Jan 14, 2016 at 11:04:28AM -0500, Kenneth Adam Miller wrote:
> >> > I have a custom drive and userland program pair that I'm using for a
> >> very
> >> > special use case at my workplace where we are mapping specific physical
> >> > address ranges into userland memory with a mmap callback. Everything
> >> works
> >> > together well with a C userland program that calls into our driver's
> >> ioctl
> >> > and mmap definitions, but for our case we are using an alternative
> >> systems
> >> > language just for the userland program.
> >>
> >> So you have userland app written in C, and another not written in C?
> >> The former works well while the latter doesn't, am i right?
> >>
> >
> > Yes, the former works in so much as mmap c

Re: Inexplicable PROT_EXEC flag set on mmap callback

2016-01-14 Thread Mike Krinkin
Hi, i have a couple of questions to clarify, if you don't mind

On Thu, Jan 14, 2016 at 11:04:28AM -0500, Kenneth Adam Miller wrote:
> I have a custom drive and userland program pair that I'm using for a very
> special use case at my workplace where we are mapping specific physical
> address ranges into userland memory with a mmap callback. Everything works
> together well with a C userland program that calls into our driver's ioctl
> and mmap definitions, but for our case we are using an alternative systems
> language just for the userland program.

So you have userland app written in C, and another not written in C?
The former works well while the latter doesn't, am i right?

> That mmap call is failing (properly
> as we want) out from the driver's mmap implementation due to the fact that
> the vm_flags have the VM_EXEC flag set. We do not want users to be able to
> map the memory range as executable, so the driver should check for this as
> it does. The issue is in the fact that somewhere between where mmap is
> called and when the parameters are given to the driver, the vma->vm_flags
> are being set to 255. I've manually checked the values being given to the
> mmap call in our non-C binary, and they are *equivalent* in value to that
> of the C program.

By "manually" do you mean strace? Could you show strace output for
both apps? And also could you show readelf -l output for both binaries?

> 
> My question is, is there anything that can cause the vma->vm_flags to be
> changed in the trip between when the user land program calls mmap and when
> control is delivered to the mmap callback?

> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: 回复:Re: some question about arch/x86/kernel/head_64.S

2015-12-30 Thread Mike Krinkin
On Wed, Dec 30, 2015 at 08:04:19PM +0800, hitmoon wrote:
> Thank you mike!
> so ,after the first instruction ,rbp contains the offset of actually loaded
> address, which equals the physical address.

yes, comment above says that at that point "someone has loaded an identity
mapped page table", so it should be equal to the physical address.

> $_text - __START_KERNEL_map contains the expected physical address .
> Right ?

yes, as far as i can tell.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: first patch

2015-12-22 Thread Mike Krinkin
On Wed, Dec 23, 2015 at 11:37:14AM +0800, maoma king wrote:
> Dear
>   I have sent my first patch (https://lkml.org/lkml/2015/11/18/239) to
> linux-next tree.But I never received anything about it.So I sent it
> again. You say "Doesn't apply to my tree :(".but it can be apply to
> least linux-next branch .

Check against staging-testing or staging-next branches on the staging tree.
Look at this http://kernelnewbies.org/FirstKernelPatch.

> I make n new patch and send it.I receive
> review(https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1048115.html)
> .
> I want to know what's wrong with me?
> how do I know that my patch is accepted?
> 
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Poking eudyptula for status updates

2015-06-25 Thread Mike Krinkin
On Thu, Jun 25, 2015 at 05:45:37PM +0200, Luis de Bethencourt wrote:
> On Thu, Jun 25, 2015 at 06:30:23PM +0300, Mike Krinkin wrote:
> > On Thu, Jun 25, 2015 at 05:02:53PM +0200, Luis de Bethencourt wrote:
> > > Hello all,
> > > 
> > > I've been waiting for a week now since I submitted task 5 to Eudyptula.
> > > I understand reviewing submissions takes time, specially the tasks that 
> > > are
> > > reviewed manually and there is a queue. Plus, it helps make the challege
> > > replicate the experience of contributing to an open project. Waiting is 
> > > fine.
> > > 
> > > What I am wondering is if my task fell through the cracks. Not sure if 
> > > there is
> > > a method to poke eudyptula for a status update. To confirm the 
> > > submissions is
> > > in the queue.
> > 
> > Did you receive respond when submitted task? If so then it's ok, actually 
> > one week isn't so much.
> > 
> 
> I got confirmation. It should be in the queue.
> 
> I saw some tasks were lost on June 15th due to some distribution mishap and
> wondering if it happened again.
>

In case of this you can expect at least a notification (as it was with lost 
submissions in June).
 
> > > 
> > > Is there an equivalent of politely asking a project maintainer about 
> > > review
> > > when a decent amount of time has passed since submission?
> > > I know that if you resubmit you get pushed to the tail of the queue.
> > > 
> > > Sorry if this has been asked or explained before, I have searched and 
> > > couldn't
> > > find anything about the matter. Sorry for yet another Eudyptula related 
> > > email
> > > in the list.
> > 
> > Just send a mail to little, there is no other way to communicate with him, 
> > as far as I know.
> > 
> 
> I wasn't sure if this was allowed or not. Just to be clear, a mail responding
> to the task submission/confirmatin or a new one?
> 
> Thanks for the suggestion.

I used to send questions in respond to the task. You can try email little
directly, if you concerned about position in the queue, but i've never tried.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Poking eudyptula for status updates

2015-06-25 Thread Mike Krinkin
On Thu, Jun 25, 2015 at 05:02:53PM +0200, Luis de Bethencourt wrote:
> Hello all,
> 
> I've been waiting for a week now since I submitted task 5 to Eudyptula.
> I understand reviewing submissions takes time, specially the tasks that are
> reviewed manually and there is a queue. Plus, it helps make the challege
> replicate the experience of contributing to an open project. Waiting is fine.
> 
> What I am wondering is if my task fell through the cracks. Not sure if there 
> is
> a method to poke eudyptula for a status update. To confirm the submissions is
> in the queue.

Did you receive respond when submitted task? If so then it's ok, actually one 
week isn't so much.

> 
> Is there an equivalent of politely asking a project maintainer about review
> when a decent amount of time has passed since submission?
> I know that if you resubmit you get pushed to the tail of the queue.
> 
> Sorry if this has been asked or explained before, I have searched and couldn't
> find anything about the matter. Sorry for yet another Eudyptula related email
> in the list.

Just send a mail to little, there is no other way to communicate with him, as 
far as I know.

> 
> Thanks,
> Luis
> 
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Debugging an ARP issue (no resp to ARP requests)

2015-01-19 Thread Mike Krinkin
Hi,

On Mon, Jan 19, 2015 at 03:42:58PM -0800, Mandeep Sandhu wrote:
> Hi All,
> 
> Please let me know if this is not the correct ML for such a question
> (or if there's a more appropriate list for it).
> 
> I'm currently debugging an issue where Linux is not responding to ARP
> requests (testing with custom network interface h/w).
> 
> I have 2 network interfaces which are basically interfaces on a custom
> network device sitting on the PCI bus.
> 
> My setup looks like follows:
> 
> xeth0 - 192.168.2.1
> xeth2 - 192.168.2.2
> 
> xeth0/2 are the interfaces created for the custom device (via a lkm)
> 
> Both these interfaces are on the local machine and are connected
> back-to-back on the custom device, so packets sent from one arrive on
> the other.
> 
> I'm testing this setup by sending a single ARP pack, forced out of one
> interface, for the other interface's IP.
> 
> $ sudo arping -c 1 -i xeth0 192.168.2.2
> ARPING 192.168.2.2
> 
> --- 192.168.2.2 statistics ---
> 1 packets transmitted, 0 packets received, 100% unanswered (0 extra)
> 
> If I start tcpdump on the receive interface (xeth2), I see the ARP
> packet arrive, but I don't see any response go out (I've attached the
> pcap file for anyone interested in looking at the received packet).
> The ARP packet's contents seem to be proper under wireshark.
> 
> Is there any statistics I can look at to see if the packet was dropped
> by linux during ARP processing?
> 
> I've put debug stmts in the LKM, but I don't see the kernel IP layer
> calling the xmit function for an ARP reply (however the xmit function
> for the ARP request, from xeth0, is being called).

Have you tried to put debug prints in arp_process function?

> 
> I don't see any drops in "netstat -s" output as well.
> 
> Any hints appreciated.

Just a random guess, but try to disable reverse path filtering (rp_filter).

> 
> Thanks,
> -mandeep

> w??T?g<<???~e?~e????
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: container_of

2015-01-17 Thread Mike Krinkin
Hi, Simon

> I compiled the kernel two times, one time with the original code and
> one time with
> #define container_of(ptr, type, member) ({\
>   (type *)( (char *)ptr - offsetof(type,member) );})

try with following version:

#define container_of(ptr, type, member) ({ \
(type *)((char *)(ptr) - offsetof(type, member));})

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies