Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

KEYS: Do some style cleanup in the key management code.

Do a bit of a style clean up in the key management code. No functional
changes.

Done using:

perl -p -i -e 's!^/[*]*/\n!!' security/keys/*.c
perl -p -i -e 's!} /[*] end [a-z0-9_]*[(][)] [*]/\n!}\n!' security/keys/*.c
sed -i -s -e ": next" -e N -e 's/^\n[}]$/}/' -e t -e P -e 's/^.*\n//' -e "b next" security/keys/*.c

To remove /*****/ lines, remove comments on the closing brace of a
function to name the function and remove blank lines before the closing
brace of a function.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

David Howells and committed by
Linus Torvalds
a8b17ed0 9093ba53

+80 -248
+1 -3
security/keys/compat.c
··· 14 14 #include <linux/compat.h> 15 15 #include "internal.h" 16 16 17 - /*****************************************************************************/ 18 17 /* 19 18 * the key control system call, 32-bit compatibility version for 64-bit archs 20 19 * - this should only be called if the 64-bit arch uses weird pointers in ··· 87 88 default: 88 89 return -EOPNOTSUPP; 89 90 } 90 - 91 - } /* end compat_sys_keyctl() */ 91 + }
-1
security/keys/encrypted_defined.c
··· 888 888 out: 889 889 encrypted_shash_release(); 890 890 return ret; 891 - 892 891 } 893 892 894 893 static void __exit cleanup_encrypted(void)
+20 -60
security/keys/key.c
··· 56 56 } 57 57 #endif 58 58 59 - /*****************************************************************************/ 60 59 /* 61 60 * get the key quota record for a user, allocating a new record if one doesn't 62 61 * already exist ··· 129 130 kfree(candidate); 130 131 out: 131 132 return user; 133 + } 132 134 133 - } /* end key_user_lookup() */ 134 - 135 - /*****************************************************************************/ 136 135 /* 137 136 * dispose of a user structure 138 137 */ ··· 143 146 144 147 kfree(user); 145 148 } 149 + } 146 150 147 - } /* end key_user_put() */ 148 - 149 - /*****************************************************************************/ 150 151 /* 151 152 * assign a key the next unique serial number 152 153 * - these are assigned randomly to avoid security issues through covert ··· 206 211 if (key->serial < xkey->serial) 207 212 goto attempt_insertion; 208 213 } 214 + } 209 215 210 - } /* end key_alloc_serial() */ 211 - 212 - /*****************************************************************************/ 213 216 /* 214 217 * allocate a key of the specified type 215 218 * - update the user's quota to reflect the existence of the key ··· 337 344 key_user_put(user); 338 345 key = ERR_PTR(-EDQUOT); 339 346 goto error; 340 - 341 - } /* end key_alloc() */ 347 + } 342 348 343 349 EXPORT_SYMBOL(key_alloc); 344 350 345 - /*****************************************************************************/ 346 351 /* 347 352 * reserve an amount of quota for the key's payload 348 353 */ ··· 375 384 key->datalen = datalen; 376 385 377 386 return ret; 378 - 379 - } /* end key_payload_reserve() */ 387 + } 380 388 381 389 EXPORT_SYMBOL(key_payload_reserve); 382 390 383 - /*****************************************************************************/ 384 391 /* 385 392 * instantiate a key and link it into the target keyring atomically 386 393 * - called with the target keyring's semaphore writelocked ··· 430 441 wake_up_bit(&key->flags, KEY_FLAG_USER_CONSTRUCT); 431 442 432 443 return ret; 444 + } 433 445 434 - } /* end __key_instantiate_and_link() */ 435 - 436 - /*****************************************************************************/ 437 446 /* 438 447 * instantiate a key and link it into the target keyring atomically 439 448 */ ··· 458 471 __key_link_end(keyring, key->type, prealloc); 459 472 460 473 return ret; 461 - 462 - } /* end key_instantiate_and_link() */ 474 + } 463 475 464 476 EXPORT_SYMBOL(key_instantiate_and_link); 465 477 466 - /*****************************************************************************/ 467 478 /* 468 479 * negatively instantiate a key and link it into the target keyring atomically 469 480 */ ··· 520 535 wake_up_bit(&key->flags, KEY_FLAG_USER_CONSTRUCT); 521 536 522 537 return ret == 0 ? link_ret : ret; 523 - 524 - } /* end key_negate_and_link() */ 538 + } 525 539 526 540 EXPORT_SYMBOL(key_negate_and_link); 527 541 528 - /*****************************************************************************/ 529 542 /* 530 543 * do cleaning up in process context so that we don't have to disable 531 544 * interrupts all over the place ··· 584 601 585 602 /* there may, of course, be more than one key to destroy */ 586 603 goto go_again; 604 + } 587 605 588 - } /* end key_cleanup() */ 589 - 590 - /*****************************************************************************/ 591 606 /* 592 607 * dispose of a reference to a key 593 608 * - when all the references are gone, we schedule the cleanup task to come and ··· 599 618 if (atomic_dec_and_test(&key->usage)) 600 619 schedule_work(&key_cleanup_task); 601 620 } 602 - 603 - } /* end key_put() */ 621 + } 604 622 605 623 EXPORT_SYMBOL(key_put); 606 624 607 - /*****************************************************************************/ 608 625 /* 609 626 * find a key by its serial number 610 627 */ ··· 643 664 error: 644 665 spin_unlock(&key_serial_lock); 645 666 return key; 667 + } 646 668 647 - } /* end key_lookup() */ 648 - 649 - /*****************************************************************************/ 650 669 /* 651 670 * find and lock the specified key type against removal 652 671 * - we return with the sem readlocked ··· 667 690 668 691 found_kernel_type: 669 692 return ktype; 693 + } 670 694 671 - } /* end key_type_lookup() */ 672 - 673 - /*****************************************************************************/ 674 695 /* 675 696 * unlock a key type 676 697 */ 677 698 void key_type_put(struct key_type *ktype) 678 699 { 679 700 up_read(&key_types_sem); 701 + } 680 702 681 - } /* end key_type_put() */ 682 - 683 - /*****************************************************************************/ 684 703 /* 685 704 * attempt to update an existing key 686 705 * - the key has an incremented refcount ··· 715 742 key_put(key); 716 743 key_ref = ERR_PTR(ret); 717 744 goto out; 745 + } 718 746 719 - } /* end __key_update() */ 720 - 721 - /*****************************************************************************/ 722 747 /* 723 748 * search the specified keyring for a key of the same description; if one is 724 749 * found, update it, otherwise add a new one ··· 826 855 827 856 key_ref = __key_update(key_ref, payload, plen); 828 857 goto error; 829 - 830 - } /* end key_create_or_update() */ 858 + } 831 859 832 860 EXPORT_SYMBOL(key_create_or_update); 833 861 834 - /*****************************************************************************/ 835 862 /* 836 863 * update a key 837 864 */ ··· 860 891 861 892 error: 862 893 return ret; 863 - 864 - } /* end key_update() */ 894 + } 865 895 866 896 EXPORT_SYMBOL(key_update); 867 897 868 - /*****************************************************************************/ 869 898 /* 870 899 * revoke a key 871 900 */ ··· 893 926 } 894 927 895 928 up_write(&key->sem); 896 - 897 - } /* end key_revoke() */ 929 + } 898 930 899 931 EXPORT_SYMBOL(key_revoke); 900 932 901 - /*****************************************************************************/ 902 933 /* 903 934 * register a type of key 904 935 */ ··· 921 956 out: 922 957 up_write(&key_types_sem); 923 958 return ret; 924 - 925 - } /* end register_key_type() */ 959 + } 926 960 927 961 EXPORT_SYMBOL(register_key_type); 928 962 929 - /*****************************************************************************/ 930 963 /* 931 964 * unregister a type of key 932 965 */ ··· 973 1010 up_write(&key_types_sem); 974 1011 975 1012 key_schedule_gc(0); 976 - 977 - } /* end unregister_key_type() */ 1013 + } 978 1014 979 1015 EXPORT_SYMBOL(unregister_key_type); 980 1016 981 - /*****************************************************************************/ 982 1017 /* 983 1018 * initialise the key management stuff 984 1019 */ ··· 998 1037 999 1038 rb_insert_color(&root_key_user.node, 1000 1039 &key_user_tree); 1001 - 1002 - } /* end key_init() */ 1040 + }
+19 -58
security/keys/keyctl.c
··· 46 46 return 0; 47 47 } 48 48 49 - /*****************************************************************************/ 50 49 /* 51 50 * extract the description of a new key from userspace and either add it as a 52 51 * new key to the specified keyring or update a matching key in that keyring ··· 131 132 kfree(description); 132 133 error: 133 134 return ret; 135 + } 134 136 135 - } /* end sys_add_key() */ 136 - 137 - /*****************************************************************************/ 138 137 /* 139 138 * search the process keyrings for a matching key 140 139 * - nested keyrings may also be searched if they have Search permission ··· 219 222 kfree(description); 220 223 error: 221 224 return ret; 225 + } 222 226 223 - } /* end sys_request_key() */ 224 - 225 - /*****************************************************************************/ 226 227 /* 227 228 * get the ID of the specified process keyring 228 229 * - the keyring must have search permission to be found ··· 246 251 247 252 } /* end keyctl_get_keyring_ID() */ 248 253 249 - /*****************************************************************************/ 250 254 /* 251 255 * join the session keyring 252 256 * - implements keyctl(KEYCTL_JOIN_SESSION_KEYRING) ··· 271 277 272 278 error: 273 279 return ret; 280 + } 274 281 275 - } /* end keyctl_join_session_keyring() */ 276 - 277 - /*****************************************************************************/ 278 282 /* 279 283 * update a key's data payload 280 284 * - the key must be writable ··· 318 326 kfree(payload); 319 327 error: 320 328 return ret; 329 + } 321 330 322 - } /* end keyctl_update_key() */ 323 - 324 - /*****************************************************************************/ 325 331 /* 326 332 * revoke a key 327 333 * - the key must be writable ··· 348 358 key_ref_put(key_ref); 349 359 error: 350 360 return ret; 361 + } 351 362 352 - } /* end keyctl_revoke_key() */ 353 - 354 - /*****************************************************************************/ 355 363 /* 356 364 * clear the specified process keyring 357 365 * - the keyring must be writable ··· 371 383 key_ref_put(keyring_ref); 372 384 error: 373 385 return ret; 386 + } 374 387 375 - } /* end keyctl_keyring_clear() */ 376 - 377 - /*****************************************************************************/ 378 388 /* 379 389 * link a key into a keyring 380 390 * - the keyring must be writable ··· 403 417 key_ref_put(keyring_ref); 404 418 error: 405 419 return ret; 420 + } 406 421 407 - } /* end keyctl_keyring_link() */ 408 - 409 - /*****************************************************************************/ 410 422 /* 411 423 * unlink the first attachment of a key from a keyring 412 424 * - the keyring must be writable ··· 435 451 key_ref_put(keyring_ref); 436 452 error: 437 453 return ret; 454 + } 438 455 439 - } /* end keyctl_keyring_unlink() */ 440 - 441 - /*****************************************************************************/ 442 456 /* 443 457 * describe a user key 444 458 * - the key must have view permission ··· 513 531 key_ref_put(key_ref); 514 532 error: 515 533 return ret; 534 + } 516 535 517 - } /* end keyctl_describe_key() */ 518 - 519 - /*****************************************************************************/ 520 536 /* 521 537 * search the specified keyring for a matching key 522 538 * - the start keyring must be searchable ··· 606 626 kfree(description); 607 627 error: 608 628 return ret; 629 + } 609 630 610 - } /* end keyctl_keyring_search() */ 611 - 612 - /*****************************************************************************/ 613 631 /* 614 632 * read a user key's payload 615 633 * - the keyring must be readable or the key must be searchable from the ··· 666 688 key_put(key); 667 689 error: 668 690 return ret; 691 + } 669 692 670 - } /* end keyctl_read_key() */ 671 - 672 - /*****************************************************************************/ 673 693 /* 674 694 * change the ownership of a key 675 695 * - the keyring owned by the changer ··· 772 796 zapowner = newowner; 773 797 ret = -EDQUOT; 774 798 goto error_put; 799 + } 775 800 776 - } /* end keyctl_chown_key() */ 777 - 778 - /*****************************************************************************/ 779 801 /* 780 802 * change the permission mask on a key 781 803 * - the keyring owned by the changer ··· 812 838 key_put(key); 813 839 error: 814 840 return ret; 815 - 816 - } /* end keyctl_setperm_key() */ 841 + } 817 842 818 843 /* 819 844 * get the destination keyring for instantiation ··· 868 895 return commit_creds(new); 869 896 } 870 897 871 - /*****************************************************************************/ 872 898 /* 873 899 * instantiate the key with the specified payload, and, if one is given, link 874 900 * the key into the keyring ··· 945 973 vfree(payload); 946 974 error: 947 975 return ret; 976 + } 948 977 949 - } /* end keyctl_instantiate_key() */ 950 - 951 - /*****************************************************************************/ 952 978 /* 953 979 * negatively instantiate the key with the given timeout (in seconds), and, if 954 980 * one is given, link the key into the keyring ··· 990 1020 991 1021 error: 992 1022 return ret; 1023 + } 993 1024 994 - } /* end keyctl_negate_key() */ 995 - 996 - /*****************************************************************************/ 997 1025 /* 998 1026 * set the default keyring in which request_key() will cache keys 999 1027 * - return the old setting ··· 1047 1079 error: 1048 1080 abort_creds(new); 1049 1081 return ret; 1082 + } 1050 1083 1051 - } /* end keyctl_set_reqkey_keyring() */ 1052 - 1053 - /*****************************************************************************/ 1054 1084 /* 1055 1085 * set or clear the timeout for a key 1056 1086 */ ··· 1102 1136 ret = 0; 1103 1137 error: 1104 1138 return ret; 1139 + } 1105 1140 1106 - } /* end keyctl_set_timeout() */ 1107 - 1108 - /*****************************************************************************/ 1109 1141 /* 1110 1142 * assume the authority to instantiate the specified key 1111 1143 */ ··· 1142 1178 ret = authkey->serial; 1143 1179 error: 1144 1180 return ret; 1145 - 1146 - } /* end keyctl_assume_authority() */ 1181 + } 1147 1182 1148 1183 /* 1149 1184 * get the security label of a key ··· 1311 1348 #endif /* !TIF_NOTIFY_RESUME */ 1312 1349 } 1313 1350 1314 - /*****************************************************************************/ 1315 1351 /* 1316 1352 * the key control system call 1317 1353 */ ··· 1401 1439 default: 1402 1440 return -EOPNOTSUPP; 1403 1441 } 1404 - 1405 - } /* end sys_keyctl() */ 1442 + }
+16 -48
security/keys/keyring.c
··· 80 80 */ 81 81 static DECLARE_RWSEM(keyring_serialise_link_sem); 82 82 83 - /*****************************************************************************/ 84 83 /* 85 84 * publish the name of a keyring so that it can be found by name (if it has 86 85 * one) ··· 101 102 102 103 write_unlock(&keyring_name_lock); 103 104 } 105 + } 104 106 105 - } /* end keyring_publish_name() */ 106 - 107 - /*****************************************************************************/ 108 107 /* 109 108 * initialise a keyring 110 109 * - we object if we were given any data ··· 120 123 } 121 124 122 125 return ret; 126 + } 123 127 124 - } /* end keyring_instantiate() */ 125 - 126 - /*****************************************************************************/ 127 128 /* 128 129 * match keyrings on their name 129 130 */ ··· 129 134 { 130 135 return keyring->description && 131 136 strcmp(keyring->description, description) == 0; 137 + } 132 138 133 - } /* end keyring_match() */ 134 - 135 - /*****************************************************************************/ 136 139 /* 137 140 * dispose of the data dangling from the corpse of a keyring 138 141 */ ··· 157 164 key_put(klist->keys[loop]); 158 165 kfree(klist); 159 166 } 167 + } 160 168 161 - } /* end keyring_destroy() */ 162 - 163 - /*****************************************************************************/ 164 169 /* 165 170 * describe the keyring 166 171 */ ··· 178 187 else 179 188 seq_puts(m, ": empty"); 180 189 rcu_read_unlock(); 190 + } 181 191 182 - } /* end keyring_describe() */ 183 - 184 - /*****************************************************************************/ 185 192 /* 186 193 * read a list of key IDs from the keyring's contents 187 194 * - the keyring's semaphore is read-locked ··· 230 241 231 242 error: 232 243 return ret; 244 + } 233 245 234 - } /* end keyring_read() */ 235 - 236 - /*****************************************************************************/ 237 246 /* 238 247 * allocate a keyring and link into the destination keyring 239 248 */ ··· 256 269 } 257 270 258 271 return keyring; 272 + } 259 273 260 - } /* end keyring_alloc() */ 261 - 262 - /*****************************************************************************/ 263 274 /* 264 275 * search the supplied keyring tree for a key that matches the criterion 265 276 * - perform a breadth-then-depth search up to the prescribed limit ··· 429 444 rcu_read_unlock(); 430 445 error: 431 446 return key_ref; 447 + } 432 448 433 - } /* end keyring_search_aux() */ 434 - 435 - /*****************************************************************************/ 436 449 /* 437 450 * search the supplied keyring tree for a key that matches the criterion 438 451 * - perform a breadth-then-depth search up to the prescribed limit ··· 448 465 449 466 return keyring_search_aux(keyring, current->cred, 450 467 type, description, type->match); 451 - 452 - } /* end keyring_search() */ 468 + } 453 469 454 470 EXPORT_SYMBOL(keyring_search); 455 471 456 - /*****************************************************************************/ 457 472 /* 458 473 * search the given keyring only (no recursion) 459 474 * - keyring must be locked by caller ··· 495 514 atomic_inc(&key->usage); 496 515 rcu_read_unlock(); 497 516 return make_key_ref(key, possessed); 517 + } 498 518 499 - } /* end __keyring_search_one() */ 500 - 501 - /*****************************************************************************/ 502 519 /* 503 520 * find a keyring with the specified name 504 521 * - all named keyrings are searched ··· 548 569 out: 549 570 read_unlock(&keyring_name_lock); 550 571 return keyring; 572 + } 551 573 552 - } /* end find_keyring_by_name() */ 553 - 554 - /*****************************************************************************/ 555 574 /* 556 575 * see if a cycle will will be created by inserting acyclic tree B in acyclic 557 576 * tree A at the topmost level (ie: as a direct child of A) ··· 634 657 cycle_detected: 635 658 ret = -EDEADLK; 636 659 goto error; 637 - 638 - } /* end keyring_detect_cycle() */ 660 + } 639 661 640 662 /* 641 663 * dispose of a keyring list after the RCU grace period, freeing the unlinked ··· 874 898 875 899 EXPORT_SYMBOL(key_link); 876 900 877 - /*****************************************************************************/ 878 901 /* 879 902 * unlink the first link to a key from a keyring 880 903 */ ··· 943 968 ret = -ENOMEM; 944 969 up_write(&keyring->sem); 945 970 goto error; 946 - 947 - } /* end key_unlink() */ 971 + } 948 972 949 973 EXPORT_SYMBOL(key_unlink); 950 974 951 - /*****************************************************************************/ 952 975 /* 953 976 * dispose of a keyring list after the RCU grace period, releasing the keys it 954 977 * links to ··· 962 989 key_put(klist->keys[loop]); 963 990 964 991 kfree(klist); 992 + } 965 993 966 - } /* end keyring_clear_rcu_disposal() */ 967 - 968 - /*****************************************************************************/ 969 994 /* 970 995 * clear the specified process keyring 971 996 * - implements keyctl(KEYCTL_CLEAR) ··· 998 1027 } 999 1028 1000 1029 return ret; 1001 - 1002 - } /* end keyring_clear() */ 1030 + } 1003 1031 1004 1032 EXPORT_SYMBOL(keyring_clear); 1005 1033 1006 - /*****************************************************************************/ 1007 1034 /* 1008 1035 * dispose of the links from a revoked keyring 1009 1036 * - called with the key sem write-locked ··· 1019 1050 rcu_assign_pointer(keyring->payload.subscriptions, NULL); 1020 1051 call_rcu(&klist->rcu, keyring_clear_rcu_disposal); 1021 1052 } 1022 - 1023 - } /* end keyring_revoke() */ 1053 + } 1024 1054 1025 1055 /* 1026 1056 * Determine whether a key is dead
+2 -6
security/keys/permission.c
··· 13 13 #include <linux/security.h> 14 14 #include "internal.h" 15 15 16 - /*****************************************************************************/ 17 16 /** 18 17 * key_task_permission - Check a key can be used 19 18 * @key_ref: The key to check ··· 78 79 79 80 /* let LSM be the final arbiter */ 80 81 return security_key_permission(key_ref, cred, perm); 81 - 82 - } /* end key_task_permission() */ 82 + } 83 83 84 84 EXPORT_SYMBOL(key_task_permission); 85 85 86 - /*****************************************************************************/ 87 86 /* 88 87 * validate a key 89 88 */ ··· 108 111 109 112 error: 110 113 return ret; 111 - 112 - } /* end key_validate() */ 114 + } 113 115 114 116 EXPORT_SYMBOL(key_validate);
+1 -6
security/keys/proc.c
··· 60 60 .release = seq_release, 61 61 }; 62 62 63 - /*****************************************************************************/ 64 63 /* 65 64 * declare the /proc files 66 65 */ ··· 78 79 panic("Cannot create /proc/key-users\n"); 79 80 80 81 return 0; 81 - 82 - } /* end key_proc_init() */ 82 + } 83 83 84 84 __initcall(key_proc_init); 85 85 86 - /*****************************************************************************/ 87 86 /* 88 87 * implement "/proc/keys" to provides a list of the keys on the system 89 88 */ ··· 290 293 return __key_user_next(n); 291 294 } 292 295 293 - /*****************************************************************************/ 294 296 /* 295 297 * implement "/proc/key-users" to provides a list of the key users 296 298 */ ··· 347 351 maxbytes); 348 352 349 353 return 0; 350 - 351 354 }
+5 -18
security/keys/process_keys.c
··· 38 38 .user_ns = &init_user_ns, 39 39 }; 40 40 41 - /*****************************************************************************/ 42 41 /* 43 42 * install user and user session keyrings for a particular UID 44 43 */ ··· 274 275 return commit_creds(new); 275 276 } 276 277 277 - /*****************************************************************************/ 278 278 /* 279 279 * the filesystem user ID changed 280 280 */ ··· 286 288 tsk->cred->thread_keyring->uid = tsk->cred->fsuid; 287 289 up_write(&tsk->cred->thread_keyring->sem); 288 290 } 291 + } 289 292 290 - } /* end key_fsuid_changed() */ 291 - 292 - /*****************************************************************************/ 293 293 /* 294 294 * the filesystem group ID changed 295 295 */ ··· 300 304 tsk->cred->thread_keyring->gid = tsk->cred->fsgid; 301 305 up_write(&tsk->cred->thread_keyring->sem); 302 306 } 307 + } 303 308 304 - } /* end key_fsgid_changed() */ 305 - 306 - /*****************************************************************************/ 307 309 /* 308 310 * search only my process keyrings for the first matching key 309 311 * - we use the supplied match function to see if the description (or other ··· 422 428 return key_ref; 423 429 } 424 430 425 - /*****************************************************************************/ 426 431 /* 427 432 * search the process keyrings for the first matching key 428 433 * - we use the supplied match function to see if the description (or other ··· 482 489 483 490 found: 484 491 return key_ref; 492 + } 485 493 486 - } /* end search_process_keyrings() */ 487 - 488 - /*****************************************************************************/ 489 494 /* 490 495 * see if the key we're looking at is the target key 491 496 */ 492 497 int lookup_user_key_possessed(const struct key *key, const void *target) 493 498 { 494 499 return key == target; 500 + } 495 501 496 - } /* end lookup_user_key_possessed() */ 497 - 498 - /*****************************************************************************/ 499 502 /* 500 503 * lookup a key given a key ID from userspace with a given permissions mask 501 504 * - don't create special keyrings unless so requested ··· 700 711 reget_creds: 701 712 put_cred(cred); 702 713 goto try_again; 714 + } 703 715 704 - } /* end lookup_user_key() */ 705 - 706 - /*****************************************************************************/ 707 716 /* 708 717 * join the named keyring as the session keyring if possible, or attempt to 709 718 * create a new one of that name if not
+8 -24
security/keys/request_key_auth.c
··· 38 38 .read = request_key_auth_read, 39 39 }; 40 40 41 - /*****************************************************************************/ 42 41 /* 43 42 * instantiate a request-key authorisation key 44 43 */ ··· 47 48 { 48 49 key->payload.data = (struct request_key_auth *) data; 49 50 return 0; 51 + } 50 52 51 - } /* end request_key_auth_instantiate() */ 52 - 53 - /*****************************************************************************/ 54 53 /* 55 54 * reading a request-key authorisation key retrieves the callout information 56 55 */ ··· 60 63 seq_puts(m, "key:"); 61 64 seq_puts(m, key->description); 62 65 seq_printf(m, " pid:%d ci:%zu", rka->pid, rka->callout_len); 66 + } 63 67 64 - } /* end request_key_auth_describe() */ 65 - 66 - /*****************************************************************************/ 67 68 /* 68 69 * read the callout_info data 69 70 * - the key's semaphore is read-locked ··· 86 91 } 87 92 88 93 return ret; 94 + } 89 95 90 - } /* end request_key_auth_read() */ 91 - 92 - /*****************************************************************************/ 93 96 /* 94 97 * handle revocation of an authorisation token key 95 98 * - called with the key sem write-locked ··· 102 109 put_cred(rka->cred); 103 110 rka->cred = NULL; 104 111 } 112 + } 105 113 106 - } /* end request_key_auth_revoke() */ 107 - 108 - /*****************************************************************************/ 109 114 /* 110 115 * destroy an instantiation authorisation token key 111 116 */ ··· 122 131 key_put(rka->dest_keyring); 123 132 kfree(rka->callout_info); 124 133 kfree(rka); 134 + } 125 135 126 - } /* end request_key_auth_destroy() */ 127 - 128 - /*****************************************************************************/ 129 136 /* 130 137 * create an authorisation token for /sbin/request-key or whoever to gain 131 138 * access to the caller's security data ··· 217 228 kfree(rka); 218 229 kleave("= %d", ret); 219 230 return ERR_PTR(ret); 231 + } 220 232 221 - } /* end request_key_auth_new() */ 222 - 223 - /*****************************************************************************/ 224 233 /* 225 234 * see if an authorisation key is associated with a particular key 226 235 */ ··· 229 242 key_serial_t id = (key_serial_t)(unsigned long) _id; 230 243 231 244 return rka->target_key->serial == id; 245 + } 232 246 233 - } /* end key_get_instantiation_authkey_match() */ 234 - 235 - /*****************************************************************************/ 236 247 /* 237 248 * get the authorisation key for instantiation of a specific key if attached to 238 249 * the current process's keyrings ··· 263 278 264 279 error: 265 280 return authkey; 266 - 267 - } /* end key_get_instantiation_authkey() */ 281 + }
+8 -24
security/keys/user_defined.c
··· 35 35 36 36 EXPORT_SYMBOL_GPL(key_type_user); 37 37 38 - /*****************************************************************************/ 39 38 /* 40 39 * instantiate a user defined key 41 40 */ ··· 64 65 65 66 error: 66 67 return ret; 67 - 68 - } /* end user_instantiate() */ 68 + } 69 69 70 70 EXPORT_SYMBOL_GPL(user_instantiate); 71 71 72 - /*****************************************************************************/ 73 72 /* 74 73 * dispose of the old data from an updated user defined key 75 74 */ ··· 78 81 upayload = container_of(rcu, struct user_key_payload, rcu); 79 82 80 83 kfree(upayload); 84 + } 81 85 82 - } /* end user_update_rcu_disposal() */ 83 - 84 - /*****************************************************************************/ 85 86 /* 86 87 * update a user defined key 87 88 * - the key's semaphore is write-locked ··· 118 123 119 124 error: 120 125 return ret; 121 - 122 - } /* end user_update() */ 126 + } 123 127 124 128 EXPORT_SYMBOL_GPL(user_update); 125 129 126 - /*****************************************************************************/ 127 130 /* 128 131 * match users on their name 129 132 */ 130 133 int user_match(const struct key *key, const void *description) 131 134 { 132 135 return strcmp(key->description, description) == 0; 133 - 134 - } /* end user_match() */ 136 + } 135 137 136 138 EXPORT_SYMBOL_GPL(user_match); 137 139 138 - /*****************************************************************************/ 139 140 /* 140 141 * dispose of the links from a revoked keyring 141 142 * - called with the key sem write-locked ··· 147 156 rcu_assign_pointer(key->payload.data, NULL); 148 157 call_rcu(&upayload->rcu, user_update_rcu_disposal); 149 158 } 150 - 151 - } /* end user_revoke() */ 159 + } 152 160 153 161 EXPORT_SYMBOL(user_revoke); 154 162 155 - /*****************************************************************************/ 156 163 /* 157 164 * dispose of the data dangling from the corpse of a user key 158 165 */ ··· 159 170 struct user_key_payload *upayload = key->payload.data; 160 171 161 172 kfree(upayload); 162 - 163 - } /* end user_destroy() */ 173 + } 164 174 165 175 EXPORT_SYMBOL_GPL(user_destroy); 166 176 167 - /*****************************************************************************/ 168 177 /* 169 178 * describe the user key 170 179 */ ··· 171 184 seq_puts(m, key->description); 172 185 173 186 seq_printf(m, ": %u", key->datalen); 174 - 175 - } /* end user_describe() */ 187 + } 176 188 177 189 EXPORT_SYMBOL_GPL(user_describe); 178 190 179 - /*****************************************************************************/ 180 191 /* 181 192 * read the key data 182 193 * - the key's semaphore is read-locked ··· 198 213 } 199 214 200 215 return ret; 201 - 202 - } /* end user_read() */ 216 + } 203 217 204 218 EXPORT_SYMBOL_GPL(user_read);