linux-mips
[Top] [All Lists]

Re: [PATCH 14/17] MIPS: bpf: Prevent kernel fall over for >=32bit shifts

To: David Laight <David.Laight@ACULAB.COM>, "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>
Subject: Re: [PATCH 14/17] MIPS: bpf: Prevent kernel fall over for >=32bit shifts
From: Markos Chandras <Markos.Chandras@imgtec.com>
Date: Mon, 23 Jun 2014 12:06:15 +0100
Cc: "David S. Miller" <davem@davemloft.net>, Daniel Borkmann <dborkman@redhat.com>, Alexei Starovoitov <ast@plumgrid.com>, "netdev@vger.kernel.org" <netdev@vger.kernel.org>
In-reply-to: <063D6719AE5E284EB5DD2968C1650D6D1726096C@AcuExch.aculab.com>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1403516340-22997-1-git-send-email-markos.chandras@imgtec.com> <1403516340-22997-15-git-send-email-markos.chandras@imgtec.com> <063D6719AE5E284EB5DD2968C1650D6D1726096C@AcuExch.aculab.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
On 06/23/2014 10:44 AM, David Laight wrote:
> From: Markos Chandras
>> Remove BUG_ON() if the shift immediate is >=32 to avoid
>> kernel crashes due to malicious user input. Since the micro-assembler
>> will not allow an immediate greater or equal to 32, we will use the
>> maximum value which is 31. This will do the correct thing on either 32-
>> or 64-bit cores since no 64-bit instructions are being used in JIT.
> 
> I'm not sure that bounding the shift to 31 bits 'is the correct thing'.
> I'd have thought that emulating the large shift or masking the shift
> to 5 bits are equally 'correct'.
> 
> ...
Hi David,

Since we use 32-bit registers (or rather, we ignore the top 32bits on
MIPS64), shifting >= 32 will always result to 0.
Alexei suggested [1] to allow large shifts and emulate them, so this
patch aims to do that by treating >=32 shift values as 31. Please tell
me if I got this wrong.

[1] http://www.linux-mips.org/archives/linux-mips/2014-06/msg00212.html


-- 
markos

<Prev in Thread] Current Thread [Next in Thread>