Print this page
12399 kobj printf functions should be checked

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/krtld/kobj.c
          +++ new/usr/src/uts/common/krtld/kobj.c
↓ open down ↓ 297 lines elided ↑ open up ↑
 298  298  int use_iflush;                         /* iflush after relocations */
 299  299  
 300  300  /*
 301  301   * _kobj_printf() and _vkobj_printf()
 302  302   *
 303  303   * Common printf function pointer. Can handle only one conversion
 304  304   * specification in the format string. Some of the functions invoked
 305  305   * through this function pointer cannot handle more that one conversion
 306  306   * specification in the format string.
 307  307   */
 308      -void (*_kobj_printf)(void *, const char *, ...);        /* printf routine */
 309      -void (*_vkobj_printf)(void *, const char *, va_list);   /* vprintf routine */
      308 +void (*_kobj_printf)(void *, const char *, ...) __KPRINTFLIKE(2);
      309 +void (*_vkobj_printf)(void *, const char *, va_list) __KVPRINTFLIKE(2);
 310  310  
 311  311  /*
 312  312   * Standalone function pointers for use within krtld.
 313  313   * Many platforms implement optimized platmod versions of
 314  314   * utilities such as bcopy and any such are not yet available
 315  315   * until the kernel is more completely stitched together.
 316  316   * See kobj_impl.h
 317  317   */
 318  318  void (*kobj_bcopy)(const void *, void *, size_t);
 319  319  void (*kobj_bzero)(void *, size_t);
↓ open down ↓ 184 lines elided ↑ open up ↑
 504  504          s_text = _text;
 505  505          e_text = _etext;
 506  506          s_data = _data;
 507  507          e_data = _edata;
 508  508  
 509  509          kobj_sync_instruction_memory(s_text, e_text - s_text);
 510  510  
 511  511  #ifdef  KOBJ_DEBUG
 512  512          if (kobj_debug & D_DEBUG)
 513  513                  _kobj_printf(ops,
 514      -                    "krtld: transferring control to: 0x%p\n", entry);
      514 +                    "krtld: transferring control to: 0x%lx\n", entry);
 515  515  #endif
 516  516  
 517  517          /*
 518  518           * Make sure the mod system knows about the modules already loaded.
 519  519           */
 520  520          last_module_id = kobj_last_module_id;
 521  521          bcopy(kobj_modules, &modules, sizeof (modules));
 522  522          modp = &modules;
 523  523          do {
 524  524                  if (modp->mod_next == kobj_modules)
 525  525                          modp->mod_next = &modules;
 526  526                  if (modp->mod_prev == kobj_modules)
 527  527                          modp->mod_prev = &modules;
 528  528          } while ((modp = modp->mod_next) != &modules);
 529  529  
 530  530          standalone = 0;
 531  531  
 532  532  #ifdef  KOBJ_DEBUG
 533  533          if (kobj_debug & D_DEBUG)
 534  534                  _kobj_printf(ops,
 535      -                    "krtld: really transferring control to: 0x%p\n", entry);
      535 +                    "krtld: really transferring control to: 0x%lx\n", entry);
 536  536  #endif
 537  537  
 538  538          /* restore printf/bcopy/bzero vectors before returning */
 539  539          kobj_restore_vectors();
 540  540  
 541  541  #if defined(_DBOOT)
 542  542          /*
 543  543           * krtld was called from a dboot ELF section, the embedded
 544  544           * dboot code contains the real entry via bootaux
 545  545           */
