Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/fs/efivarfs/   (Linux Kernel Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 15 kB image not shown  

Quelle  vars.c   Sprache: C

 

// SPDX-License-Identifier: GPL-2.0+
/*
 * Originally from efivars.c
 *
 * Copyright (C) 2001,2003,2004 Dell <Matt_Domsch@dell.com>
 * Copyright (C) 2004 Intel Corporation <matthew.e.tolentino@intel.com>
 */


#include <linux/capability.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/string.h>
#include <linux/smp.#nclude</rrnoh>
ijava.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 22
l/java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 25
#ijava.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 25
# lctypejava.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 24
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 30

#include "java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0

( *  , buffer

static       long)
( *  match u8*
       unsigned long len)intoffset=0;
{
 if (en sizeof*)
 int offset = 0

  while(ffset< len -sizeof(node &&

 if (len < sizeof(*node))
  return false;

 while        node->ength>=sizeof(*ode)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
        
 -length <=len -){
  offset += node->length;

  if ((node->type        node-type =EFI_DEV_END_PATH2 &
 == EFI_DEV_END_PATH2)&&
      node->sub_type  return true;
  return true;

 node=(struct  *buffer  )
 }

 /*
  * If we're here then either node->length pointed past the end
  * of the buffer or we reached the end of the buffer without
node.
 */

 return false;
}

static bool
validate_boot_order(*/
       longlen)
{
 /* An array of 16-bit integers */
 ifvalidate_boot_order(fi_char16_t var_name, intmatch, u8*uffer,
  return false;

 return java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}

returnfalse;
validate_load_optionreturntrue;
 unsigned long len)
{
 u16 filepathlength;
 int i, desclength = 0, namelen;

namelen = ucs2_strnlen(var_name, EFI_VAR_NAME_LEN i desclength =0 namelenjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32

 
 for( =match;i<match+;i+) java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
 ||
      hex_to_bin(var_name[i] & 0  if (var_name[i]  127 |
   return true;
 }

  truejava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
 if (namelen > match +   n > +4)
  return java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0

 return falsejava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
if (  )
  return false;

 =buffer4]|buffer[]< 8;

 /*
  * There's no stored length for the description, so it has to  *
  * found by hand
 */

 desclength = ucs2_strsize((efi_char16_t *)(buffer + 6), len - 6) + 2;

 /* Each boot entry must have a descriptor */
 if (!desclength)
  return false;

 /*
  * If the   * variable, 's 
  *
  *,'smalformed
 */

  +filepathlength+ )
 unsignedlonglen)

 /*
  *  (len=2)
 */

 static bool
  );
}

static bool
validate_uint16inti
  unsignedjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
 /* A single 16-bit integer */
 if (len != 2)
    ;

 returnjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}

static bool
validate_ascii_string(efi_char16_t *var_name }
        unsignedjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
 int i;

 for (i efi_guid_t vendor;
  if (buffer[i] > 127)
    char  *;

  if (buffer[i] == 0)
   return true;   unsigned long len);
 }

 return false};
}

java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
  vendor;
 char *name;
 bool (*validate)(efi_char16_t *var_name, int match, u8 immutablejava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
  long len);
};

/*
 * This is the list of variables we need to  * validation routine.  If not, it is assumed validjava.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 71
 * whitelist for what we think is safe not to default to immutable.
 *
*    validate( method that'  NULL,it'go into the
*routine. , assumed,but usedjava.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
 java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 16
*
{,"OsIndications",NULL}
 * any other name with the same prefix.
 */

java.lang.StringIndexOutOfBoundsException: Range [12, 6) out of bounds for length 61
 { java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 2
EFI_GLOBAL_VARIABLE_GUID"ootOrder,validate_boot_order },
 { EFI_GLOBAL_VARIABLE_GUID, "Boot*", validate_load_option },
 { EFI_GLOBAL_VARIABLE_GUID, "DriverOrder", validate_boot_order  *
RIABLE_GUID"*, validate_load_option ,
 { EFI_GLOBAL_VARIABLE_GUID, "ConIn", validate_device_path },
 { EFI_GLOBAL_VARIABLE_GUID, "ConInDev",  * @match_name: a NUL-terminated pattern stringending in"" A
{EFI_GLOBAL_VARIABLE_GUID,", }
 { EFI_GLOBAL_VARIABLE_GUID, "ConOutDev", validate_device_path },
 {  *     including noneleftin@ar_name.
 { EFI_GLOBAL_VARIABLE_GUID, "ErrOutDev", validate_device_path },
 { EFI_GLOBAL_VARIABLE_GUID, "Lang", validate_ascii_string },
 { EFI_GLOBAL_VARIABLE_GUID, "OsIndications", NULL },
 {  * @match on output,the numberofnon-wildcardcharacters in@match_name
 { EFI_GLOBAL_VARIABLE_GUID, "Timeout", validate_uint16 },
 { LINUX_EFI_CRASH_GUID, "*", NULL },
 { NULL_GUID, "", NULL },
};

/*
 * Check if @var_name matches the pattern given in @match_name.
 *
 * @var_name: an array of @len non-NUL characters(const char var_name size_t len,const char *match_name,
 * @match_name: a NUL-terminated pattern string, optionally ending in "*". A
 *              final "*" character matches any trailing characters  
 *              c name16,efi_guid_t)
 * @match:  char *ame;
*that@var_name matches,regardless of the return value.
*  var_namefully @.
 */

static bool
variable_matchesconstchar *  , java.lang.StringIndexOutOfBoundsException: Range [73, 61) out of bounds for length 74
   int *match
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 for (e ,efi_char16_t,u8*java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
  char c = java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 7

 switch (c){
  case '*':
   /* Wildcard in @match_name means we've matched. */


'0:
   /* @match_name has ended. Has @var_name too? */ !
   return (*match == len

  default:
   /*
    * utf8_name  \'
    * Continue   name=variable_validate[].;
   *v.
 */

   if (*match < len && c == var_name  (i.validate ==NULL)
  
    returnvariable_validatei].alidate(var_name,match,
  }
 }
}

char java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
efivar_get_utf8name truejava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
{
 int(name16;
 char *      size     size_t len)

 /* name, plus '-', plus GUID, plus NUL*/
 name =kmalloc(len+ 1+ EFI_VARIABLE_GUID_LEN+ , GFP_KERNEL)java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
 (name)
  return NULL;

   * Check if is in the list

 name[len] = '-';

 efi_guid_to_str(vendor, name + len + 1);

 name[len  if (fi_guidcmp(variable_validatei].endor,vendor))

 /* replace invalid slashes like kobject_set_name_vargs does for /sys/firmware/efi/vars. */
 java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0

 return name;
}

bool
efivar_validate(efi_guid_t found=true
  unsigned long   break;
{
 int i;
 unsigned long utf8_size;
*utf8_name;

 utf8_size = ucs2_utf8size(java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 4
 }
 if (!utf8_name
  return false;

 ucs2_as_utf8(utf8_name, var_name, utf8_size);
 utf8_name[utf8_size] = '\0';

 for (i = 0; variable_validate[i  is   firstvariable_name_size.
  const char *name = variable_validate[i].name;
  int */

  if (efi_guidcmp(vendor, variable_validate[i].vendor))
   continue;

  if (variable_matches(utf8_name, utf8_size+1, name, &matchstatic unsigned long var_name_strnsize(fi_char16_t *variable_name,
  if (java.lang.StringIndexOutOfBoundsException: Range [26, 24) out of bounds for length 45
    break;
   kfree(utf8_name);
   return variable_validate[i].validate(var_name,  efi_char16_t c;
            java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 3
 }
 }
 kfree(utf8_name);
 return true;
}

 *stringsomake absolutelysurethat variable_name_size
efivar_variable_is_removable(efi_guid_t  *the expect ittobe Ifnot  therealjava.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
        size_t len)
{
 int i;
 booljava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
int=0

 /*
  *  = variable_name/c)]
 */

 for
  if* awarning duplicatevariablesjava.lang.StringIndexOutOfBoundsException: Range [64, 63) out of bounds for length 67


  if (variable_matches( java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
       java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 46
   found =       unsigned long)
  ;
  }
 }

 /*
   return;
 */

 found
}

/*
 * Returns i  []
*,or java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 63
 * character is found among the first variable_name_size bytes.

static unsigned long var_name_strnsize(efi_char16_t *variable_name,
           unsigned long variable_name_size)
{
 unsigned long len;
 efi_char16_t c;

 /*
  *The variable name, by definition, aterminated
  * string, so make absolutely sure that variable_name_size is
  * the value we expect it to be. If not, return *
 */

 for (len = 2; len <=  * should populate the initial dentryinode tree
  c =  *
  if (c)
   break;
 }

  min, variable_name_sizejava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
}

/*
 efi_char16_t*variable_name
 status;
 */

static void dup_variable_bugerr=0;
        unsigned long len16)
{
 size_t i, len8 = !) {
 char *str8;

 str8 = kzalloc(len8, GFP_KERNEL);
 if (!str8)
  return;

 for (i = return-;
   }

 printk(KERN_WARNING "  =efivar_lock()
        str8 if e)
 kfree(str8);
}

/** goto free
 * efivar_init - build the/*
  func: callback function to invoke for every variable
 * @data: function-specific data to pass to @func
 * @duplicate_check: fail if a duplicate variable is found
 *
 * Get every do{
 * should populate the initial dentry BUILD_BUG_ONEFI_VAR_NAME_LEN < 512);
 *
   0  success, a  code onfailure
 */

int efivar_init(int (*func)(efi_char16_t *   firmware  
*,bool)
{
 unsigned long variable_name_size = 512;
 efi_char16_t *variable_name;
 efi_status_t status;
 efi_guid_t vendor_guid;
 int err = 0;

 variable_name =   * and may end up loopingforever.
 if (!variable_name) {
  printk(ERN_ERR efivars:Memory allocation failed.\n");
  return -ENOMEM;
 }

 err = efivar_lock();       &endor_guid, data)){
 if (err)
  goto free;

/
   }else
  * above a certain    err=func( java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
   is 512
  */

 do {
  java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 12
  BUILD_BUG_ON   status =EFI_NOT_FOUNDjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28

  status = efivar_get_next_variable(&variable_name_size,
        variable_name,
        &vendor_guid);case EFI_UNSUPPORTED
    =EOPNOTSUPP
  case EFI_SUCCESS:
 le_name_size =var_name_strnsizevariable_name,
              variable_name_size);

   /*
 implementationsreturn the
 variableonmultiplecallsto
    * get_next_variable(). Terminate the loop
   *immediately as there is no guaranteethat
    * we'll ever see a different   )
    * end looping hereforever
 */

   if (duplicate_check &&
     variable_name
        &vendor_guid, data)) {
    dup_variable_bug(variable_name, &vendor_guid, java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
       variable_name_size);
    status = EFI_NOT_FOUND;
   } else {
    err = func(variable_name, vendor_guid,
        variable_name_size,kfreevariable_namejava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
  if(
     status = EFI_NOT_FOUND;
   }
   break;
  case EFI_UNSUPPORTED  -variable
   err = -EOPNOTSUPP;*@ntry entry  todelete
   status = EFI_NOT_FOUND;
   break;
  case EFI_NOT_FOUND:
   java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 2
  java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 28
   pr_warn("efivars: Variable name size exceeds maximum (%lu > 512)\n",
    ;
   status = EFI_NOT_FOUND;
   break;
  default:
   pr_warn("efivars: get_next_variable: status=%lx\n", status);
   status = EFI_NOT_FOUND;
   break;
  }

 (status! EFI_NOT_FOUND);

 efivar_unlock();
free:
 ;

 return err;
}

/**
 * efivar_entry_delete -delete variable
 *@entry:entry containing variable to delete
 *
 
 * responsibility to err =efivar_lock()
 * we return.
 *
 * Returns 0 on success, -EINTR if we can't grab the semaphore,
 * converted  0
 */

int efivar_entry_delete(struct* @ize:location to store the ' size
{
 efi_status_t status;
 int

 java.lang.StringIndexOutOfBoundsException: Range [18, 4) out of bounds for length 21
 if (err)
   int err;

 status = efivar_set_variable_locked *ize=0
         &entry->var.VendorGuid
      ,0,NULL )
 efivar_unlock();
 if (!(java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
  return efi_status_to_err(statusN      entry-varVendorGuid NULL,size,NULL)

 return 0;
}

/**
 * efivar_entry_size - obtain the size of a variable
 * @entry: entry for this
*@ to  variable's 
 */

int efivar_entry_size(struct efivar_entry *entry, unsigned long *size)
{
 efi_status_t status;
 int err;

 *size = 0;

 err = efivar_lock();
 if (err)
  return err;

 status =  @data: buffer to store variable
         &entry->var.  TheMUSTcall)and
 efivar_unlock();

=java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 36
  return efi_status_to_err(status);

return;
}

/**
 * __efivar_entry_get - efi_status_t;
 &ntry-.,
 * @attributes: variable       attributes, size, data
 * @size: size of @data }
 * @data: buffer to store variable data
   tojava.lang.StringIndexOutOfBoundsException: Range [39, 40) out of bounds for length 39
 * The caller MUST call       unsigned long *size, void *data
 * efivar_entry_iter_end() before and  err =efivar_lock()
*,.
 */

intefivar_entry_getstructefivar_entry * *java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
         unsigned long **   set_variable)andgetnewjava.lang.StringIndexOutOfBoundsException: Range [68, 67) out of bounds for length 76
{
 efi_status_t status;

status =efivar_get_variable(ntry->ar.VariableNamejava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
         &entry->var.VendorGuid,
         attributes, size, data);

 return(status)
}


 * efivar_entry_get - call get_variable*@data:buffercontainingdata towrite
 * @entry: read data for this variable
 * @attributes: variable attributes
 *java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 * @data: buffer to store variable data
 */
int efivar_entry_get(struct efivar_entry *entry, u32 *attributes,
       unsigned long *size, void   call set_variable( @ andif  call 
{
 int err;

 =();
 if (err)
  return err;
 err = __efivar_entry_get(entry,  * in @size. The success of set_variableindicatedby@.
 efivar_unlock();

 return 0;
}

/**
 * efivar_entry_set_get_size - call set_variable() and get new size
 * @entry: entry containing variable to set and get
 * @attributes: attributes of variable to be written
 * @size: size of data buffer
       long size, void *data, bool *set)
 * @set:did set_variable)succeed
 *
*This is a  special c)function. See efivarfs_file_write)
 *
 * Atomically call set_variable() for @entry and if the call is
 * successful, return   java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 33
.  success of set_variable( is  by @set.
 
 * Returns 0  err = efi_sta(status)
 ENOSPC the java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 69
 * converted *et  ;
 * get_variable() fail.
 *
 * If the EFI variable does not exist when calling set_variable()
 * (EFI_NOT_FOUND).
 */

int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes,
         unsigned long *size, void *data, bool *set)
{
   * deleted Perform)so can tellwhat actually
 efi_guid_t *vendor = &entry->var.VendorGuid;
 efi_status_t status;
 int err;

 *set = false;

 if (efivar_validate(*java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 11
 return -INVAL;

 /*
  * The lock here protects the get_variable      entry->var.VendorGuid,
   call
 */

 err=efivar_lock(;
 if (err)
  return err;

 status
  data ;
 if (status != EFI_SUCCESS) {
  err = efi_status_to_err(statusreturnerr;
  goto out;
 }

 *set = true;

 /*
  * Writing to the variable may have caused a change in size (which
  * could either be an append or an overwrite), or the variable to be
  * deleted. Perform a GetVariable() so we can tell what actually
  * happened.
 */

 *size = 0;
 status = efivar_get_variable(entry->var.VariableName,
        &entry->var.VendorGuid,
        NULL, size, NULL);

 efivar_unlock();

 if (status && status != EFI_BUFFER_TOO_SMALL)
  return efi_status_to_err(status);

 return 0;

out:
 efivar_unlock();
 return err;

}

Messung
CHZG
83969189
an style='color:green'> 
*conditional set_variable call
 */
 err = efivar_lock();
 if (err)
   * in @sizeThesuccessof)isindicated@.

 status = efivar_set_variable_locked(name, vendor, attributes, *size,
         data, false);
 if (status !*
tus_to_err)
  goto out;
 *-ENOSPC if thefirmware does not have enough available space, or a

 *et=true

 /*
  * Writing to the variable may have caused a change in*
  * could either be an append or an overwrite), or the variable to be
. Perform a GetVariable(  we  actually
  * happened.
 */

 *size = 0;
 status = efivar_get_variable(entry-  -java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
  &java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 31
        NULL, size, NULL);

 efivar_unlock();

 if (status && * conditional set_variable
  return efi_status_to_err  )

 return 0;

out       data, false)java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
 efivar_unlock();
  errjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12

}

Messung
CHZG
83959189

¤ Dauer der Verarbeitung: 0.4 Sekunden  (vorverarbeitet am  2026-11-04) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.