Skip to contentSkip to conversation

New Defects reported by Coverity Scan for Das U-Boot

DISCUSSION Heinrich Schuchardt 1 participant 2 messages Jan 27, 2024 – Jan 28, 2024 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20240127154018.GC785631@bill-the-cat

#1 lore raw

Am 27. Januar 2024 16:40:18 MEZ schrieb Tom Rini <[email protected]>:

Quoted 209 lines

Hey, I'll just pass this on directly rather than to the list.

---------- Forwarded message ---------
From: <[email protected]>
Date: Sat, Jan 27, 2024 at 10:36 AM
Subject: New Defects reported by Coverity Scan for Das U-Boot
To: <[email protected]>

Hi,

Please find the latest report on new defect(s) introduced to Das U-Boot found with Coverity Scan.

1 new defect(s) introduced to Das U-Boot found with Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)

** CID 479279: (TAINTED_SCALAR)

________________________________________________________________________________________________________
*** CID 479279: (TAINTED_SCALAR)
/cmd/smbios.c: 180 in do_smbios()
174 smbios_print_type2((struct smbios_type2 *)pos);
175 break;
176 case 127:
177 smbios_print_type127((struct
smbios_type127 *)pos);
178 break;
179 default:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
    CID 479279:    (TAINTED_SCALAR)
    Passing tainted expression "pos->length" to "smbios_print_generic", which uses it as a loop boundary.

180 smbios_print_generic(pos);
181 break;
182 }
183 }
184
185 return CMD_RET_SUCCESS;
/cmd/smbios.c: 154 in do_smbios()
148 size = entry2->length;
149 max_struct_size = entry2->max_struct_size;
150 } else {
151 log_err("Unknown SMBIOS anchor format\n");
152 return CMD_RET_FAILURE;
153 }

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CID 479279: (TAINTED_SCALAR)
Passing tainted expression "size" to "table_compute_checksum", which uses it as a loop boundary.

154 if (table_compute_checksum(entry, size)) {
155 log_err("Invalid anchor checksum\n");
156 return CMD_RET_FAILURE;
157 }
158 printf("SMBIOS %s present.\n", version);
159
/cmd/smbios.c: 174 in do_smbios()
168 (unsigned long long)map_to_sysmem(pos));
169 switch (pos->type) {
170 case 1:
171 smbios_print_type1((struct smbios_type1 *)pos);
172 break;
173 case 2:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
    CID 479279:    (TAINTED_SCALAR)
    Passing tainted expression "((struct smbios_type2 *)pos)->number_contained_objects" to "smbios_print_type2", which uses it as a loop boundary.

174 smbios_print_type2((struct smbios_type2 *)pos);
175 break;
176 case 127:
177 smbios_print_type127((struct
smbios_type127 *)pos);
178 break;
179 default:
/cmd/smbios.c: 154 in do_smbios()
148 size = entry2->length;
149 max_struct_size = entry2->max_struct_size;
150 } else {
151 log_err("Unknown SMBIOS anchor format\n");
152 return CMD_RET_FAILURE;
153 }

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CID 479279: (TAINTED_SCALAR)
Passing tainted expression "size" to "table_compute_checksum", which uses it as a loop boundary.

154 if (table_compute_checksum(entry, size)) {
155 log_err("Invalid anchor checksum\n");
156 return CMD_RET_FAILURE;
157 }
158 printf("SMBIOS %s present.\n", version);
159
/cmd/smbios.c: 180 in do_smbios()
174 smbios_print_type2((struct smbios_type2 *)pos);
175 break;
176 case 127:
177 smbios_print_type127((struct
smbios_type127 *)pos);
178 break;
179 default:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
    CID 479279:    (TAINTED_SCALAR)
    Passing tainted expression "pos->length" to "smbios_print_generic", which uses it as a loop boundary.