↓ open down ↓ 304 lines elided ↑ open up ↑
 850  850  
 851  851          cp->mod_text = mp->text;
 852  852          cp->mod_text_size = mp->text_size;
 853  853  
 854  854          mp->filename = cp->mod_filename;
 855  855  
 856  856  #ifdef  KOBJ_DEBUG
 857  857          if (kobj_debug & D_LOADING) {
 858  858                  _kobj_printf(ops, "krtld: file=%s\n", mp->filename);
 859  859                  _kobj_printf(ops, "\ttext: 0x%p", mp->text);
 860      -                _kobj_printf(ops, " size: 0x%x\n", mp->text_size);
      860 +                _kobj_printf(ops, " size: 0x%lx\n", mp->text_size);
 861  861                  _kobj_printf(ops, "\tdata: 0x%p", mp->data);
 862      -                _kobj_printf(ops, " dsize: 0x%x\n", mp->data_size);
      862 +                _kobj_printf(ops, " dsize: 0x%lx\n", mp->data_size);
 863  863          }
 864  864  #endif /* KOBJ_DEBUG */
 865  865  
 866  866          /*
 867  867           * Insert symbols into the hash table.
 868  868           */
 869  869          for (i = 0; i < mp->nsyms; i++) {
 870  870                  sp = (Sym *)(mp->symtbl + i * mp->symhdr->sh_entsize);
 871  871  
 872  872                  if (sp->st_name == 0 || sp->st_shndx == SHN_UNDEF)
↓ open down ↓ 88 lines elided ↑ open up ↑
 961  961           * set the limits for the booted object.
 962  962           */
 963  963          kmp->text_size = (size_t)(mp->text - kmp->text);
 964  964          kmp->data_size = (size_t)(mp->data - kmp->data);
 965  965          kobj_modules->mod_text_size = kmp->text_size;
 966  966  
 967  967  #ifdef  KOBJ_DEBUG
 968  968          if (kobj_debug & D_LOADING) {
 969  969                  _kobj_printf(ops, "krtld: file=%s\n", mp->filename);
 970  970                  _kobj_printf(ops, "\ttext:0x%p", mp->text);
 971      -                _kobj_printf(ops, " size: 0x%x\n", mp->text_size);
      971 +                _kobj_printf(ops, " size: 0x%lx\n", mp->text_size);
 972  972                  _kobj_printf(ops, "\tdata:0x%p", mp->data);
 973      -                _kobj_printf(ops, " dsize: 0x%x\n", mp->data_size);
      973 +                _kobj_printf(ops, " dsize: 0x%lx\n", mp->data_size);
 974  974          }
 975  975  #endif /* KOBJ_DEBUG */
 976  976  
 977  977          /*
 978  978           * Insert the symbols into the hash table.
 979  979           */
 980  980          for (i = 0; i < mp->nsyms; i++) {
 981  981                  sp = (Sym *)(mp->symtbl + i * mp->symhdr->sh_entsize);
 982  982  
 983  983                  if (sp->st_name == 0 || sp->st_shndx == SHN_UNDEF)
↓ open down ↓ 1019 lines elided ↑ open up ↑
2003 2003          }
2004 2004  
2005 2005          /* primary kernel modules do not have a signature section */
2006 2006          if (!(mp->flags & KOBJ_PRIM))
2007 2007                  get_signature(mp, file);
2008 2008  
2009 2009  #ifdef  KOBJ_DEBUG
2010 2010          if (kobj_debug & D_LOADING) {
2011 2011                  _kobj_printf(ops, "krtld: file=%s\n", mp->filename);
2012 2012                  _kobj_printf(ops, "\ttext:0x%p", mp->text);
2013      -                _kobj_printf(ops, " size: 0x%x\n", mp->text_size);
     2013 +                _kobj_printf(ops, " size: 0x%lx\n", mp->text_size);
2014 2014                  _kobj_printf(ops, "\tdata:0x%p", mp->data);
2015      -                _kobj_printf(ops, " dsize: 0x%x\n", mp->data_size);
     2015 +                _kobj_printf(ops, " dsize: 0x%lx\n", mp->data_size);
2016 2016          }
2017 2017  #endif /* KOBJ_DEBUG */
2018 2018  
2019 2019          /*
2020 2020           * For primary kernel modules, we defer
2021 2021           * symbol resolution and relocation until
2022 2022           * all primary objects have been loaded.
2023 2023           */
2024 2024          if (!standalone) {
2025 2025                  int ddrval, dcrval;
↓ open down ↓ 681 lines elided ↑ open up ↑
2707 2707                   * The check should ideally be shp->sh_type == SHT_NOBITS.
2708 2708                   * However, we can't do that check here as get_progbits()
2709 2709                   * resets the type.
2710 2710                   */
2711 2711                  if (strcmp(shstrtab + shp->sh_name, ".bss") == 0)
2712 2712                          continue;
2713 2713  #ifdef  KOBJ_DEBUG
2714 2714                  if (kobj_debug & D_DEBUG)
2715 2715                          _kobj_printf(ops,
2716 2716                              "krtld: crypto_es_hash: updating hash with"
2717      -                            " %s data size=%d\n", shstrtab + shp->sh_name,
2718      -                            shp->sh_size);
     2717 +                            " %s data size=%lx\n", shstrtab + shp->sh_name,
     2718 +                            (size_t)shp->sh_size);
2719 2719  #endif
2720 2720                  ASSERT(shp->sh_addr != 0);
2721 2721                  SHA1Update(&ctx, (const uint8_t *)shp->sh_addr, shp->sh_size);
2722 2722          }
2723 2723  
2724 2724          SHA1Final((uchar_t *)hash, &ctx);
2725 2725  }
2726 2726  
2727 2727  /*
2728 2728   * Get the .SUNW_signature section for the module, it it exists.
↓ open down ↓ 132 lines elided ↑ open up ↑
2861 2861                          break;
2862 2862  
2863 2863                  if (c == modnamelen - 1) {
2864 2864                          char *dep = kobj_alloc(p - d + 1, KM_WAIT|KM_TMP);
2865 2865  
2866 2866                          (void) strncpy(dep, d,  p - d + 1);
2867 2867                          dep[p - d] = '\0';
2868 2868  
2869 2869                          _kobj_printf(ops, "%s: dependency ", modp->mod_modname);
2870 2870                          _kobj_printf(ops, "'%s' too long ", dep);
2871      -                        _kobj_printf(ops, "(max %d chars)\n", modnamelen);
     2871 +                        _kobj_printf(ops, "(max %d chars)\n", (int)modnamelen);
2872 2872  
2873 2873                          kobj_free(dep, p - d + 1);
2874 2874  
2875 2875                          return (-1);
2876 2876                  }
2877 2877  
2878 2878                  *q = '\0';
2879 2879                  if ((req = mod_load_requisite(modp, modname)) == NULL) {
2880 2880  #ifndef KOBJ_DEBUG
2881 2881                          if (_moddebug & MODDEBUG_LOADMSG) {
↓ open down ↓ 931 lines elided ↑ open up ↑
3813 3813  kobj_read_file(struct _buf *file, char *buf, uint_t size, uint_t off)
3814 3814  {
3815 3815          int b_size, c_size;
3816 3816          int b_off;      /* Offset into buffer for start of bcopy */
3817 3817          int count = 0;
3818 3818          int page_addr;
3819 3819  
3820 3820          if (_moddebug & MODDEBUG_ERRMSG) {
3821 3821                  _kobj_printf(ops, "kobj_read_file: size=%x,", size);
3822 3822                  _kobj_printf(ops, " offset=%x at", off);
3823      -                _kobj_printf(ops, " buf=%x\n", buf);
     3823 +                _kobj_printf(ops, " buf=%lx\n", (uintptr_t)buf);
3824 3824          }
3825 3825  
3826 3826          /*
3827 3827           * Handle compressed (gzip for now) file here. First get the
3828 3828           * compressed size, then read the image into memory and finally
3829 3829           * call zlib to decompress the image at the supplied memory buffer.
3830 3830           */
3831 3831          if (file->_iscmp == CH_MAGIC_GZIP) {
3832 3832                  ulong_t dlen;
3833 3833                  vattr_t vattr;
↓ open down ↓ 22 lines elided ↑ open up ↑
3856 3856                  /* Decompress the image at the supplied memory buffer */
3857 3857                  if ((err = z_uncompress(buf, &dlen, file->_dbuf,
3858 3858                      vattr.va_size)) != Z_OK) {
3859 3859                          _kobj_printf(ops, "kobj_read_file: z_uncompress "
3860 3860                              "failed, error code : 0x%x\n", err);
3861 3861                          return (-1);
3862 3862                  }
3863 3863  
3864 3864                  if (dlen != size) {
3865 3865                          _kobj_printf(ops, "kobj_read_file: z_uncompress "
3866      -                            "failed to uncompress (size returned 0x%x , "
     3866 +                            "failed to uncompress (size returned 0x%lx , "
3867 3867                              "expected size: 0x%x)\n", dlen, size);
3868 3868                          return (-1);
3869 3869                  }
3870 3870  
3871 3871                  return (0);
3872 3872          }
3873 3873  
3874 3874          while (size) {
3875 3875                  page_addr = F_PAGE(file, off);
3876 3876                  b_size = file->_size;
↓ open down ↓ 793 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX