insecure.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /* Null security operations.
  3. *
  4. * Copyright (C) 2016 Red Hat, Inc. All Rights Reserved.
  5. * Written by David Howells (dhowells@redhat.com)
  6. */
  7. #include <net/af_rxrpc.h>
  8. #include "ar-internal.h"
  9. static int none_init_connection_security(struct rxrpc_connection *conn,
  10. struct rxrpc_key_token *token)
  11. {
  12. return 0;
  13. }
  14. /*
  15. * Allocate an appropriately sized buffer for the amount of data remaining.
  16. */
  17. static struct rxrpc_txbuf *none_alloc_txbuf(struct rxrpc_call *call, size_t remain, gfp_t gfp)
  18. {
  19. return rxrpc_alloc_data_txbuf(call, min_t(size_t, remain, RXRPC_JUMBO_DATALEN), 1, gfp);
  20. }
  21. static int none_secure_packet(struct rxrpc_call *call, struct rxrpc_txbuf *txb)
  22. {
  23. return 0;
  24. }
  25. static int none_verify_packet(struct rxrpc_call *call, struct sk_buff *skb)
  26. {
  27. struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
  28. sp->flags |= RXRPC_RX_VERIFIED;
  29. return 0;
  30. }
  31. static void none_free_call_crypto(struct rxrpc_call *call)
  32. {
  33. }
  34. static int none_respond_to_challenge(struct rxrpc_connection *conn,
  35. struct sk_buff *skb)
  36. {
  37. return rxrpc_abort_conn(conn, skb, RX_PROTOCOL_ERROR, -EPROTO,
  38. rxrpc_eproto_rxnull_challenge);
  39. }
  40. static int none_verify_response(struct rxrpc_connection *conn,
  41. struct sk_buff *skb)
  42. {
  43. return rxrpc_abort_conn(conn, skb, RX_PROTOCOL_ERROR, -EPROTO,
  44. rxrpc_eproto_rxnull_response);
  45. }
  46. static void none_clear(struct rxrpc_connection *conn)
  47. {
  48. }
  49. static int none_init(void)
  50. {
  51. return 0;
  52. }
  53. static void none_exit(void)
  54. {
  55. }
  56. /*
  57. * RxRPC Kerberos-based security
  58. */
  59. const struct rxrpc_security rxrpc_no_security = {
  60. .name = "none",
  61. .security_index = RXRPC_SECURITY_NONE,
  62. .init = none_init,
  63. .exit = none_exit,
  64. .init_connection_security = none_init_connection_security,
  65. .free_call_crypto = none_free_call_crypto,
  66. .alloc_txbuf = none_alloc_txbuf,
  67. .secure_packet = none_secure_packet,
  68. .verify_packet = none_verify_packet,
  69. .respond_to_challenge = none_respond_to_challenge,
  70. .verify_response = none_verify_response,
  71. .clear = none_clear,
  72. };