Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:security\keys\big_key.c Create Date:2022-07-28 18:28:31
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Preparse a big key

Proto:int big_key_preparse(struct key_preparsed_payload *prep)

Type:int

Parameter:

TypeParameterName
struct key_preparsed_payload *prep
203  struct path * path = (struct path * ) & Raw data [big_key_path]
207  datalen = Raw datalen , enclen = datalen + Authentication tag length
210  If datalen <= 0 || datalen > 1024 * 1024 || Not Raw data Then Return -EINVAL
214  Quota length for proposed payload = 16
216  Raw data [big_key_len] = datalen
218  If datalen > If the data is under this limit, there's no point creating a shm file to* hold it as the permanently resident metadata for the shmem fs will be at* least as large as the data. Then
224  pos = 0
226  buf = Allocate a buffer consisting of a set of pages with a virtual mapping* applied over them.
227  If Not buf Then Return -ENOMEM
229  memcpy(virt, Raw data , datalen)
232  enckey = Allocation memory
233  If Not enckey Then
234  ret = -ENOMEM
235  Go to error
237  ret = Calls wait_for_random_bytes() and then calls get_random_bytes(buf, nbytes).* Returns the result of the call to wait_for_random_bytes.
238  If Value for the false possibility is greater at compile time(ret) Then Go to err_enckey
242  ret = Encrypt/decrypt big_key data
243  If ret Then Go to err_enckey
247  file = shmem_kernel_file_setup - get an unlinked file living in tmpfs which must be* kernel internal. There will be NO LSM permission checks against the* underlying inode. So users of this interface must do LSM checks at a* higher layer
248  If IS_ERR(file) Then
249  ret = PTR_ERR(file)
250  Go to err_enckey
253  written = kernel_write(file, virt, enclen, & pos)
254  If written != enclen Then
255  ret = written
256  If written >= 0 Then ret = -ENOMEM
258  Go to err_fput
264  Raw data [big_key_data] = enckey
265  path = f_path
266  path_get(path)
267  fput(file)
268  Free up the buffer.
269  Else
271  data = Allocation memory
273  If Not data Then Return -ENOMEM
276  Raw data [big_key_data] = data
277  memcpy(data, Raw data , Raw datalen )
279  Return 0
281  err_fput :
282  fput(file)
283  err_enckey :
284  kzfree - like kfree but zero memory*@p: object to free memory of* The memory of the object @p points to is zeroed before freed.* If @p is %NULL, kzfree() does nothing.* Note: this function zeroes the whole allocated buffer which can be a good
285  error :
286  Free up the buffer.
287  Return ret