From: Eric Biggers <ebiggers(a)google.com>
Changing ghash_mod_init() to be subsys_initcall made it start running
before the alignment fault handler has been installed on ARM. In kernel
builds where the keys in the ghash test vectors happened to be
misaligned in the kernel image, this exposed the longstanding bug that
ghash_setkey() is incorrectly casting the key buffer (which can have any
alignment) to be128 for passing to gf128mul_init_4k_lle().
Fix this by memcpy()ing the key to a temporary buffer.
Don't fix it by setting an alignmask on the algorithm instead because
that would unnecessarily force alignment of the data too.
Fixes: 2cdc6899a88e ("crypto: ghash - Add GHASH digest algorithm for GCM")
Reported-by: Peter Robinson <pbrobinson(a)gmail.com>
Cc: stable(a)vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers(a)google.com>
---
crypto/ghash-generic.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/crypto/ghash-generic.c b/crypto/ghash-generic.c
index e6307935413c1..c8a347798eae6 100644
--- a/crypto/ghash-generic.c
+++ b/crypto/ghash-generic.c
@@ -34,6 +34,7 @@ static int ghash_setkey(struct crypto_shash *tfm,
const u8 *key, unsigned int keylen)
{
struct ghash_ctx *ctx = crypto_shash_ctx(tfm);
+ be128 k;
if (keylen != GHASH_BLOCK_SIZE) {
crypto_shash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
@@ -42,7 +43,12 @@ static int ghash_setkey(struct crypto_shash *tfm,
if (ctx->gf128)
gf128mul_free_4k(ctx->gf128);
- ctx->gf128 = gf128mul_init_4k_lle((be128 *)key);
+
+ BUILD_BUG_ON(sizeof(k) != GHASH_BLOCK_SIZE);
+ memcpy(&k, key, GHASH_BLOCK_SIZE); /* avoid violating alignment rules */
+ ctx->gf128 = gf128mul_init_4k_lle(&k);
+ memzero_explicit(&k, GHASH_BLOCK_SIZE);
+
if (!ctx->gf128)
return -ENOMEM;
--
2.22.0.rc1.257.g3120a18244-goog
The sha256-ce finup implementation for ARM64 produces wrong digest
for empty input (len=0). Expected: the actual digest, result: initial
value of SHA internal state. The error is in sha256_ce_finup:
for empty data `finalize` will be 1, so the code is relying on
sha2_ce_transform to make the final round. However, in
sha256_base_do_update, the block function will not be called when
len == 0.
Fix it by setting finalize to 0 if data is empty.
Fixes: 03802f6a80b3a ("crypto: arm64/sha2-ce - move SHA-224/256 ARMv8 implementation to base layer")
Cc: stable(a)vger.kernel.org
Signed-off-by: Elena Petrova <lenaptr(a)google.com>
---
arch/arm64/crypto/sha2-ce-glue.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/crypto/sha2-ce-glue.c b/arch/arm64/crypto/sha2-ce-glue.c
index a725997e55f2..6a5ade974a35 100644
--- a/arch/arm64/crypto/sha2-ce-glue.c
+++ b/arch/arm64/crypto/sha2-ce-glue.c
@@ -60,7 +60,7 @@ static int sha256_ce_finup(struct shash_desc *desc, const u8 *data,
unsigned int len, u8 *out)
{
struct sha256_ce_state *sctx = shash_desc_ctx(desc);
- bool finalize = !sctx->sst.count && !(len % SHA256_BLOCK_SIZE);
+ bool finalize = !sctx->sst.count && !(len % SHA256_BLOCK_SIZE) && len;
if (!crypto_simd_usable()) {
if (len)
--
2.22.0.rc1.257.g3120a18244-goog
The sha1-ce finup implementation for ARM64 produces wrong digest
for empty input (len=0). Expected: da39a3ee..., result: 67452301...
(initial value of SHA internal state). The error is in sha1_ce_finup:
for empty data `finalize` will be 1, so the code is relying on
sha1_ce_transform to make the final round. However, in
sha1_base_do_update, the block function will not be called when
len == 0.
Fix it by setting finalize to 0 if data is empty.
Fixes: 07eb54d306f4 ("crypto: arm64/sha1-ce - move SHA-1 ARMv8 implementation to base layer")
Cc: stable(a)vger.kernel.org
Signed-off-by: Elena Petrova <lenaptr(a)google.com>
---
arch/arm64/crypto/sha1-ce-glue.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/crypto/sha1-ce-glue.c b/arch/arm64/crypto/sha1-ce-glue.c
index eaa7a8258f1c..0652f5f07ed1 100644
--- a/arch/arm64/crypto/sha1-ce-glue.c
+++ b/arch/arm64/crypto/sha1-ce-glue.c
@@ -55,7 +55,7 @@ static int sha1_ce_finup(struct shash_desc *desc, const u8 *data,
unsigned int len, u8 *out)
{
struct sha1_ce_state *sctx = shash_desc_ctx(desc);
- bool finalize = !sctx->sst.count && !(len % SHA1_BLOCK_SIZE);
+ bool finalize = !sctx->sst.count && !(len % SHA1_BLOCK_SIZE) && len;
if (!crypto_simd_usable())
return crypto_sha1_finup(desc, data, len, out);
--
2.22.0.rc1.257.g3120a18244-goog
Greg,
I'm really confused. [1] was my submittal to stable for "binder: fix
race between munmap() and direct reclaim" which I think looks correct.
For "binder: fix handling of misaligned binder object", I only
submitted to LKML [2]. But then I see [3] for 4.14 (that looks
incorrect as Ben pointed out).
So the result is that fix is present in the LTS trees where it is
needed, but it has the wrong commit message and headline.
I agree with Ben that the cleanest approach is to revert and apply the
correct version (to 4.14, 4.19, 5.0). I think the correct version is
the one I sent [1], but please let me know if you see something I
screwed up or if you need me to do something.
[1] https://www.spinics.net/lists/stable/msg299033.html
[2] https://lkml.org/lkml/2019/2/14/1235
[3] https://lkml.org/lkml/2019/4/30/650
-Todd
On Tue, May 28, 2019 at 9:34 AM Todd Kjos <tkjos(a)google.com> wrote:
>
> Probably my screw-up. I was working on both of those bug fixes at about the same time. I'll investigate what happened.
>
> On Mon, May 27, 2019 at 11:51 PM Greg Kroah-Hartman <gregkh(a)linuxfoundation.org> wrote:
>>
>> On Mon, May 27, 2019 at 10:09:32PM +0100, Ben Hutchings wrote:
>> > There are commits in the 4.14, 4.19 and 5.0 stable branches that claim
>> > to be backports of:
>> >
>> > commit 26528be6720bb40bc8844e97ee73a37e530e9c5e
>> > Author: Todd Kjos <tkjos(a)android.com>
>> > Date: Thu Feb 14 15:22:57 2019 -0800
>> >
>> > binder: fix handling of misaligned binder object
>> >
>> > However the source changes actually match:
>> >
>> > commit 5cec2d2e5839f9c0fec319c523a911e0a7fd299f
>> > Author: Todd Kjos <tkjos(a)android.com>
>> > Date: Fri Mar 1 15:06:06 2019 -0800
>> >
>> > binder: fix race between munmap() and direct reclaim
>> >
>> > So far as I can see, the former fixes a bug only introduced in 5.1 and
>> > the latter fixes an older bug, so the changes are correct and only the
>> > metadata is not.
>> >
>> > Similar mix-ups have happened before and I'm a little disturbed that
>> > this keeps happening. In any case, you may want to revert and re-apply
>> > with correct metadata.
>>
>> Note, these backports came directly from Todd, so he can provide more
>> information about them. Todd, did something get messed up on your end
>> and do we need to include another patch to fix this up?
>>
>> thanks,
>>
>> greg k-h
Prior to this commit we fail to init the DSI panel on the GPD MicroPC:
https://www.indiegogo.com/projects/gpd-micropc-6-inch-handheld-industry-lap…
The problem is intel_dsi_vbt_init() failing with the following error:
*ERROR* Burst mode freq is less than computed
The pclk in the VBT panel modeline is 70000, together with 24 bpp and
4 lines this results in a bitrate value of 70000 * 24 / 4 = 420000.
But the target_burst_mode_freq in the VBT is 418000.
This commit works around this problem by adding an intel_fuzzy_clock_check
when target_burst_mode_freq < bitrate and setting target_burst_mode_freq to
bitrate when that checks succeeds, fixing the panel not working.
Cc: stable(a)vger.kernel.org
Signed-off-by: Hans de Goede <hdegoede(a)redhat.com>
---
drivers/gpu/drm/i915/intel_dsi_vbt.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/gpu/drm/i915/intel_dsi_vbt.c b/drivers/gpu/drm/i915/intel_dsi_vbt.c
index 022bf59418df..a2a9b9d0eeaa 100644
--- a/drivers/gpu/drm/i915/intel_dsi_vbt.c
+++ b/drivers/gpu/drm/i915/intel_dsi_vbt.c
@@ -895,6 +895,17 @@ bool intel_dsi_vbt_init(struct intel_dsi *intel_dsi, u16 panel_id)
if (mipi_config->target_burst_mode_freq) {
u32 bitrate = intel_dsi_bitrate(intel_dsi);
+ /*
+ * Sometimes the VBT contains a slightly lower clock,
+ * then the bitrate we have calculated, in this case
+ * just replace it with the calculated bitrate.
+ */
+ if (mipi_config->target_burst_mode_freq < bitrate &&
+ intel_fuzzy_clock_check(
+ mipi_config->target_burst_mode_freq,
+ bitrate))
+ mipi_config->target_burst_mode_freq = bitrate;
+
if (mipi_config->target_burst_mode_freq < bitrate) {
DRM_ERROR("Burst mode freq is less than computed\n");
return false;
--
2.21.0
I've attached the following fixes to 4.4, as an mbox:
- binder: Replace "%p" with "%pK" for stable
- binder: replace "%p" with "%pK"
- net: create skb_gso_validate_mac_len()
- bnx2x: disable GSO where gso_size is too big for hardware
- brcmfmac: Add length checks on firmware events
- brcmfmac: screening firmware event packet
- brcmfmac: revise handling events in receive path
- brcmfmac: fix incorrect event channel deduction
- brcmfmac: add length checks in scheduled scan result handler
- brcmfmac: add subtype check for event handling in data path
- userfaultfd: don't pin the user memory in userfaultfd_file_create()
- coredump: fix race condition between mmget_not_zero()/get_task_mm() and core dumping
The userfaultfd commit might not be a security fix but the next one
depends on it.
Ben.
--
Ben Hutchings, Software Developer Codethink Ltd
https://www.codethink.co.uk/ Dale House, 35 Dale Street
Manchester, M1 2HF, United Kingdom
I've attached the following fixes to 4.9, as an mbox:
- brcmfmac: add length checks in scheduled scan result handler
- brcmfmac: assure SSID length from firmware is limited
- brcmfmac: add subtype check for event handling in data path
- binder: Replace "%p" with "%pK" for stable
- binder: replace "%p" with "%pK"
- fs: prevent page refcount overflow in pipe_buf_get
- mm, gup: remove broken VM_BUG_ON_PAGE compound check for hugepages
- mm, gup: ensure real head page is ref-counted when using hugepages
- mm: prevent get_user_pages() from overflowing page refcount
- mm: make page ref count overflow check tighter and more explicit
- coredump: fix race condition between mmget_not_zero()/get_task_mm() and core dumping
The first two "mm, gup" commits might not be strictly security fixes
but the next one depends on them.
Ben.
--
Ben Hutchings, Software Developer Codethink Ltd
https://www.codethink.co.uk/ Dale House, 35 Dale Street
Manchester, M1 2HF, United Kingdom
While this backport proposal is based on the 4.4.y stable tree, it
might also apply in some form to any stable tree which backported
05c0b86b96: "ipv6: frags: rewrite ip6_expire_frag_queue()"
While this made ip6_expire_frag_queue() similar to ip_exire(),
it did not follow the additional changes to ip_expire() which
were also backported:
fa0f527358: "ip: use rb trees for IP frag queue."
a4fd284a1f: "ip: process in-order fragments efficiently"
The former of the two not only adds handling for rb trees, but
also modifies ip_expire() to take the first skb off the queue
before using it for the sending the icmp message. This also got
rid of the need to protect the skb by incrementing its reference
count (which is the reason for the crash in ip6_expire_frag_queue()).
My first approach was do those changes in ip6_expire_frag_queue(),
but only the former of the two can be done without problems. The
latter uses code which is only locally defined in ipv4/ip_fragment.c.
This was changed upstream in 5.1 when moving code around to be shared
c23f35d19d: "net: IP defrag: encapsulate rbtree defrag code into
callable functions"
And while backporting that I found the two other changes which sounded
like one might want them backported, too. Maybe even more since the
second (ip: fail fast on IP defrag errors) is already partially
included in the backport of "net: ipv4: do not handle duplicate
fragments as overlapping".
Though I do realize that "net: IP defrag: encapsulate rbtree
defrag code into callable functions" is rather large and for
that reason maybe not qualifying as a stable backport.
So I would like to ask what the net-developers think about
this.
Thanks,
Stefan
0001: v4.20: ipv4: ipv6: netfilter: Adjust the frag mem limit when
truesize changes
0002: v4.20: ip: fail fast on IP defrag errors
0003: v5.1 : net: IP defrag: encapsulate rbtree defrag code into
callable functions
0004: n/a : ipv6: frags: Use inet_frag_pull_head() in
ip6_expire_frag_queue()
Jiri Wiesner (1):
ipv4: ipv6: netfilter: Adjust the frag mem limit when truesize changes
Peter Oskolkov (2):
ip: fail fast on IP defrag errors
net: IP defrag: encapsulate rbtree defrag code into callable functions
Stefan Bader (1):
ipv6: frags: Use inet_frag_pull_head() in ip6_expire_frag_queue()
include/net/inet_frag.h | 16 +-
net/ipv4/inet_fragment.c | 293 +++++++++++++++++++++++
net/ipv4/ip_fragment.c | 294 +++---------------------
net/ipv6/netfilter/nf_conntrack_reasm.c | 8 +-
net/ipv6/reassembly.c | 20 +-
5 files changed, 359 insertions(+), 272 deletions(-)
--
2.17.1