* sysfs binary attribute API flux @ 2012-03-22 20:38 Jonathan McCune 2012-03-22 21:28 ` Greg KH 0 siblings, 1 reply; 5+ messages in thread From: Jonathan McCune @ 2012-03-22 20:38 UTC (permalink / raw) To: linux-kernel; +Cc: Jonathan M. McCune Greetings, I maintain a Linux kernel module for a research project*, where it is necessary to move some binary data from userspace into the kernel. I have been using sysfs's 'struct bin_attribute'. Unfortunately, every few kernel versions, my code breaks because of a change in the definition of some elements in this struct. For example, kernel versions 2.6.20, 2.6.32, and 2.6.38 each define the 'read' and 'write' function pointers differently. I will spare the inline diff, but they can each be seen here: http://lxr.linux.no/linux+v2.6.32.59/include/linux/sysfs.h#L65 http://lxr.linux.no/linux+v2.6.38.8/include/linux/sysfs.h#L88 http://lxr.linux.no/linux+v2.6.20.21/include/linux/sysfs.h#L54 My question: is there some other interface that I should be using? Am I using sysfs incorrectly? All of the documentation I've been able to find seems to strongly encourage the use of sysfs. http://kernel.org/doc/Documentation/filesystems/sysfs.txt cc appreciated in reply. Many thanks, -Jon * http://flickertcb.sourceforge.net/ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sysfs binary attribute API flux 2012-03-22 20:38 sysfs binary attribute API flux Jonathan McCune @ 2012-03-22 21:28 ` Greg KH 2012-03-23 13:25 ` Jonathan McCune 0 siblings, 1 reply; 5+ messages in thread From: Greg KH @ 2012-03-22 21:28 UTC (permalink / raw) To: Jonathan McCune; +Cc: linux-kernel On Thu, Mar 22, 2012 at 04:38:46PM -0400, Jonathan McCune wrote: > Greetings, > > I maintain a Linux kernel module for a research project*, where it is > necessary to move some binary data from userspace into the kernel. What exact type of binary data are you talking about here? > I > have been using sysfs's 'struct bin_attribute'. Unfortunately, every > few kernel versions, my code breaks because of a change in the > definition of some elements in this struct. For example, kernel > versions 2.6.20, 2.6.32, and 2.6.38 each define the 'read' and 'write' > function pointers differently. I will spare the inline diff, but they > can each be seen here: Is this a problem? It's only an issue for code that lives outside of the kernel, and there's nothing we can do about that, sorry. > My question: is there some other interface that I should be using? Am > I using sysfs incorrectly? All of the documentation I've been able to > find seems to strongly encourage the use of sysfs. debugfs? What exactly are you using this data for? Who creates it? What does it represent? thanks, greg k-h ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sysfs binary attribute API flux 2012-03-22 21:28 ` Greg KH @ 2012-03-23 13:25 ` Jonathan McCune 2012-03-23 16:20 ` Greg KH 0 siblings, 1 reply; 5+ messages in thread From: Jonathan McCune @ 2012-03-23 13:25 UTC (permalink / raw) To: Greg KH; +Cc: linux-kernel On Thu, Mar 22, 2012 at 5:28 PM, Greg KH <greg@kroah.com> wrote: >> necessary to move some binary data from userspace into the kernel. > What exact type of binary data are you talking about here? There is a statically linked executable, which will also take a binary blob as input, and produce another as output. >> have been using sysfs's 'struct bin_attribute'. Unfortunately, every >> few kernel versions, my code breaks because of a change in the >> definition of some elements in this struct. For example, kernel > > Is this a problem? It's only an issue for code that lives outside of > the kernel, and there's nothing we can do about that, sorry. My main question is one about best practices. If using sysfs and keeping up with such changes is the best option available, I can live with that. However, if I've somehow missed a preferred alternative, then I would like to use it. > debugfs? This may be an option, but my understanding is that it makes even fewer promises about API stability. > What exactly are you using this data for? Who creates it? What does it > represent? The research project involves using Intel TXT (or the AMD SVM equivalent) as a form of context switch mechanism to execute the statically-linked binary code in isolation from the rest of the system. Thus, there's some amount of systems-level code (executes in ring 0) in the binary to preserve the state of the Linux kernel, but the majority of it performs some kind of application-specific (executes in ring 3) function (e.g., protects some SSL / SSH / VPN keys). Another way to think about it is as a provision for arbitrarily many virtual smart cards, e.g., from userspace this shouldn't look all that different from loading binary code into some kind of peripheral device with support for arbitrary execution. In case you're interested in the code or the research paper describing the approach in more detail: http://flickertcb.sourceforge.net/ http://www.ece.cmu.edu/~jmmccune/papers/mccune_parno_perrig_reiter_isozaki_eurosys08.pdf Many thanks for your time, -Jon ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sysfs binary attribute API flux 2012-03-23 13:25 ` Jonathan McCune @ 2012-03-23 16:20 ` Greg KH 2012-03-23 19:10 ` Jonathan McCune 0 siblings, 1 reply; 5+ messages in thread From: Greg KH @ 2012-03-23 16:20 UTC (permalink / raw) To: Jonathan McCune; +Cc: linux-kernel On Fri, Mar 23, 2012 at 09:25:54AM -0400, Jonathan McCune wrote: > On Thu, Mar 22, 2012 at 5:28 PM, Greg KH <greg@kroah.com> wrote: > >> necessary to move some binary data from userspace into the kernel. > > What exact type of binary data are you talking about here? > > There is a statically linked executable, which will also take a binary > blob as input, and produce another as output. You are passing the kernel an executable? I'm afraid to ask... > >> have been using sysfs's 'struct bin_attribute'. Unfortunately, every > >> few kernel versions, my code breaks because of a change in the > >> definition of some elements in this struct. For example, kernel > > > > Is this a problem? It's only an issue for code that lives outside of > > the kernel, and there's nothing we can do about that, sorry. > > My main question is one about best practices. If using sysfs and > keeping up with such changes is the best option available, I can live > with that. However, if I've somehow missed a preferred alternative, > then I would like to use it. No kernel api is stable, nor will it ever be, see Documentation/stable_api_nonsense.txt for details. As your code is living outside of the main kernel.org tree, you will have to deal with this for any number of different function calls you make, sysfs is not unique at all here. > > debugfs? > > This may be an option, but my understanding is that it makes even > fewer promises about API stability. You are thinking about the user/kernel api stability here, not the in-kernel api, right? Please don't confuse the two. > > What exactly are you using this data for? Who creates it? What does it > > represent? > > The research project involves using Intel TXT (or the AMD SVM > equivalent) as a form of context switch mechanism to execute the > statically-linked binary code in isolation from the rest of the > system. Thus, there's some amount of systems-level code (executes in > ring 0) in the binary to preserve the state of the Linux kernel, but > the majority of it performs some kind of application-specific > (executes in ring 3) function (e.g., protects some SSL / SSH / VPN > keys). Another way to think about it is as a provision for arbitrarily > many virtual smart cards, e.g., from userspace this shouldn't look all > that different from loading binary code into some kind of peripheral > device with support for arbitrary execution. In case you're interested > in the code or the research paper describing the approach in more > detail: > > http://flickertcb.sourceforge.net/ > > http://www.ece.cmu.edu/~jmmccune/papers/mccune_parno_perrig_reiter_isozaki_eurosys08.pdf Why not just create a new syscall for your work? That would be easier in the longrun, and really, that is what you are doing here. best of luck, greg k-h ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sysfs binary attribute API flux 2012-03-23 16:20 ` Greg KH @ 2012-03-23 19:10 ` Jonathan McCune 0 siblings, 0 replies; 5+ messages in thread From: Jonathan McCune @ 2012-03-23 19:10 UTC (permalink / raw) To: Greg KH; +Cc: linux-kernel On Fri, Mar 23, 2012 at 12:20 PM, Greg KH <greg@kroah.com> wrote: > No kernel api is stable, nor will it ever be, see > Documentation/stable_api_nonsense.txt for details. As your code is > living outside of the main kernel.org tree, you will have to deal with > this for any number of different function calls you make, sysfs is not > unique at all here. Thank you. I think this puts the issue to rest for me. > Why not just create a new syscall for your work? That would be easier > in the longrun, and really, that is what you are doing here. I may do just that. Thanks, -Jon ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-03-23 19:11 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-03-22 20:38 sysfs binary attribute API flux Jonathan McCune 2012-03-22 21:28 ` Greg KH 2012-03-23 13:25 ` Jonathan McCune 2012-03-23 16:20 ` Greg KH 2012-03-23 19:10 ` Jonathan McCune
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox