1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 /* 20 * hwasan_tag_memory() - tag a given a chunk of memory 21 * @ptr: pointer to the memory region being tagged 22 * @size: size of the memory region being tagged 23 * 24 * Generate a tag for the memory region and record it in the corresponding 25 * shadow memory locations. 26 * 27 * Return: pointer to the same memory pointed to by @ptr, but with the generated 28 * tag placed in the top byte. 29 */ 30 void* hwasan_tag_memory(void* ptr, size_t size); 31 32 /* 33 * hwasan_untag_memory() - untag a given a chunk of memory 34 * @ptr: pointer to the memory region being untagged 35 * @size: size of the memory region being untagged 36 * 37 * Find shadow memory location corresponding to the given memory region and 38 * clear its contents. 39 */ 40 void hwasan_untag_memory(void* ptr, size_t size); 41 42 /* 43 * hwasan_remove_ptr_tag() - clear the tag from the given pointer 44 * @ptr: pointer being untagged 45 * 46 * Return: pointer to memory pointed to by @ptr, but with the tag cleared. 47 */ 48 void* hwasan_remove_ptr_tag(void* ptr); 49