aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_hs_control.c
AgeCommit message (Collapse)Author
2022-12-16Fix typosDimitris Apostolou
2021-07-12test_hs_control: initialize pointers to NULLNick Mathewson
This is an attempt to fix CID 1486276, where coverity warns us that, if the tests failed, we might free() an uninitialized pointer.
2021-03-12Update copyrights to 2021, using "make update-copyright"Nick Mathewson
2021-02-22Fix a test failure in test_hs_control_add_onion_helper_add_service().George Kadianakis
This bug made the pipeline fail. It basically tries to access a service we just freed because it's still on the service list. It only occurs about once every 10 tests and it looks like this: $ ./src/test/test hs_control/hs_control_add_onion_helper_add_service hs_control/hs_control_add_onion_helper_add_service: [forking] ================================================================= ==354311==ERROR: AddressSanitizer: heap-use-after-free on address 0x613000000940 at pc 0x55a159251b03 bp 0x7ffc6abb5b30 sp 0x7ffc6abb5b28 READ of size 8 at 0x613000000940 thread T0 ^[[A #0 0x55a159251b02 in hs_service_ht_HT_FIND_P_ src/feature/hs/hs_service.c:153 #1 0x55a159251b02 in hs_service_ht_HT_FIND src/feature/hs/hs_service.c:153 #2 0x55a159251b02 in find_service src/feature/hs/hs_service.c:175 #3 0x55a159251c2c in register_service src/feature/hs/hs_service.c:188 #4 0x55a159262379 in hs_service_add_ephemeral src/feature/hs/hs_service.c:3811 #5 0x55a158e865e6 in test_hs_control_add_onion_helper_add_service src/test/test_hs_control.c:847 #6 0x55a1590fe77b in testcase_run_bare_ src/ext/tinytest.c:107 #7 0x55a1590fee98 in testcase_run_forked_ src/ext/tinytest.c:201 #8 0x55a1590fee98 in testcase_run_one src/ext/tinytest.c:267 #9 0x55a1590ffb06 in tinytest_main src/ext/tinytest.c:454 #10 0x55a158b1b1a4 in main src/test/testing_common.c:420 #11 0x7f7f06f8dd09 in __libc_start_main ../csu/libc-start.c:308 #12 0x55a158b21f69 in _start (/home/f/Computers/tor/mytor/src/test/test+0x372f69) 0x613000000940 is located 64 bytes inside of 344-byte region [0x613000000900,0x613000000a58) freed by thread T0 here: #0 0x7f7f0774ab6f in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:123 #1 0x55a158e86508 in test_hs_control_add_onion_helper_add_service src/test/test_hs_control.c:838 #2 0x55a1590fe77b in testcase_run_bare_ src/ext/tinytest.c:107 #3 0x55a1590fee98 in testcase_run_forked_ src/ext/tinytest.c:201 #4 0x55a1590fee98 in testcase_run_one src/ext/tinytest.c:267 #5 0x55a1590ffb06 in tinytest_main src/ext/tinytest.c:454 #6 0x55a158b1b1a4 in main src/test/testing_common.c:420 #7 0x7f7f06f8dd09 in __libc_start_main ../csu/libc-start.c:308 previously allocated by thread T0 here: #0 0x7f7f0774ae8f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145 #1 0x55a15948b728 in tor_malloc_ src/lib/malloc/malloc.c:45 #2 0x55a15948b7c0 in tor_malloc_zero_ src/lib/malloc/malloc.c:71 #3 0x55a159261bb5 in hs_service_new src/feature/hs/hs_service.c:4290 #4 0x55a159261f49 in hs_service_add_ephemeral src/feature/hs/hs_service.c:3758 #5 0x55a158e8619f in test_hs_control_add_onion_helper_add_service src/test/test_hs_control.c:832 #6 0x55a1590fe77b in testcase_run_bare_ src/ext/tinytest.c:107 #7 0x55a1590fee98 in testcase_run_forked_ src/ext/tinytest.c:201 #8 0x55a1590fee98 in testcase_run_one src/ext/tinytest.c:267 #9 0x55a1590ffb06 in tinytest_main src/ext/tinytest.c:454 #10 0x55a158b1b1a4 in main src/test/testing_common.c:420 #11 0x7f7f06f8dd09 in __libc_start_main ../csu/libc-start.c:308 SUMMARY: AddressSanitizer: heap-use-after-free src/feature/hs/hs_service.c:153 in hs_service_ht_HT_FIND_P_ Shadow bytes around the buggy address: 0x0c267fff80d0: 00 00 00 00 00 00 00 00 00 00 00 00 fa fa fa fa 0x0c267fff80e0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00 0x0c267fff80f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c267fff8100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c267fff8110: 00 00 00 00 00 00 00 00 fa fa fa fa fa fa fa fa =>0x0c267fff8120: fd fd fd fd fd fd fd fd[fd]fd fd fd fd fd fd fd 0x0c267fff8130: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c267fff8140: fd fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa 0x0c267fff8150: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00 0x0c267fff8160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c267fff8170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb Shadow gap: cc ==354311==ABORTING [Lost connection!] [hs_control_add_onion_helper_add_service FAILED] 1/1 TESTS FAILED. (0 skipped)
2021-02-19hs-v2: Removal of service and relay supportDavid Goulet
This is unfortunately massive but both functionalities were extremely intertwined and it would have required us to actually change the HSv2 code in order to be able to split this into multiple commits. After this commit, there are still artefacts of v2 in the code but there is no more support for service, intro point and HSDir. The v2 support for rendezvous circuit is still available since that code is the same for the v3 and we will leave it in so if a client is able to rendezvous on v2 then it can still transfer traffic. Once the entire network has moved away from v2, we can remove v2 rendezvous point support. Related to #40266 Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-02-08Another round of unittest massaging for tor!212.George Kadianakis
2021-02-08Fix broken unittest from tor!212 .George Kadianakis
Be more careful with memory management in the test.
2020-12-08Reinstate add_onion_helper_add_service() test, validate auth clients before ↵Neel Chauhan
adding them
2020-11-24Some test and logic correctionsNeel Chauhan
2020-11-19Add tests for bug #40084Neel Chauhan
2020-11-12Fix typos.Samanta Navarro
Typos found with codespell. Please keep in mind that this should have impact on actual code and must be carefully evaluated: src/core/or/lttng_circuit.inc - ctf_enum_value("CONTROLER", CIRCUIT_PURPOSE_CONTROLLER) + ctf_enum_value("CONTROLLER", CIRCUIT_PURPOSE_CONTROLLER)
2020-08-20v3 control: Persist ONION_CLIENT_AUTH_ADD client nameNeel Chauhan
2020-06-22Consistently use 'address' in Invalid v3 address responses to ↵Miguel Jacq
ONION_CLIENT_AUTH commands
2020-04-13hs-v3: Don't allow registration of an all-zeroes client auth key.George Kadianakis
The client auth protocol allows attacker-controlled x25519 private keys being passed around, which allows an attacker to potentially trigger the all-zeroes assert for client_auth_sk in hs_descriptor.c:decrypt_descriptor_cookie(). We fixed that by making sure that an all-zeroes client auth key will not be used. There are no guidelines for validating x25519 private keys, and the assert was there as a sanity check for code flow issues (we don't want to enter that function with an unitialized key if client auth is being used). To avoid such crashes in the future, we also changed the assert to a BUG-and-err.
2020-03-17Split a wide line.Nick Mathewson
2020-03-17Add unittest for TROVE-2020-003.George Kadianakis
This unittest currently fails on purpose (to demonstrate the bug) but it will stop failing after the next commit (the bugfix).
2020-02-06test: Missing hs_init() in some hs_control testsDavid Goulet
Without the hs_init(), the caches are not initialized and the previous commit was causing an assert due to the missing caches. But regardless of that, those tests were not initializing but were calling hs_free_all(). Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-01-08It's 2020. Update the copyright dates with "make update-copyright"Nick Mathewson
2019-12-20Code Style: Delete headers that are included twiceteor
These changes were created using the "make autostyle" from 32522, and then split into commits.
2019-12-10Merge branch 'tor-github/pr/1583'David Goulet
2019-12-10hs-v3: Fix memory leak in test_hs_control_store_permanent_creds()George Kadianakis
2019-12-04control-port: Include HS address in ONION_CLIENT_AUTH_VIEW reply.George Kadianakis
2019-12-03hsv3: ONION_CLIENT_AUTH_REMOVE now also removes the credential file.George Kadianakis
2019-12-03hsv3: Remove support for client auth nicknames.George Kadianakis
Because the function that parses client auth credentials saved on disk (parse_auth_file_content()) is not future compatible, there is no way to add support for storing the nickname on the disk. Hence, nicknames cannot persist after Tor restart making them pretty much useless. In the future we can introduce nicknames by adding a new file format for client auth credentials, but this was not deemed worth doing at this stage.
2019-12-03hsv3: Add tests for permanently storing auth credentials.George Kadianakis
Remove Permanent flag from old tests, and make a new test that does all the permanent things.
2019-11-18control-port: Tests for ONION_CLIENT_AUTH_VIEW.George Kadianakis
2019-11-18control-port: Tests for ONION_CLIENT_AUTH_REMOVE.George Kadianakis
2019-11-18control-port: Tests for ONION_CLIENT_AUTH_ADD.George Kadianakis
2019-11-18control-port: Implement ONION_CLIENT_AUTH_ADD.George Kadianakis
2019-04-05crypto_format: Remove the return values from digest256_to_base64()teor
... and ed25519_public_to_base64(). Also remove all checks for the return values, which were redundant anyway, because the functions never failed. Part of 29960.
2019-03-25Minimize the includes in control.cNick Mathewson
2019-03-25Split all controller events code into a new control_events.cNick Mathewson
Also, split the formatting code shared by control.c and control_events.c into controller_fmt.c.
2019-01-16Bump copyright date to 2019Nick Mathewson
2018-07-05Fix every include path changed in the previous commit (automated)Nick Mathewson
I am very glad to have written this script.
2018-07-01Minimize headers that include crypto_formats and x25519 stuffNick Mathewson
2018-06-20Run rectify_include_paths.pyNick Mathewson
2018-06-20Update copyrights to 2018.Nick Mathewson
2018-06-15Extract routerstatus_t into its own header.Nick Mathewson
2018-06-15Extract node_t into its own header.Nick Mathewson
2018-04-28Make hsdir_index in node_t a hsdir_index_t rather than a pointer.Neel Chauhan
2017-12-05test: Add HS_DESC v3 unit testsDavid Goulet
This introduces the test_hs_control.c file which at this commit contains basic unit test for the HS_DESC event. Signed-off-by: David Goulet <dgoulet@torproject.org>