<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 3, 2017 at 10:59 PM, Pradeepa Kumar <span dir="ltr"><<a target="_blank" href="mailto:cdpradeepa@gmail.com">cdpradeepa@gmail.com</a>></span> wrote:<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><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 <--> my kernel module <--> 64 bit app</div><div>my kernel module implements new protocol and </div><div>provides 'struct proto_ops'</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></blockquote><div><br></div><div>Don't top post. <br><div>I suggest sending mail to netdev kernel mailing list<br></div><div>with all the relevant information as I doubt if networking<br></div>layer in kernel doesn't handle 32/64 bit properly. </div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div dir="ltr"><div><br></div><div><br></div></div><div class="gmail-HOEnZb"><div class="gmail-h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 4, 2017 at 12:18 PM, Anish Kumar <span dir="ltr"><<a target="_blank" href="mailto:anish198519851985@gmail.com">anish198519851985@gmail.com</a>></span> wrote:<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div dir="auto"><span><div></div><div><br></div><div><br>On Jan 3, 2017, at 10:03 PM, Pradeepa Kumar <<a target="_blank" href="mailto:cdpradeepa@gmail.com">cdpradeepa@gmail.com</a>> 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"><<a target="_blank" href="mailto:anish198519851985@gmail.com">anish198519851985@gmail.com</a>></span> wrote:<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div dir="auto"><span class="gmail-m_-748738888465932825m_-1113997045255833954gmail-"><div></div><div><br></div><div><br>On Jan 3, 2017, at 8:04 PM, Pradeepa Kumar <<a target="_blank" href="mailto:cdpradeepa@gmail.com">cdpradeepa@gmail.com</a>> 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-width:0px;border-style:none;border-color:-moz-use-text-color;font-size:13px;border-collapse:collapse;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif"><tbody style="margin:0px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color"><tr style="margin:0px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color"><td style="padding:0px 15px 0px 0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;vertical-align:top" class="gmail-m_-748738888465932825m_-1113997045255833954gmail-m_-7449249445306101190gmail-votecell"><div style="margin:0px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;text-align:center;min-width:46px" class="gmail-m_-748738888465932825m_-1113997045255833954gmail-m_-7449249445306101190gmail-vote"><a style="margin:0px auto 10px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;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" title="This question does not show any research effort; it is unclear or not useful" class="gmail-m_-748738888465932825m_-1113997045255833954gmail-m_-7449249445306101190gmail-vote-down-off">down vote</a><a target="_blank" style="margin:0px auto 2px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;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" title="Click to mark as favorite question (click again to undo)" href="http://stackoverflow.com/questions/41455943/adding-32-bit-compatibility-layer-in-custom-kernel-module#" class="gmail-m_-748738888465932825m_-1113997045255833954gmail-m_-7449249445306101190gmail-star-off">favorite</a><div style="margin:0px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color" class="gmail-m_-748738888465932825m_-1113997045255833954gmail-m_-7449249445306101190gmail-favoritecount"><span style="margin:0px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;color:rgb(106,115,124)"></span></div></div></td><td style="padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;vertical-align:top" class="gmail-m_-748738888465932825m_-1113997045255833954gmail-m_-7449249445306101190gmail-postcell"><div style="margin:0px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color"><div style="margin:0px 0px 5px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;font-size:15px;width:660px;word-wrap:break-word;line-height:1.3" class="gmail-m_-748738888465932825m_-1113997045255833954gmail-m_-7449249445306101190gmail-post-text"><span class="gmail-m_-748738888465932825m_-1113997045255833954gmail-"><p style="margin:0px 0px 1em;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;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-width:0px;border-style:none;border-color:-moz-use-text-color;clear:both">it works fine when 64 bit app runs.</p><p style="margin:0px 0px 1em;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;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-width:0px;border-style:none;border-color:-moz-use-text-color;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-width:0px;border-style:none;border-color:-moz-use-text-color"><li style="margin:0px 0px 0.5em;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;word-wrap:break-word"><span class="gmail-m_-748738888465932825m_-1113997045255833954gmail-"><p style="margin:0px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;clear:both">is it simple to add compatibility layer to my custom kernel module</p><p style="margin:0px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;clear:both"><br></p></span><p style="margin:0px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;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 'compat_recvmsg' 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><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>had there been 'compat_recvmsg' 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 style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div dir="auto"><blockquote type="cite"><div><div dir="ltr"><div><table style="margin:0px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;font-size:13px;border-collapse:collapse;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif"><tbody style="margin:0px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color"><tr style="margin:0px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color"><td style="padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;vertical-align:top" class="gmail-m_-748738888465932825m_-1113997045255833954gmail-m_-7449249445306101190gmail-postcell"><div style="margin:0px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color"><div style="margin:0px 0px 5px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;font-size:15px;width:660px;word-wrap:break-word;line-height:1.3" class="gmail-m_-748738888465932825m_-1113997045255833954gmail-m_-7449249445306101190gmail-post-text"><ul style="margin:0px 0px 1em 30px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color"><li style="margin:0px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;word-wrap:break-word"><span class="gmail-m_-748738888465932825m_-1113997045255833954gmail-"><p style="margin:0px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;clear:both">how do i do this (any links ?)</p><p style="margin:0px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;clear:both"><br></p></span><p style="margin:0px;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;clear:both">You can see many drivers supports compat call.</p></li></ul><p style="margin:0px 0px 1em;padding:0px;border-width:0px;border-style:none;border-color:-moz-use-text-color;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 target="_blank" href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.or<wbr>g</a></span><br><span><a target="_blank" href="https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies">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>
</div></div></blockquote></div><br></div></div>