compat.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* compat.c: 32-bit compatibility syscall for 64-bit systems
  2. *
  3. * Copyright (C) 2004-5 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <linux/sched.h>
  12. #include <linux/syscalls.h>
  13. #include <linux/keyctl.h>
  14. #include <linux/compat.h>
  15. #include "internal.h"
  16. /*****************************************************************************/
  17. /*
  18. * the key control system call, 32-bit compatibility version for 64-bit archs
  19. * - this should only be called if the 64-bit arch uses weird pointers in
  20. * 32-bit mode or doesn't guarantee that the top 32-bits of the argument
  21. * registers on taking a 32-bit syscall are zero
  22. * - if you can, you should call sys_keyctl directly
  23. */
  24. asmlinkage long compat_sys_keyctl(u32 option,
  25. u32 arg2, u32 arg3, u32 arg4, u32 arg5)
  26. {
  27. switch (option) {
  28. case KEYCTL_GET_KEYRING_ID:
  29. return keyctl_get_keyring_ID(arg2, arg3);
  30. case KEYCTL_JOIN_SESSION_KEYRING:
  31. return keyctl_join_session_keyring(compat_ptr(arg2));
  32. case KEYCTL_UPDATE:
  33. return keyctl_update_key(arg2, compat_ptr(arg3), arg4);
  34. case KEYCTL_REVOKE:
  35. return keyctl_revoke_key(arg2);
  36. case KEYCTL_DESCRIBE:
  37. return keyctl_describe_key(arg2, compat_ptr(arg3), arg4);
  38. case KEYCTL_CLEAR:
  39. return keyctl_keyring_clear(arg2);
  40. case KEYCTL_LINK:
  41. return keyctl_keyring_link(arg2, arg3);
  42. case KEYCTL_UNLINK:
  43. return keyctl_keyring_unlink(arg2, arg3);
  44. case KEYCTL_SEARCH:
  45. return keyctl_keyring_search(arg2, compat_ptr(arg3),
  46. compat_ptr(arg4), arg5);
  47. case KEYCTL_READ:
  48. return keyctl_read_key(arg2, compat_ptr(arg3), arg4);
  49. case KEYCTL_CHOWN:
  50. return keyctl_chown_key(arg2, arg3, arg4);
  51. case KEYCTL_SETPERM:
  52. return keyctl_setperm_key(arg2, arg3);
  53. case KEYCTL_INSTANTIATE:
  54. return keyctl_instantiate_key(arg2, compat_ptr(arg3), arg4,
  55. arg5);
  56. case KEYCTL_NEGATE:
  57. return keyctl_negate_key(arg2, arg3, arg4);
  58. case KEYCTL_SET_REQKEY_KEYRING:
  59. return keyctl_set_reqkey_keyring(arg2);
  60. case KEYCTL_SET_TIMEOUT:
  61. return keyctl_set_timeout(arg2, arg3);
  62. case KEYCTL_ASSUME_AUTHORITY:
  63. return keyctl_assume_authority(arg2);
  64. default:
  65. return -EOPNOTSUPP;
  66. }
  67. } /* end compat_sys_keyctl() */