180 smbios_print_generic(pos);
181 break;
182 }
183 }
184
185 return CMD_RET_SUCCESS;
/cmd/smbios.c: 174 in do_smbios()
168 (unsigned long long)map_to_sysmem(pos));
169 switch (pos->type) {
170 case 1:
171 smbios_print_type1((struct smbios_type1 *)pos);
172 break;
173 case 2:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
    CID 479279:    (TAINTED_SCALAR)
    Passing tainted expression "((struct smbios_type2 *)pos)->number_contained_objects" to "smbios_print_type2", which uses it as a loop boundary.

174 smbios_print_type2((struct smbios_type2 *)pos);
175 break;
176 case 127:
177 smbios_print_type127((struct
smbios_type127 *)pos);
178 break;
179 default:
/cmd/smbios.c: 174 in do_smbios()
168 (unsigned long long)map_to_sysmem(pos));
169 switch (pos->type) {
170 case 1:
171 smbios_print_type1((struct smbios_type1 *)pos);
172 break;
173 case 2:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
    CID 479279:    (TAINTED_SCALAR)
    Passing tainted expression "((struct smbios_type2 *)pos)->number_contained_objects" to "smbios_print_type2", which uses it as a loop boundary.

174 smbios_print_type2((struct smbios_type2 *)pos);
175 break;
176 case 127:
177 smbios_print_type127((struct
smbios_type127 *)pos);
178 break;
179 default:
/cmd/smbios.c: 180 in do_smbios()
174 smbios_print_type2((struct smbios_type2 *)pos);
175 break;
176 case 127:
177 smbios_print_type127((struct
smbios_type127 *)pos);
178 break;
179 default:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
    CID 479279:    (TAINTED_SCALAR)
    Passing tainted expression "pos->length" to "smbios_print_generic", which uses it as a loop boundary.

180 smbios_print_generic(pos);
181 break;
182 }
183 }
184
185 return CMD_RET_SUCCESS;
/cmd/smbios.c: 180 in do_smbios()
174 smbios_print_type2((struct smbios_type2 *)pos);
175 break;
176 case 127:
177 smbios_print_type127((struct
smbios_type127 *)pos);
178 break;
179 default:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
    CID 479279:    (TAINTED_SCALAR)
    Passing tainted expression "pos->length" to "smbios_print_generic", which uses it as a loop boundary.

180 smbios_print_generic(pos);
181 break;
182 }
183 }
184
185 return CMD_RET_SUCCESS;
/cmd/smbios.c: 174 in do_smbios()
168 (unsigned long long)map_to_sysmem(pos));
169 switch (pos->type) {
170 case 1:
171 smbios_print_type1((struct smbios_type1 *)pos);
172 break;
173 case 2:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
    CID 479279:    (TAINTED_SCALAR)
    Passing tainted expression "((struct smbios_type2 *)pos)->number_contained_objects" to "smbios_print_type2", which uses it as a loop boundary.

174 smbios_print_type2((struct smbios_type2 *)pos);
175 break;
176 case 127:
177 smbios_print_type127((struct
smbios_type127 *)pos);
178 break;
179 default:
/cmd/smbios.c: 180 in do_smbios()
174 smbios_print_type2((struct smbios_type2 *)pos);
175 break;
176 case 127:
177 smbios_print_type127((struct
smbios_type127 *)pos);
178 break;
179 default:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
    CID 479279:    (TAINTED_SCALAR)
    Passing tainted expression "pos->length" to "smbios_print_generic", which uses it as a loop boundary.

180 smbios_print_generic(pos);
181 break;
182 }
183 }
184
185 return CMD_RET_SUCCESS;
/cmd/smbios.c: 174 in do_smbios()
168 (unsigned long long)map_to_sysmem(pos));
169 switch (pos->type) {
170 case 1:
171 smbios_print_type1((struct smbios_type1 *)pos);
172 break;
173 case 2:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
    CID 479279:    (TAINTED_SCALAR)
    Passing tainted expression "((struct smbios_type2 *)pos)->number_contained_objects" to "smbios_print_type2", which uses it as a loop boundary.
Quoted 8 lines

174 smbios_print_type2((struct smbios_type2 *)pos);
175 break;
176 case 127:
177 smbios_print_type127((struct
smbios_type127 *)pos);
178 break;
179 default:

The values may come from QEMU, so may be "tainted". We could check the length of the individual structures against the total size of the SMBIOS table.

Best regards

Heinrich

#2 lore raw
Quoted 221 lines · Heinrich Schuchardt

Am 27. Januar 2024 16:40:18 MEZ schrieb Tom Rini <[email protected]>:

Quoted 209 lines

Hey, I'll just pass this on directly rather than to the list.

---------- Forwarded message ---------
From: <[email protected]>
Date: Sat, Jan 27, 2024 at 10:36 AM
Subject: New Defects reported by Coverity Scan for Das U-Boot
To: <[email protected]>

Hi,

Please find the latest report on new defect(s) introduced to Das U-Boot found with Coverity Scan.

1 new defect(s) introduced to Das U-Boot found with Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)

** CID 479279: (TAINTED_SCALAR)

________________________________________________________________________________________________________
*** CID 479279: (TAINTED_SCALAR)
/cmd/smbios.c: 180 in do_smbios()
174 smbios_print_type2((struct smbios_type2 *)pos);
175 break;
176 case 127:
177 smbios_print_type127((struct
smbios_type127 *)pos);
178 break;
179 default:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
     CID 479279:    (TAINTED_SCALAR)
     Passing tainted expression "pos->length" to "smbios_print_generic", which uses it as a loop boundary.

180 smbios_print_generic(pos);
181 break;
182 }
183 }
184
185 return CMD_RET_SUCCESS;
/cmd/smbios.c: 154 in do_smbios()
148 size = entry2->length;
149 max_struct_size = entry2->max_struct_size;
150 } else {
151 log_err("Unknown SMBIOS anchor format\n");
152 return CMD_RET_FAILURE;
153 }

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CID 479279: (TAINTED_SCALAR)
Passing tainted expression "size" to "table_compute_checksum", which uses it as a loop boundary.

154 if (table_compute_checksum(entry, size)) {
155 log_err("Invalid anchor checksum\n");
156 return CMD_RET_FAILURE;
157 }
158 printf("SMBIOS %s present.\n", version);
159
/cmd/smbios.c: 174 in do_smbios()
168 (unsigned long long)map_to_sysmem(pos));
169 switch (pos->type) {
170 case 1:
171 smbios_print_type1((struct smbios_type1 *)pos);
172 break;
173 case 2:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
     CID 479279:    (TAINTED_SCALAR)
     Passing tainted expression "((struct smbios_type2 *)pos)->number_contained_objects" to "smbios_print_type2", which uses it as a loop boundary.

174 smbios_print_type2((struct smbios_type2 *)pos);
175 break;
176 case 127:
177 smbios_print_type127((struct
smbios_type127 *)pos);
178 break;
179 default:
/cmd/smbios.c: 154 in do_smbios()
148 size = entry2->length;
149 max_struct_size = entry2->max_struct_size;
150 } else {
151 log_err("Unknown SMBIOS anchor format\n");
152 return CMD_RET_FAILURE;
153 }

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CID 479279: (TAINTED_SCALAR)
Passing tainted expression "size" to "table_compute_checksum", which uses it as a loop boundary.

154 if (table_compute_checksum(entry, size)) {
155 log_err("Invalid anchor checksum\n");
156 return CMD_RET_FAILURE;
157 }
158 printf("SMBIOS %s present.\n", version);
159
/cmd/smbios.c: 180 in do_smbios()
174 smbios_print_type2((struct smbios_type2 *)pos);
175 break;
176 case 127:
177 smbios_print_type127((struct
smbios_type127 *)pos);
178 break;
179 default:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
     CID 479279:    (TAINTED_SCALAR)
     Passing tainted expression "pos->length" to "smbios_print_generic", which uses it as a loop boundary.

