mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
cipso: fix total option length computation
[ Upstream commit 9f36169912331fa035d7b73a91252d7c2512eb1a ]
As evident from the definition of ip_options_get(), the IP option
IPOPT_END is used to pad the IP option data array, not IPOPT_NOP. Yet
the loop that walks the IP options to determine the total IP options
length in cipso_v4_delopt() doesn't take IPOPT_END into account.
Fix it by recognizing the IPOPT_END value as the end of actual options.
Fixes: 014ab19a69
("selinux: Set socket NetLabel based on connection endpoint")
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
23a52ca69c
commit
08fa10b265
1 changed files with 8 additions and 4 deletions
|
@ -2015,12 +2015,16 @@ static int cipso_v4_delopt(struct ip_options_rcu __rcu **opt_ptr)
|
|||
* from there we can determine the new total option length */
|
||||
iter = 0;
|
||||
optlen_new = 0;
|
||||
while (iter < opt->opt.optlen)
|
||||
if (opt->opt.__data[iter] != IPOPT_NOP) {
|
||||
while (iter < opt->opt.optlen) {
|
||||
if (opt->opt.__data[iter] == IPOPT_END) {
|
||||
break;
|
||||
} else if (opt->opt.__data[iter] == IPOPT_NOP) {
|
||||
iter++;
|
||||
} else {
|
||||
iter += opt->opt.__data[iter + 1];
|
||||
optlen_new = iter;
|
||||
} else
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
hdr_delta = opt->opt.optlen;
|
||||
opt->opt.optlen = (optlen_new + 3) & ~3;
|
||||
hdr_delta -= opt->opt.optlen;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue