[IPSEC]: Avoid undefined shift operation when testing algorithm ID
commit0c0b10ef376c7b320197160f21d6c626ab0a6f4d
authorHerbert Xu <herbert@gondor.apana.org.au>
Tue, 15 Jan 2008 21:29:47 +0000 (15 23:29 +0200)
committerAdrian Bunk <bunk@kernel.org>
Tue, 15 Jan 2008 23:48:14 +0000 (16 01:48 +0200)
tree933437942d1c789f59452a481d53b477330fd735
parent0b9ad3cb150e0fa7bb559e6664fb6c9458c3fd24
[IPSEC]: Avoid undefined shift operation when testing algorithm ID

[ Upstream commit: f398035f2dec0a6150833b0bc105057953594edb ]

The aalgos/ealgos fields are only 32 bits wide.  However, af_key tries
to test them with the expression 1 << id where id can be as large as
253.  This produces different behaviour on different architectures.

The following patch explicitly checks whether ID is greater than 31
and fails the check if that's the case.

We cannot easily extend the mask to be longer than 32 bits due to
exposure to user-space.  Besides, this whole interface is obsolete
anyway in favour of the xfrm_user interface which doesn't use this
bit mask in templates (well not within the kernel anyway).

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Adrian Bunk <bunk@kernel.org>
net/key/af_key.c