pvtcp_off_linux_shim.S 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Linux 2.6.32 and later Kernel module for VMware MVP PVTCP Server
  3. *
  4. * Copyright (C) 2010-2013 VMware, Inc. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published by
  8. * the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along with
  16. * this program; see the file COPYING. If not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. #line 5
  20. /**
  21. * @file
  22. *
  23. * @brief PVTCP socket destructor shim.
  24. *
  25. * The module reference accounting code for socket destruction in the core
  26. * Linux kernel does not know about PVTCP sockets, so it does not properly
  27. * increment/decrement the reference count on pvtcpkm when calling through a
  28. * function pointer into our destructor. If a module unload is requested on
  29. * pvtcpkm while a socket is being destroyed, it is possible for the destructor
  30. * to be preempted after decrementing the module reference count but before
  31. * returning to the core kernel. If the module code is unmapped before the
  32. * function return, it is possible that we will attempt to execute unmapped
  33. * code, resulting in a host crash.
  34. *
  35. * This shim proxies socket destruction requests through to the PVTCP socket
  36. * destructor, then jumps directly to module_put to drop the reference count.
  37. * module_put will return directly to the caller, eliminating the race.
  38. */
  39. .text
  40. .p2align 4
  41. .global asmDestructorShim
  42. /**
  43. * @brief Socket destructor callback. Calls into pvtcpkm to destroy a socket
  44. * and then decrements the refcount.
  45. * @param r0 pointer to struct sock
  46. */
  47. asmDestructorShim:
  48. push {lr}
  49. ldr r1, targetAddr @ Destroy socket
  50. blx r1
  51. pop {lr}
  52. cmp r0, #0
  53. bxne lr @ We shouldn't module_put, just return.
  54. ldr r0, owner
  55. ldr r1, modulePutAddr @ Jump to module_put. module_put
  56. bx r1 @ returns directly to caller
  57. owner:
  58. .word __this_module
  59. targetAddr:
  60. .word DestructCB
  61. modulePutAddr:
  62. .word module_put