Commit 0c61227094b3ddaca2f847ee287c4a2e3762b5a2

Authored by Gleb Natapov
Committed by H. Peter Anvin
1 parent 8e10cd7434

x86, setup: Fix EDD3.0 data verification.

Check for nonzero path in edd_has_edd30() has no sense. First, it looks
at the wrong memory. Device path starts at offset 30 of the info->params
structure which is at offset 8 from the beginning of info structure,
but code looks at info + 4 instead. This was correct when code was
introduced, but around v2.6.4 three more fields were added to edd_info
structure (commit 66b61a5c in history.git). Second, even if it will check
correct memory it will always succeed since at offset 30 (params->key)
there will be non-zero values otherwise previous check would fail.

The patch replaces this bogus check with one that verifies checksum.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Link: http://lkml.kernel.org/r/20110426082132.GG2265@redhat.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>

Showing 1 changed file with 11 additions and 11 deletions Side-by-side Diff

drivers/firmware/edd.c
... ... @@ -531,8 +531,8 @@
531 531 edd_has_edd30(struct edd_device *edev)
532 532 {
533 533 struct edd_info *info;
534   - int i, nonzero_path = 0;
535   - char c;
  534 + int i;
  535 + u8 csum = 0;
536 536  
537 537 if (!edev)
538 538 return 0;
539 539  
... ... @@ -544,16 +544,16 @@
544 544 return 0;
545 545 }
546 546  
547   - for (i = 30; i <= 73; i++) {
548   - c = *(((uint8_t *) info) + i + 4);
549   - if (c) {
550   - nonzero_path++;
551   - break;
552   - }
553   - }
554   - if (!nonzero_path) {
  547 +
  548 + /* We support only T13 spec */
  549 + if (info->params.device_path_info_length != 44)
555 550 return 0;
556   - }
  551 +
  552 + for (i = 30; i < info->params.device_path_info_length + 30; i++)
  553 + csum += *(((u8 *)&info->params) + i);
  554 +
  555 + if (csum)
  556 + return 0;
557 557  
558 558 return 1;
559 559 }