tpm1.c (3eb66e91a25497065c5322b1268cbc3953642227) | tpm1.c (bb3b6b0fc57182b568ded61c55eff8a02fcfe27b) |
---|---|
1/* 2 * Copyright (C) 2005, 2012 IBM Corporation 3 * 4 * Authors: 5 * Kent Yoder <key@linux.vnet.ibm.com> 6 * Seiji Munetoh <munetoh@jp.ibm.com> 7 * Stefan Berger <stefanb@us.ibm.com> 8 * Reiner Sailer <sailer@watson.ibm.com> --- 60 unchanged lines hidden (view full) --- 69 "S-CRTM Contents ", 70 "POST Contents ", 71 "Table of Devices", 72}; 73 74/* returns pointer to start of pos. entry of tcg log */ 75static void *tpm1_bios_measurements_start(struct seq_file *m, loff_t *pos) 76{ | 1/* 2 * Copyright (C) 2005, 2012 IBM Corporation 3 * 4 * Authors: 5 * Kent Yoder <key@linux.vnet.ibm.com> 6 * Seiji Munetoh <munetoh@jp.ibm.com> 7 * Stefan Berger <stefanb@us.ibm.com> 8 * Reiner Sailer <sailer@watson.ibm.com> --- 60 unchanged lines hidden (view full) --- 69 "S-CRTM Contents ", 70 "POST Contents ", 71 "Table of Devices", 72}; 73 74/* returns pointer to start of pos. entry of tcg log */ 75static void *tpm1_bios_measurements_start(struct seq_file *m, loff_t *pos) 76{ |
77 loff_t i; | 77 loff_t i = 0; |
78 struct tpm_chip *chip = m->private; 79 struct tpm_bios_log *log = &chip->log; 80 void *addr = log->bios_event_log; 81 void *limit = log->bios_event_log_end; 82 struct tcpa_event *event; 83 u32 converted_event_size; 84 u32 converted_event_type; 85 | 78 struct tpm_chip *chip = m->private; 79 struct tpm_bios_log *log = &chip->log; 80 void *addr = log->bios_event_log; 81 void *limit = log->bios_event_log_end; 82 struct tcpa_event *event; 83 u32 converted_event_size; 84 u32 converted_event_type; 85 |
86 | |
87 /* read over *pos measurements */ | 86 /* read over *pos measurements */ |
88 for (i = 0; i < *pos; i++) { | 87 do { |
89 event = addr; 90 | 88 event = addr; 89 |
90 /* check if current entry is valid */ 91 if (addr + sizeof(struct tcpa_event) >= limit) 92 return NULL; 93 |
|
91 converted_event_size = 92 do_endian_conversion(event->event_size); 93 converted_event_type = 94 do_endian_conversion(event->event_type); 95 | 94 converted_event_size = 95 do_endian_conversion(event->event_size); 96 converted_event_type = 97 do_endian_conversion(event->event_type); 98 |
96 if ((addr + sizeof(struct tcpa_event)) < limit) { 97 if ((converted_event_type == 0) && 98 (converted_event_size == 0)) 99 return NULL; 100 addr += (sizeof(struct tcpa_event) + 101 converted_event_size); 102 } 103 } | 99 if (((converted_event_type == 0) && (converted_event_size == 0)) 100 || ((addr + sizeof(struct tcpa_event) + converted_event_size) 101 >= limit)) 102 return NULL; |
104 | 103 |
105 /* now check if current entry is valid */ 106 if ((addr + sizeof(struct tcpa_event)) >= limit) 107 return NULL; | 104 if (i++ == *pos) 105 break; |
108 | 106 |
109 event = addr; | 107 addr += (sizeof(struct tcpa_event) + converted_event_size); 108 } while (1); |
110 | 109 |
111 converted_event_size = do_endian_conversion(event->event_size); 112 converted_event_type = do_endian_conversion(event->event_type); 113 114 if (((converted_event_type == 0) && (converted_event_size == 0)) 115 || ((addr + sizeof(struct tcpa_event) + converted_event_size) 116 >= limit)) 117 return NULL; 118 | |
119 return addr; 120} 121 122static void *tpm1_bios_measurements_next(struct seq_file *m, void *v, 123 loff_t *pos) 124{ 125 struct tcpa_event *event = v; 126 struct tpm_chip *chip = m->private; --- 184 unchanged lines hidden --- | 110 return addr; 111} 112 113static void *tpm1_bios_measurements_next(struct seq_file *m, void *v, 114 loff_t *pos) 115{ 116 struct tcpa_event *event = v; 117 struct tpm_chip *chip = m->private; --- 184 unchanged lines hidden --- |