Chameleon

Chameleon Commit Details

Date:2012-09-28 12:52:33 (11 years 6 months ago)
Author:armel cadet-petit
Commit:2066
Parents: 2065
Message:security fixes, few other fixes
Changes:
M/branches/cparm/i386/modules/GUI/gui.c
M/branches/cparm/xcode3_sym.zip
M/branches/cparm/i386/modules/KernelPatcher/kernel_patcher.c
M/branches/cparm/Chameleon.xcodeproj/project.pbxproj
M/branches/cparm/i386/libsaio/fake_efi.c
M/branches/cparm/i386/modules/ACPICodec/acpi_codec.c
M/branches/cparm/i386/modules/GUI/picopng.c
M/branches/cparm/i386/modules/GraphicsEnabler/nvidia.c
M/branches/cparm/CHANGES

File differences

branches/cparm/Chameleon.xcodeproj/project.pbxproj
450450
451451
452452
453
454
455
456453
457454
458455
......
10821079
10831080
10841081
1085
10861082
10871083
10881084
......
13961392
13971393
13981394
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
14091395
14101396
14111397
AB43B3F814C384040018D529 /* stack_protector.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stack_protector.c; sourceTree = "<group>"; };
AB79217514F38CF200F5EB39 /* bootXnu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bootXnu.h; sourceTree = "<group>"; };
AB79219214F3919E00F5EB39 /* ModuleHelp.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ModuleHelp.txt; sourceTree = "<group>"; };
ABA02705156CE81A00F8E5F3 /* ext2fs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ext2fs.c; sourceTree = "<group>"; };
ABA02706156CE81A00F8E5F3 /* ext2fs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ext2fs.h; sourceTree = "<group>"; };
ABA02707156CE81A00F8E5F3 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
ABA0C7BF1568190C003440AF /* arc4random-fbsd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "arc4random-fbsd.c"; sourceTree = "<group>"; };
ABA0C7C01568190C003440AF /* lib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lib.c; sourceTree = "<group>"; };
ABA0C7C11568190C003440AF /* rtc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rtc.c; sourceTree = "<group>"; };
AB43B34914C37E520018D529 /* ACPICodec */,
AB43B35214C37E520018D529 /* ACPIPatcher */,
AB43B35914C37E520018D529 /* CPUfreq */,
ABA02704156CE81A00F8E5F3 /* Ext2fs */,
AB43B35C14C37E520018D529 /* GraphicsEnabler */,
AB43B36614C37E520018D529 /* GUI */,
AB43B37014C37E520018D529 /* HelloWorld */,
path = Intel_Acpi;
sourceTree = "<group>";
};
ABA02704156CE81A00F8E5F3 /* Ext2fs */ = {
isa = PBXGroup;
children = (
ABA02705156CE81A00F8E5F3 /* ext2fs.c */,
ABA02706156CE81A00F8E5F3 /* ext2fs.h */,
ABA02707156CE81A00F8E5F3 /* Makefile */,
);
path = Ext2fs;
sourceTree = "<group>";
};
ABBBFCF915D55908002D7A1E /* bin */ = {
isa = PBXGroup;
children = (
branches/cparm/CHANGES
1
2
3
4
5
16
27
38
- Few security fixes
- Fixed a serious bug in picopng
- Fixed a bug in gui.c, related to the images loading
- Fixed a bug with acpi, where no acpi table may be configured
- Security fixes
- Updated smbus(spd.c) and radeon(ati.c) card list (taken from the last cosmo1t's update)
branches/cparm/i386/libsaio/fake_efi.c
6464
6565
6666
67
68
67
68
6969
70
71
72
73
74
75
76
70
71
72
73
74
75
76
77
7778
7879
7980
......
469470
470471
471472
472
473
474
475
476
477
473478
474
475
476
477
478479
480
479481
480482
481483
......
490492
491493
492494
493
495
496
497
498
499
500
494501
495502
496503
497504
498
499
500
505
506
501507
502508
503
504
509
505510
506
511
507512
508
513
514
509515
510
516
517
511518
512519
520
521
522
523
524
525
513526
527
514528
515529
516
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
517552
518553
519554
520555
521
522
523
524
556
557
558
525559
526
560
527561
528
529
530562
531563
532564
......
606638
607639
608640
609
641
610642
611643
612644
......
648680
649681
650682
651
683
652684
653685
654686
......
687719
688720
689721
690
722
691723
692724
693725
......
697729
698730
699731
700
732
701733
702734
703735
......
941973
942974
943975
944
976
945977
946978
947979
......
951983
952984
953985
954
986
955987
956988
957989
......
961993
962994
963995
964
996
997
965998
966999
967
968
969
1000
9701001
9711002
9721003
......
9931024
9941025
9951026
996
1027
9971028
9981029
9991030
* necessary hardware.
*/
static inline char * mallocStringForGuid(EFI_GUID const *pGuid);
static VOID EFI_ST_FIX_CRC32(void);
static EFI_STATUS setupAcpiNoMod();
static VOID EFI_ST_FIX_CRC32(VOID);
static EFI_STATUS setupAcpiNoMod(VOID);
static EFI_CHAR16* getSmbiosChar16(const char * key, size_t* len);
static EFI_CHAR8* getSmbiosUUID();
static int8_t *getSystemID();
static VOID setupSystemType();
static VOID setupEfiDeviceTree(void);
static VOID setup_Smbios();
static VOID setup_machine_signature();
static VOID setupEfiConfigurationTable();
static EFI_CHAR8* getSmbiosUUID(VOID);
static int8_t *getSystemID(VOID);
static VOID setupSystemType(VOID);
static VOID setupEfiDeviceTree(VOID);
static VOID setup_Smbios(VOID);
static VOID setup_machine_signature(VOID);
static VOID setupEfiConfigurationTable(VOID);
static EFI_STATUS EFI_FindAcpiTables(VOID);
/*==========================================================================
* Utility function to make a device tree string from an EFI_GUID
* ACPI
*/
static uint64_t local_rsd_p;
static uint64_t local_rsd_p= 0;
static uint64_t kFSBFrequency= 0;
static uint32_tkHardware_signature = 0;
static uint8_tkType= 0;
static uint32_tkAdler32= 0;
static ACPI_TABLES acpi_tables;
static uint64_t kFSBFrequency;
static uint32_tkHardware_signature;
static uint8_tkType;
static uint32_tkAdler32;
EFI_STATUS Register_Acpi_Efi(void* rsd_p, unsigned char rev )
{
EFI_STATUS Status = EFI_UNSUPPORTED;
{
Status = addConfigurationTable(&gEfiAcpiTableGuid, &local_rsd_p, "ACPI");
}
}
}
else
{
Status = setupAcpiNoMod();
}
return Status;
}
/* Setup ACPI without any patch. */
static EFI_STATUS setupAcpiNoMod()
{
static EFI_STATUS EFI_FindAcpiTables(VOID)
{
EFI_STATUS ret = EFI_UNSUPPORTED;
ACPI_TABLE_RSDP* rsdp = (ACPI_TABLE_RSDP*)((uint32_t)local_rsd_p);
if(rsdp->Revision > 0 && (GetChecksum(rsdp, sizeof(ACPI_TABLE_RSDP)) == 0))
if (local_rsd_p)
{
ret = addConfigurationTable(&gEfiAcpi20TableGuid, &local_rsd_p, "ACPI_20");
return EFI_SUCCESS;
}
else
if (!FindAcpiTables(&acpi_tables))
{
ret = addConfigurationTable(&gEfiAcpiTableGuid, &local_rsd_p, "ACPI");
printf("Failed to detect ACPI tables.\n");
ret = EFI_NOT_FOUND;
}
local_rsd_p = ((uint64_t)((uint32_t)acpi_tables.RsdPointer));
if (local_rsd_p)
{
ret = EFI_SUCCESS;
}
return ret;
}
EFI_STATUS setup_acpi (void)
/* Setup ACPI without any patch. */
static EFI_STATUS setupAcpiNoMod(VOID)
{
EFI_STATUS ret = EFI_UNSUPPORTED;
if (EFI_FindAcpiTables() == EFI_SUCCESS)
{
ACPI_TABLE_RSDP* rsdp = (ACPI_TABLE_RSDP*)((uint32_t)local_rsd_p);
if(rsdp->Revision > 0 && (GetChecksum(rsdp, sizeof(ACPI_TABLE_RSDP)) == 0))
{
ret = addConfigurationTable(&gEfiAcpi20TableGuid, &local_rsd_p, "ACPI_20");
}
else
{
ret = addConfigurationTable(&gEfiAcpiTableGuid, &local_rsd_p, "ACPI");
}
}
return ret;
}
EFI_STATUS setup_acpi (VOID)
{
EFI_STATUS ret = EFI_UNSUPPORTED;
do {
if (!FindAcpiTables(&acpi_tables))
{
printf("Failed to detect ACPI tables.\n");
ret = EFI_NOT_FOUND;
if ((ret = EFI_FindAcpiTables()) != EFI_SUCCESS)
{
break;
}
}
local_rsd_p = ((uint64_t)((uint32_t)acpi_tables.RsdPointer));
{
ACPI_TABLE_FADT *FacpPointer = (acpi_tables.FacpPointer64 != (void*)0ul) ? (ACPI_TABLE_FADT *)acpi_tables.FacpPointer64 : (ACPI_TABLE_FADT *)acpi_tables.FacpPointer;
* Get the SystemID from the bios dmi info
*/
static EFI_CHAR8* getSmbiosUUID()
static EFI_CHAR8* getSmbiosUUID(VOID)
{
static EFI_CHAR8 uuid[UUID_LEN];
int i, isZero, isOnes;
* or from the bios if not, or from a fixed value if no bios value is found
*/
static int8_t *getSystemID()
static int8_t *getSystemID(VOID)
{
static int8_tsysid[16];
// unable to determine UUID for host. Error: 35 fix
* facp content to reflect in ioregs
*/
static VOID setupSystemType()
static VOID setupSystemType(VOID)
{
Node *node = DT__FindNode("/", false);
if (node == 0) stop("Couldn't get root node");
DT__AddProperty(node, SYSTEM_TYPE_PROP, sizeof(uint8_t), &kType);
}
static VOID setupEfiDeviceTree(void)
static VOID setupEfiDeviceTree(VOID)
{
Node*node;
}
}
static VOID setup_Smbios()
static VOID setup_Smbios(VOID)
{
if (execute_hook("getSmbiosPatched",NULL, NULL, NULL, NULL, NULL, NULL) != EFI_SUCCESS)
{
}
}
static VOID setup_machine_signature()
static VOID setup_machine_signature(VOID)
{
Node *chosenNode = DT__FindNode("/chosen", false);
if (chosenNode)
do {
if (!local_rsd_p)
{
if (!FindAcpiTables(&acpi_tables)){
if ( EFI_FindAcpiTables() != EFI_SUCCESS)
{
printf("Failed to detect ACPI tables.\n");
break;
}
local_rsd_p = ((uint64_t)((uint32_t)acpi_tables.RsdPointer));
}
}
ACPI_TABLE_FACS *FacsPointer = (acpi_tables.FacsPointer64 != (void*)0ul) ? (ACPI_TABLE_FACS *)acpi_tables.FacsPointer64:(ACPI_TABLE_FACS *)acpi_tables.FacsPointer;
* Installs all the needed configuration table entries
*/
static VOID setupEfiConfigurationTable()
static VOID setupEfiConfigurationTable(VOID)
{
if (smbios_p)
addConfigurationTable(&gEfiSmbiosTableGuid, &smbios_p, NULL);
branches/cparm/i386/modules/GUI/picopng.c
110110
111111
112112
113
113
114114
115115
116
117
118
119
120
121
116
117
118
119
120
121
122
123
124
125
126
127
122128
129
123130
124131
125132
void *png_alloc_realloc(void *addr, size_t size)
{
void *new_addr;
void *new_addr = NULL;
if (!addr)
return png_alloc_malloc(size);
new_addr = realloc(addr, size);
if (new_addr && (new_addr != addr)) {
png_alloc_node_t *old_node;
old_node = png_alloc_find_node(addr);
png_alloc_remove_node(old_node);
png_alloc_add_node(new_addr, size);
png_alloc_node_t *old_node;
old_node = png_alloc_find_node(addr);
if (old_node)
{
new_addr = realloc(addr, size);
if (new_addr && (new_addr != addr))
{
png_alloc_remove_node(old_node);
png_alloc_add_node(new_addr, size);
}
}
return new_addr;
}
branches/cparm/i386/modules/GUI/gui.c
501501
502502
503503
504
504
505505
506506
507507
......
509509
510510
511511
512
512513
513514
514515
......
520521
521522
522523
523
524
524525
525526
526527
......
542543
543544
544545
546
547
548
545549
546550
547551
......
575579
576580
577581
578
582
579583
580584
581585
......
983987
984988
985989
986
990
987991
988992
989993
......
25852589
25862590
25872591
2588
2592
25892593
2590
2594
25912595
25922596
25932597
width = 0;
height = 0;
imagedata = NULL;
if ( strlen(theme_name) > 0 && (loadPngImage(dirspec, &width, &height, &imagedata)) == 0)
if ((strlen(theme_name) > 0) && (loadPngImage(dirspec, &width, &height, &imagedata) != -1 ))
{
images[i].image->width = width;
images[i].image->height = height;
flipRB(images[i].image);
DBG("[ %s ] succesfully loaded and registred !!\n", dirspec);
DBG("width = %d : height = %d !!\n",images[i].image->width,images[i].image->height);
return 0;
}
embed_data = embeddedImages[e].pngdata;
embed_size = *embeddedImages[e].length;
if (loadEmbeddedPngImage(embed_data, embed_size, &width, &height, &imagedata) == 0)
if (loadEmbeddedPngImage(embed_data, embed_size, &width, &height, &imagedata) != -1)
{
images[i].image->width = width;
images[i].image->height = height;
images[i].image->height = images[alt_image].image->height;
images[i].image->pixels = images[alt_image].image->pixels;
DBG("Passing to alt_image !!\n");
DBG("width = %d : height = %d !!\n",images[alt_image].image->width,images[alt_image].image->height);
} else {
DBG("Unable to load %s, this image not vital anyway, reseting and returning success !!\n", dirspec);
printf("[ %s/%s/%s.png ] not used in this version, skipped !!\n",src, theme_name, image);
sleep(2);
#endif
return 1;
return 0;
}
static int loadGraphics(char *src)
if(GUI_getDimensionForKey("menu_height", &pixel, theme, gui.screen.height , 0 ) )
gui.menu.height = pixel;
else
gui.menu.height = (infoMenuItemsCount) * images[iMenuSelection].image->height;
gui.menu.height = infoMenuItemsCount * images[iMenuSelection].image->height;
if(GUI_getDimensionForKey("menu_pos_x", &pixel, theme, screen_width , gui.menu.width ) )
gui.menu.pos.x = pixel;
return;
}
sprintf(dirspec, "%s/%s/boot.png", src, theme_name);
if (strlen(theme_name) == 0 || loadPngImage(dirspec, &bootImageWidth, &bootImageHeight, &bootImageData) != 0) {
if ((strlen(theme_name) == 0) || (loadPngImage(dirspec, &bootImageWidth, &bootImageHeight, &bootImageData) == -1)) {
#ifdef EMBED_THEME
if ((loadEmbeddedPngImage(__boot_png, __boot_png_len, &bootImageWidth, &bootImageHeight, &bootImageData)) != 0)
if ((loadEmbeddedPngImage(__boot_png, __boot_png_len, &bootImageWidth, &bootImageHeight, &bootImageData)) == -1)
#endif
usePngImage = false;
}
branches/cparm/i386/modules/KernelPatcher/kernel_patcher.c
558558
559559
560560
561
561562
563
562564
563565
564566
bytes[patchLocation + 3] = 0x00;// cpuid_extfamily
bytes[patchLocation + 4] = 0x02;// cpuid_stepping
#if 0
patchLocation = jumpLocation;
#endif
// We now have 14 bytes available for a patch
}
else
branches/cparm/i386/modules/GraphicsEnabler/nvidia.c
14331433
14341434
14351435
1436
14361437
14371438
14381439
DBG("%s Signature 0x%02x%02x %d bytes\n", nvFilename, rom[0], rom[1], nvBiosOveride);
} else {
printf("ERROR: unable to open nVidia Video BIOS File %s\n", nvFilename);
free(rom);
return false;
}
} else {
branches/cparm/i386/modules/ACPICodec/acpi_codec.c
47114711
47124712
47134713
4714
47144715
4716
4717
47154718
47164719
47174720
......
49124915
49134916
49144917
4918
49154919
49164920
49174921
......
49414945
49424946
49434947
4944
4948
4949
4950
4951
4952
49454953
49464954
49474955
......
50885096
50895097
50905098
5091
5099
5100
5101
5102
5103
5104
5105
5106
50925107
5108
5109
5110
5111
5112
5113
5114
5115
50935116
50945117
5095
5096
5118
5119
5120
50975121
50985122
5099
5100
5101
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
51025137
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5138
5139
5140
5141
5142
51305143
51315144
51325145
if (!FindAcpiTables(&acpi_tables))
{
printf("Error: AcpiCodec Failed to detect ACPI tables.\n");
#if DEBUG_ACPI
getc();
#endif
Register_Acpi_Efi(NULL, 0);
return EFI_NOT_FOUND;
}
if (rsdp == (void*)0ul || (GetChecksum(rsdp, (rsdp->Revision == 0) ? ACPI_RSDP_REV0_SIZE:sizeof(ACPI_TABLE_RSDP)) != 0) )
{
printf("Error : ACPI RSD PTR Revision %d checksum is incorrect or table not found \n",rsdp->Revision );
Register_Acpi_Efi(NULL, 0);
return EFI_UNSUPPORTED;
}
{
rsdp_mod=(ACPI_TABLE_RSDP *) AllocateKernelMemory(rsdplength);
if (!rsdp_mod) return EFI_OUT_OF_RESOURCES;
if (!rsdp_mod)
{
Register_Acpi_Efi(NULL, 0);
return EFI_OUT_OF_RESOURCES;
}
memcpy(rsdp_mod, rsdp, rsdplength);
}
}
}
if ((rsdp_mod != (void *)0ul) && (rsdp_mod->Length >= ACPI_RSDP_REV0_SIZE) )
if (rsdp_mod == (void *)0ul)
{
printf("Error: rsdp_mod == null \n");
Register_Acpi_Efi(NULL, 0);
return EFI_ABORTED;
}
if (!(rsdp_mod->Length >= ACPI_RSDP_REV0_SIZE))
{
printf("Error: rsdp_mod size is incorrect \n");
Register_Acpi_Efi(NULL, 0);
return EFI_ABORTED;
}
do {
if ((rsdp_mod->Revision == 0) || (gen_xsdt == true))
{
process_rsdt(rsdp_mod, gen_xsdt, new_table_list);
goto out;
if (process_rsdt(rsdp_mod, gen_xsdt, new_table_list))
break;
printf("Error : ACPI RSD PTR Revision 1 is incorrect, \n");
}
}
else
{
if ((GetChecksum(rsdp_mod, sizeof(ACPI_TABLE_RSDP)) == 0) &&
(Revision == 2) &&
(rsdplength == sizeof(ACPI_TABLE_RSDP)))
{
if (process_xsdt(rsdp_mod, new_table_list))
break;
printf("Error : ACPI RSD PTR Revision 2 is incorrect \n");
}
Revision = 0; // fallback to Revision 0
if (process_rsdt(rsdp_mod, false, new_table_list))
break;
printf("Error: Incorect ACPI RSD PTR or not found \n");
return EFI_UNSUPPORTED;
}
if ((GetChecksum(rsdp_mod, sizeof(ACPI_TABLE_RSDP)) == 0) &&
(Revision == 2) &&
(rsdplength == sizeof(ACPI_TABLE_RSDP)))
{
process_xsdt(rsdp_mod, new_table_list);
}
else
{
printf("Warning : ACPI RSD PTR Revision 2 is incorrect, \n");
printf(" trying to fallback to Revision 1\n");
if ((rsdp_mod != (void *)0ul) && (rsdp_mod->Length >= ACPI_RSDP_REV0_SIZE) )
{
process_rsdt(rsdp_mod, false, new_table_list);
}
else
{
printf("Error: Incorect ACPI RSD PTR or not found \n");
return EFI_UNSUPPORTED;
}
}
out:
Register_Acpi_Efi(NULL, 0);
return EFI_ABORTED;
} while (0);
// Correct the checksum of RSDP
DBG("RSDP: Original checksum %d\n", rsdp_mod->Checksum);

Archive Download the corresponding diff file

Revision: 2066