180 smbios_print_generic(pos);
181 break;
182 }
183 }
184
185 return CMD_RET_SUCCESS;
/cmd/smbios.c: 174 in do_smbios()
168 (unsigned long long)map_to_sysmem(pos));
169 switch (pos->type) {
170 case 1:
171 smbios_print_type1((struct smbios_type1 *)pos);
172 break;
173 case 2:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
     CID 479279:    (TAINTED_SCALAR)
     Passing tainted expression "((struct smbios_type2 *)pos)->number_contained_objects" to "smbios_print_type2", which uses it as a loop boundary.

174 smbios_print_type2((struct smbios_type2 *)pos);
175 break;
176 case 127:
177 smbios_print_type127((struct
smbios_type127 *)pos);
178 break;
179 default:
/cmd/smbios.c: 174 in do_smbios()
168 (unsigned long long)map_to_sysmem(pos));
169 switch (pos->type) {
170 case 1:
171 smbios_print_type1((struct smbios_type1 *)pos);
172 break;
173 case 2:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
     CID 479279:    (TAINTED_SCALAR)
     Passing tainted expression "((struct smbios_type2 *)pos)->number_contained_objects" to "smbios_print_type2", which uses it as a loop boundary.

174 smbios_print_type2((struct smbios_type2 *)pos);
175 break;
176 case 127:
177 smbios_print_type127((struct
smbios_type127 *)pos);
178 break;
179 default:
/cmd/smbios.c: 180 in do_smbios()
174 smbios_print_type2((struct smbios_type2 *)pos);
175 break;
176 case 127:
177 smbios_print_type127((struct
smbios_type127 *)pos);
178 break;
179 default:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
     CID 479279:    (TAINTED_SCALAR)
     Passing tainted expression "pos->length" to "smbios_print_generic", which uses it as a loop boundary.

180 smbios_print_generic(pos);
181 break;
182 }
183 }
184
185 return CMD_RET_SUCCESS;
/cmd/smbios.c: 180 in do_smbios()
174 smbios_print_type2((struct smbios_type2 *)pos);
175 break;
176 case 127:
177 smbios_print_type127((struct
smbios_type127 *)pos);
178 break;
179 default:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
     CID 479279:    (TAINTED_SCALAR)
     Passing tainted expression "pos->length" to "smbios_print_generic", which uses it as a loop boundary.

180 smbios_print_generic(pos);
181 break;
182 }
183 }
184
185 return CMD_RET_SUCCESS;
/cmd/smbios.c: 174 in do_smbios()
168 (unsigned long long)map_to_sysmem(pos));
169 switch (pos->type) {
170 case 1:
171 smbios_print_type1((struct smbios_type1 *)pos);
172 break;
173 case 2:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
     CID 479279:    (TAINTED_SCALAR)
     Passing tainted expression "((struct smbios_type2 *)pos)->number_contained_objects" to "smbios_print_type2", which uses it as a loop boundary.

174 smbios_print_type2((struct smbios_type2 *)pos);
175 break;
176 case 127:
177 smbios_print_type127((struct
smbios_type127 *)pos);
178 break;
179 default:
/cmd/smbios.c: 180 in do_smbios()
174 smbios_print_type2((struct smbios_type2 *)pos);
175 break;
176 case 127:
177 smbios_print_type127((struct
smbios_type127 *)pos);
178 break;
179 default:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
     CID 479279:    (TAINTED_SCALAR)
     Passing tainted expression "pos->length" to "smbios_print_generic", which uses it as a loop boundary.

180 smbios_print_generic(pos);
181 break;
182 }
183 }
184
185 return CMD_RET_SUCCESS;
/cmd/smbios.c: 174 in do_smbios()
168 (unsigned long long)map_to_sysmem(pos));
169 switch (pos->type) {
170 case 1:
171 smbios_print_type1((struct smbios_type1 *)pos);
172 break;
173 case 2:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
     CID 479279:    (TAINTED_SCALAR)
     Passing tainted expression "((struct smbios_type2 *)pos)->number_contained_objects" to "smbios_print_type2", which uses it as a loop boundary.
Quoted 8 lines

174 smbios_print_type2((struct smbios_type2 *)pos);
175 break;
176 case 127:
177 smbios_print_type127((struct
smbios_type127 *)pos);
178 break;
179 default:

Quoted 2 lines

The values may come from QEMU, so may be "tainted". We could check the length of the individual structures against the total size of the SMBIOS table.

In Coverity I marked this as false positive with the following comment:

"The only case in which the data is tainted is when copying the smbios table from a prior firmware state when running as EFI app or from QEMU. Sanity checks should not be in the smbios command but where we import the table."

Best regards

Heinrich