Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ppp: mppe: sanity error path rework

We are going to need sanity error path a little further, rework to be
able to use the sanity error path anywhere in decompressor.

Signed-off-by: Sylvain Rochet <sylvain.rochet@finsecur.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Sylvain Rochet and committed by
David S. Miller
32530189 73b5a6f2

+13 -16
+13 -16
drivers/net/ppp/ppp_mppe.c
··· 478 478 struct blkcipher_desc desc = { .tfm = state->arc4 }; 479 479 unsigned ccount; 480 480 int flushed = MPPE_BITS(ibuf) & MPPE_BIT_FLUSHED; 481 - int sanity = 0; 482 481 struct scatterlist sg_in[1], sg_out[1]; 483 482 484 483 if (isize <= PPP_HDRLEN + MPPE_OVHD) { ··· 513 514 "mppe_decompress[%d]: ENCRYPTED bit not set!\n", 514 515 state->unit); 515 516 state->sanity_errors += 100; 516 - sanity = 1; 517 + goto sanity_error; 517 518 } 518 519 if (!state->stateful && !flushed) { 519 520 printk(KERN_DEBUG "mppe_decompress[%d]: FLUSHED bit not set in " 520 521 "stateless mode!\n", state->unit); 521 522 state->sanity_errors += 100; 522 - sanity = 1; 523 + goto sanity_error; 523 524 } 524 525 if (state->stateful && ((ccount & 0xff) == 0xff) && !flushed) { 525 526 printk(KERN_DEBUG "mppe_decompress[%d]: FLUSHED bit not set on " 526 527 "flag packet!\n", state->unit); 527 528 state->sanity_errors += 100; 528 - sanity = 1; 529 - } 530 - 531 - if (sanity) { 532 - if (state->sanity_errors < SANITY_MAX) 533 - return DECOMP_ERROR; 534 - else 535 - /* 536 - * Take LCP down if the peer is sending too many bogons. 537 - * We don't want to do this for a single or just a few 538 - * instances since it could just be due to packet corruption. 539 - */ 540 - return DECOMP_FATALERROR; 529 + goto sanity_error; 541 530 } 542 531 543 532 /* ··· 636 649 state->sanity_errors >>= 1; 637 650 638 651 return osize; 652 + 653 + sanity_error: 654 + if (state->sanity_errors < SANITY_MAX) 655 + return DECOMP_ERROR; 656 + else 657 + /* Take LCP down if the peer is sending too many bogons. 658 + * We don't want to do this for a single or just a few 659 + * instances since it could just be due to packet corruption. 660 + */ 661 + return DECOMP_FATALERROR; 639 662 } 640 663 641 664 /*