~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/security/keys/compat.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /security/keys/compat.c (Version linux-6.12-rc7) and /security/keys/compat.c (Version linux-5.4.285)


  1 // SPDX-License-Identifier: GPL-2.0-or-later        1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /* 32-bit compatibility syscall for 64-bit sys      2 /* 32-bit compatibility syscall for 64-bit systems
  3  *                                                  3  *
  4  * Copyright (C) 2004-5 Red Hat, Inc. All Righ      4  * Copyright (C) 2004-5 Red Hat, Inc. All Rights Reserved.
  5  * Written by David Howells (dhowells@redhat.c      5  * Written by David Howells (dhowells@redhat.com)
  6  */                                                 6  */
  7                                                     7 
  8 #include <linux/syscalls.h>                         8 #include <linux/syscalls.h>
  9 #include <linux/keyctl.h>                           9 #include <linux/keyctl.h>
 10 #include <linux/compat.h>                          10 #include <linux/compat.h>
 11 #include <linux/slab.h>                            11 #include <linux/slab.h>
 12 #include "internal.h"                              12 #include "internal.h"
 13                                                    13 
 14 /*                                                 14 /*
                                                   >>  15  * Instantiate a key with the specified compatibility multipart payload and
                                                   >>  16  * link the key into the destination keyring if one is given.
                                                   >>  17  *
                                                   >>  18  * The caller must have the appropriate instantiation permit set for this to
                                                   >>  19  * work (see keyctl_assume_authority).  No other permissions are required.
                                                   >>  20  *
                                                   >>  21  * If successful, 0 will be returned.
                                                   >>  22  */
                                                   >>  23 static long compat_keyctl_instantiate_key_iov(
                                                   >>  24         key_serial_t id,
                                                   >>  25         const struct compat_iovec __user *_payload_iov,
                                                   >>  26         unsigned ioc,
                                                   >>  27         key_serial_t ringid)
                                                   >>  28 {
                                                   >>  29         struct iovec iovstack[UIO_FASTIOV], *iov = iovstack;
                                                   >>  30         struct iov_iter from;
                                                   >>  31         long ret;
                                                   >>  32 
                                                   >>  33         if (!_payload_iov)
                                                   >>  34                 ioc = 0;
                                                   >>  35 
                                                   >>  36         ret = compat_import_iovec(WRITE, _payload_iov, ioc,
                                                   >>  37                                   ARRAY_SIZE(iovstack), &iov,
                                                   >>  38                                   &from);
                                                   >>  39         if (ret < 0)
                                                   >>  40                 return ret;
                                                   >>  41 
                                                   >>  42         ret = keyctl_instantiate_key_common(id, &from, ringid);
                                                   >>  43         kfree(iov);
                                                   >>  44         return ret;
                                                   >>  45 }
                                                   >>  46 
                                                   >>  47 /*
 15  * The key control system call, 32-bit compati     48  * The key control system call, 32-bit compatibility version for 64-bit archs
                                                   >>  49  *
                                                   >>  50  * This should only be called if the 64-bit arch uses weird pointers in 32-bit
                                                   >>  51  * mode or doesn't guarantee that the top 32-bits of the argument registers on
                                                   >>  52  * taking a 32-bit syscall are zero.  If you can, you should call sys_keyctl()
                                                   >>  53  * directly.
 16  */                                                54  */
 17 COMPAT_SYSCALL_DEFINE5(keyctl, u32, option,        55 COMPAT_SYSCALL_DEFINE5(keyctl, u32, option,
 18                        u32, arg2, u32, arg3, u     56                        u32, arg2, u32, arg3, u32, arg4, u32, arg5)
 19 {                                                  57 {
 20         switch (option) {                          58         switch (option) {
 21         case KEYCTL_GET_KEYRING_ID:                59         case KEYCTL_GET_KEYRING_ID:
 22                 return keyctl_get_keyring_ID(a     60                 return keyctl_get_keyring_ID(arg2, arg3);
 23                                                    61 
 24         case KEYCTL_JOIN_SESSION_KEYRING:          62         case KEYCTL_JOIN_SESSION_KEYRING:
 25                 return keyctl_join_session_key     63                 return keyctl_join_session_keyring(compat_ptr(arg2));
 26                                                    64 
 27         case KEYCTL_UPDATE:                        65         case KEYCTL_UPDATE:
 28                 return keyctl_update_key(arg2,     66                 return keyctl_update_key(arg2, compat_ptr(arg3), arg4);
 29                                                    67 
 30         case KEYCTL_REVOKE:                        68         case KEYCTL_REVOKE:
 31                 return keyctl_revoke_key(arg2)     69                 return keyctl_revoke_key(arg2);
 32                                                    70 
 33         case KEYCTL_DESCRIBE:                      71         case KEYCTL_DESCRIBE:
 34                 return keyctl_describe_key(arg     72                 return keyctl_describe_key(arg2, compat_ptr(arg3), arg4);
 35                                                    73 
 36         case KEYCTL_CLEAR:                         74         case KEYCTL_CLEAR:
 37                 return keyctl_keyring_clear(ar     75                 return keyctl_keyring_clear(arg2);
 38                                                    76 
 39         case KEYCTL_LINK:                          77         case KEYCTL_LINK:
 40                 return keyctl_keyring_link(arg     78                 return keyctl_keyring_link(arg2, arg3);
 41                                                    79 
 42         case KEYCTL_UNLINK:                        80         case KEYCTL_UNLINK:
 43                 return keyctl_keyring_unlink(a     81                 return keyctl_keyring_unlink(arg2, arg3);
 44                                                    82 
 45         case KEYCTL_SEARCH:                        83         case KEYCTL_SEARCH:
 46                 return keyctl_keyring_search(a     84                 return keyctl_keyring_search(arg2, compat_ptr(arg3),
 47                                              c     85                                              compat_ptr(arg4), arg5);
 48                                                    86 
 49         case KEYCTL_READ:                          87         case KEYCTL_READ:
 50                 return keyctl_read_key(arg2, c     88                 return keyctl_read_key(arg2, compat_ptr(arg3), arg4);
 51                                                    89 
 52         case KEYCTL_CHOWN:                         90         case KEYCTL_CHOWN:
 53                 return keyctl_chown_key(arg2,      91                 return keyctl_chown_key(arg2, arg3, arg4);
 54                                                    92 
 55         case KEYCTL_SETPERM:                       93         case KEYCTL_SETPERM:
 56                 return keyctl_setperm_key(arg2     94                 return keyctl_setperm_key(arg2, arg3);
 57                                                    95 
 58         case KEYCTL_INSTANTIATE:                   96         case KEYCTL_INSTANTIATE:
 59                 return keyctl_instantiate_key(     97                 return keyctl_instantiate_key(arg2, compat_ptr(arg3), arg4,
 60                                                    98                                               arg5);
 61                                                    99 
 62         case KEYCTL_NEGATE:                       100         case KEYCTL_NEGATE:
 63                 return keyctl_negate_key(arg2,    101                 return keyctl_negate_key(arg2, arg3, arg4);
 64                                                   102 
 65         case KEYCTL_SET_REQKEY_KEYRING:           103         case KEYCTL_SET_REQKEY_KEYRING:
 66                 return keyctl_set_reqkey_keyri    104                 return keyctl_set_reqkey_keyring(arg2);
 67                                                   105 
 68         case KEYCTL_SET_TIMEOUT:                  106         case KEYCTL_SET_TIMEOUT:
 69                 return keyctl_set_timeout(arg2    107                 return keyctl_set_timeout(arg2, arg3);
 70                                                   108 
 71         case KEYCTL_ASSUME_AUTHORITY:             109         case KEYCTL_ASSUME_AUTHORITY:
 72                 return keyctl_assume_authority    110                 return keyctl_assume_authority(arg2);
 73                                                   111 
 74         case KEYCTL_GET_SECURITY:                 112         case KEYCTL_GET_SECURITY:
 75                 return keyctl_get_security(arg    113                 return keyctl_get_security(arg2, compat_ptr(arg3), arg4);
 76                                                   114 
 77         case KEYCTL_SESSION_TO_PARENT:            115         case KEYCTL_SESSION_TO_PARENT:
 78                 return keyctl_session_to_paren    116                 return keyctl_session_to_parent();
 79                                                   117 
 80         case KEYCTL_REJECT:                       118         case KEYCTL_REJECT:
 81                 return keyctl_reject_key(arg2,    119                 return keyctl_reject_key(arg2, arg3, arg4, arg5);
 82                                                   120 
 83         case KEYCTL_INSTANTIATE_IOV:              121         case KEYCTL_INSTANTIATE_IOV:
 84                 return keyctl_instantiate_key_ !! 122                 return compat_keyctl_instantiate_key_iov(
 85                                                !! 123                         arg2, compat_ptr(arg3), arg4, arg5);
 86                                                   124 
 87         case KEYCTL_INVALIDATE:                   125         case KEYCTL_INVALIDATE:
 88                 return keyctl_invalidate_key(a    126                 return keyctl_invalidate_key(arg2);
 89                                                   127 
 90         case KEYCTL_GET_PERSISTENT:               128         case KEYCTL_GET_PERSISTENT:
 91                 return keyctl_get_persistent(a    129                 return keyctl_get_persistent(arg2, arg3);
 92                                                   130 
 93         case KEYCTL_DH_COMPUTE:                   131         case KEYCTL_DH_COMPUTE:
 94                 return compat_keyctl_dh_comput    132                 return compat_keyctl_dh_compute(compat_ptr(arg2),
 95                                                   133                                                 compat_ptr(arg3),
 96                                                   134                                                 arg4, compat_ptr(arg5));
 97                                                   135 
 98         case KEYCTL_RESTRICT_KEYRING:             136         case KEYCTL_RESTRICT_KEYRING:
 99                 return keyctl_restrict_keyring    137                 return keyctl_restrict_keyring(arg2, compat_ptr(arg3),
100                                                   138                                                compat_ptr(arg4));
101                                                   139 
102         case KEYCTL_PKEY_QUERY:                   140         case KEYCTL_PKEY_QUERY:
103                 if (arg3 != 0)                    141                 if (arg3 != 0)
104                         return -EINVAL;           142                         return -EINVAL;
105                 return keyctl_pkey_query(arg2,    143                 return keyctl_pkey_query(arg2,
106                                          compa    144                                          compat_ptr(arg4),
107                                          compa    145                                          compat_ptr(arg5));
108                                                   146 
109         case KEYCTL_PKEY_ENCRYPT:                 147         case KEYCTL_PKEY_ENCRYPT:
110         case KEYCTL_PKEY_DECRYPT:                 148         case KEYCTL_PKEY_DECRYPT:
111         case KEYCTL_PKEY_SIGN:                    149         case KEYCTL_PKEY_SIGN:
112                 return keyctl_pkey_e_d_s(optio    150                 return keyctl_pkey_e_d_s(option,
113                                          compa    151                                          compat_ptr(arg2), compat_ptr(arg3),
114                                          compa    152                                          compat_ptr(arg4), compat_ptr(arg5));
115                                                   153 
116         case KEYCTL_PKEY_VERIFY:                  154         case KEYCTL_PKEY_VERIFY:
117                 return keyctl_pkey_verify(comp    155                 return keyctl_pkey_verify(compat_ptr(arg2), compat_ptr(arg3),
118                                           comp    156                                           compat_ptr(arg4), compat_ptr(arg5));
119                                                   157 
120         case KEYCTL_MOVE:                         158         case KEYCTL_MOVE:
121                 return keyctl_keyring_move(arg    159                 return keyctl_keyring_move(arg2, arg3, arg4, arg5);
122                                                   160 
123         case KEYCTL_CAPABILITIES:                 161         case KEYCTL_CAPABILITIES:
124                 return keyctl_capabilities(com    162                 return keyctl_capabilities(compat_ptr(arg2), arg3);
125                                                << 
126         case KEYCTL_WATCH_KEY:                 << 
127                 return keyctl_watch_key(arg2,  << 
128                                                   163 
129         default:                                  164         default:
130                 return -EOPNOTSUPP;               165                 return -EOPNOTSUPP;
131         }                                         166         }
132 }                                                 167 }
133                                                   168 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php