<div dir="ltr">my app is crashing as it is trying iterate cmsghdrs<div>it got after call to recvmsg();<div>To give some context</div></div><div>below is the flow</div><div><br></div><div>32 bit app  &lt;--&gt; my kernel module &lt;--&gt; 64 bit app</div><div>my kernel module implements new protocol and </div><div>provides &#39;struct proto_ops&#39;</div><div>it never calls __sys_socket* calls.</div><div>once 32 bit app calls recvmsg(),</div><div>kernel module gets required data from another 64 bit app</div><div>via netlink msg.</div><div>issue here is the struct msghdr and strcu cmsgdr sizes</div><div>and members are of different lenghts.</div><div>so kernel module needs to give data to 32 bit app</div><div>in proper struct which are of correct sizes in 32 bit mode.</div><div>so kernel module needs a way to figure out</div><div>it is 32 bit app that made recvmsg() call and process accordingly.</div><div>i dont see compat_recv in struct proto_ops</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 4, 2017 at 12:18 PM, Anish Kumar <span dir="ltr">&lt;<a href="mailto:anish198519851985@gmail.com" target="_blank">anish198519851985@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><span class=""><div></div><div><br></div><div><br>On Jan 3, 2017, at 10:03 PM, Pradeepa Kumar &lt;<a href="mailto:cdpradeepa@gmail.com" target="_blank">cdpradeepa@gmail.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra">Please see inline below</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 4, 2017 at 11:07 AM, Anish Kumar <span dir="ltr">&lt;<a href="mailto:anish198519851985@gmail.com" target="_blank">anish198519851985@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><span class="m_-1113997045255833954gmail-"><div></div><div><br></div><div><br>On Jan 3, 2017, at 8:04 PM, Pradeepa Kumar &lt;<a href="mailto:cdpradeepa@gmail.com" target="_blank">cdpradeepa@gmail.com</a>&gt; wrote:<br><br></div></span><blockquote type="cite"><div><div dir="ltr">Hi experts<div><br></div><div><table style="margin:0px;padding:0px;border:0px;font-size:13px;border-collapse:collapse;color:rgb(36,39,41);font-family:arial,&quot;helvetica neue&quot;,helvetica,sans-serif"><tbody style="margin:0px;padding:0px;border:0px"><tr style="margin:0px;padding:0px;border:0px"><td class="m_-1113997045255833954gmail-m_-7449249445306101190gmail-votecell" style="padding:0px 15px 0px 0px;border:0px;vertical-align:top"><div class="m_-1113997045255833954gmail-m_-7449249445306101190gmail-vote" style="margin:0px;padding:0px;border:0px;text-align:center;min-width:46px"><a class="m_-1113997045255833954gmail-m_-7449249445306101190gmail-vote-down-off" title="This question does not show any research effort; it is unclear or not useful" style="margin:0px auto 10px;padding:0px;border:0px;font-size:1px;color:rgb(0,119,204);background-size:initial;background-repeat:no-repeat;overflow:hidden;display:block;width:40px;height:30px;background-position:0px -220px">down vote</a><a class="m_-1113997045255833954gmail-m_-7449249445306101190gmail-star-off" href="http://stackoverflow.com/questions/41455943/adding-32-bit-compatibility-layer-in-custom-kernel-module#" title="Click to mark as favorite question (click again to undo)" style="margin:0px auto 2px;padding:0px;border:0px;font-size:1px;color:rgb(0,119,204);text-decoration:none;background-size:initial;background-repeat:no-repeat;overflow:hidden;display:block;width:40px;height:30px;background-position:0px -120px" target="_blank">favorite</a><div class="m_-1113997045255833954gmail-m_-7449249445306101190gmail-favoritecount" style="margin:0px;padding:0px;border:0px"><span style="margin:0px;padding:0px;border:0px;color:rgb(106,115,124)"></span></div></div></td><td class="m_-1113997045255833954gmail-m_-7449249445306101190gmail-postcell" style="padding:0px;border:0px;vertical-align:top"><div style="margin:0px;padding:0px;border:0px"><div class="m_-1113997045255833954gmail-m_-7449249445306101190gmail-post-text" style="margin:0px 0px 5px;padding:0px;border:0px;font-size:15px;width:660px;word-wrap:break-word;line-height:1.3"><span class="m_-1113997045255833954gmail-"><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both">in my 64 bit kernel, I have a custom kernel module providing new protocol and providing socket system calls.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both">it works fine when 64 bit app runs.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both">i am seeing issues when 32 bit app runs (for exp recvmsg() call does not work if msg has cmsghdrs as struct size of cmsghdr is different in 32 bit and 64 bit).</p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both">This is because my custom kernel module does not have 32 bit compatibility layer ( but linux kernel has this in compat.c etc).</p></span><ul style="margin:0px 0px 1em 30px;padding:0px;border:0px"><li style="margin:0px 0px 0.5em;padding:0px;border:0px;word-wrap:break-word"><span class="m_-1113997045255833954gmail-"><p style="margin:0px;padding:0px;border:0px;clear:both">is it simple to add compatibility layer to my custom kernel module</p><p style="margin:0px;padding:0px;border:0px;clear:both"><br></p></span><p style="margin:0px;padding:0px;border:0px;clear:both">All you have to do is add compat_ioctl call to your driver.</p></li></ul></div></div></td></tr></tbody></table></div></div></div></blockquote></div></blockquote><div>my kernel module provides recvmsg() but i dont see any &#39;compat_recvmsg&#39; in struct proto_ops.</div></div></div></div></div></blockquote><div><br></div></span>Try to wrap your text in 80 characters.<div><br></div><div>Your application is crashing? Right?</div><div>Have you figured where it is crashing exactly?</div><div><br></div><div>I understood that your application is crashing as </div><div>It not able to function with 64 bit kernel.</div><div><br></div><div>This happens because of the data being passed</div><div>to kernel is not in the right format. You need to</div><div>look at what you are passing to the driver and</div><div>if needed write the compat_ioctl callback in your</div><div>driver fops.<span class=""><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>had there been  &#39;compat_recvmsg&#39; it would have been possible for me to define recvmsg() for 32 bit apps.<br></div><div>please let me know if i am missing anything</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><blockquote type="cite"><div><div dir="ltr"><div><table style="margin:0px;padding:0px;border:0px;font-size:13px;border-collapse:collapse;color:rgb(36,39,41);font-family:arial,&quot;helvetica neue&quot;,helvetica,sans-serif"><tbody style="margin:0px;padding:0px;border:0px"><tr style="margin:0px;padding:0px;border:0px"><td class="m_-1113997045255833954gmail-m_-7449249445306101190gmail-postcell" style="padding:0px;border:0px;vertical-align:top"><div style="margin:0px;padding:0px;border:0px"><div class="m_-1113997045255833954gmail-m_-7449249445306101190gmail-post-text" style="margin:0px 0px 5px;padding:0px;border:0px;font-size:15px;width:660px;word-wrap:break-word;line-height:1.3"><ul style="margin:0px 0px 1em 30px;padding:0px;border:0px"><li style="margin:0px;padding:0px;border:0px;word-wrap:break-word"><span class="m_-1113997045255833954gmail-"><p style="margin:0px;padding:0px;border:0px;clear:both">how do i do this (any links ?)</p><p style="margin:0px;padding:0px;border:0px;clear:both"><br></p></span><p style="margin:0px;padding:0px;border:0px;clear:both">You can see many drivers supports compat call.</p></li></ul><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both">Thanks</p></div></div></td></tr></tbody></table></div></div>
</div></blockquote><blockquote type="cite"><div><span>______________________________<wbr>_________________</span><br><span>Kernelnewbies mailing list</span><br><span><a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.or<wbr>g</a></span><br><span><a href="https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">https://lists.kernelnewbies.or<wbr>g/mailman/listinfo/kernelnewbi<wbr>es</a></span><br></div></blockquote></div></blockquote></div><br></div></div>
</div></blockquote></span></div></div></blockquote></div><br></div>