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
To print the pathname that will be used by shell in the current
environment, 'command -v' is a standardized way. [1]
'which' is also often used in scripts, but it is less portable.
When I worked on commit bd55f96fa9fc ("kbuild: refactor cc-cross-prefix
implementation"), I was eager to use 'command -v' but it did not work.
(The reason is explained below.)
I kept 'which' as before but got rid of '> /dev/null 2>&1' as I
thought it was no longer needed. Sorry, I was wrong.
It works well on my Ubuntu machine, but Alexey Brodkin reports noisy
warnings on CentOS7 when 'which' fails to find the given command in
the PATH environment.
$ which foo
which: no foo in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
Given that behavior of 'which' depends on system (and it may not be
installed by default), I want to try 'command -v' once again.
The specification [1] clearly describes the behavior of 'command -v'
when the given command is not found:
Otherwise, no output shall be written and the exit status shall reflect
that the name was not found.
However, we need a little magic to use 'command -v' from Make.
$(shell ...) passes the argument to a subshell for execution, and
returns the standard output of the command.
Here is a trick. GNU Make may optimize this by executing the command
directly instead of forking a subshell, if no shell special characters
are found in the command and omitting the subshell will not change the
behavior.
In this case, no shell special character is used. So, Make will try
to run it directly. However, 'command' is a shell-builtin command,
then Make would fail to find it in the PATH environment:
$ make ARCH=m68k defconfig
make: command: Command not found
make: command: Command not found
make: command: Command not found
In fact, Make has a table of shell-builtin commands because it must
ask the shell to execute them.
Until recently, 'command' was missing in the table.
This issue was fixed by the following commit:
| commit 1af314465e5dfe3e8baa839a32a72e83c04f26ef
| Author: Paul Smith <psmith(a)gnu.org>
| Date: Sun Nov 12 18:10:28 2017 -0500
|
| * job.c: Add "command" as a known shell built-in.
|
| This is not a POSIX shell built-in but it's common in UNIX shells.
| Reported by Nick Bowler <nbowler(a)draconx.ca>.
Because the latest release is GNU Make 4.2.1 in 2016, this commit is
not included in any released versions. (But some distributions may
have back-ported it.)
We need to trick Make to spawn a subshell. There are various ways to
do so:
1) Use a shell special character '~' as dummy
$(shell : ~; command -v $(c)gcc)
2) Use a variable reference, which always expands to the empty string
(suggested by David Laight)
$(shell command$${x:+} -v $(c)gcc)
3) Use redirect
$(shell command -v $(c)gcc 2>/dev/null)
I chose 3) to not confuse people. The stderr would not be polluted
anyway, but it will provide extra safety, and is easy to understand.
Tested on Make 3.81, 3.82, 4.0, 4.1, 4.2, 4.2.1
[1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html
Fixes: bd55f96fa9fc ("kbuild: refactor cc-cross-prefix implementation")
Cc: linux-stable <stable(a)vger.kernel.org> # 5.1
Reported-by: Alexey Brodkin <abrodkin(a)synopsys.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro(a)socionext.com>
Tested-by: Alexey Brodkin <abrodkin(a)synopsys.com>
---
Changes in v2:
- Use dummy redirect
scripts/Kbuild.include | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 85d758233483..fd8aa314c156 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -74,8 +74,11 @@ endef
# Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-)
# Return first <prefix> where a <prefix>gcc is found in PATH.
# If no gcc found in PATH with listed prefixes return nothing
+#
+# Note: 2>/dev/null is here to force Make to invoke a shell. This workaround
+# is needed because this issue was only fixed after GNU Make 4.2.1 release.
cc-cross-prefix = $(firstword $(foreach c, $(filter-out -%, $(1)), \
- $(if $(shell which $(c)gcc), $(c))))
+ $(if $(shell command -v $(c)gcc 2>/dev/null), $(c))))
# output directory for tests below
TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
--
2.17.1
From: Bjørn Mork <bjorn(a)mork.no>
commit 6314dab4b8fb8493d810e175cb340376052c69b6 upstream.
The GetNtbFormat and SetNtbFormat requests operate on 16 bit little
endian values. We get away with ignoring this most of the time, because
we only care about USB_CDC_NCM_NTB16_FORMAT which is 0x0000. This
fails for USB_CDC_NCM_NTB32_FORMAT.
Fix comparison between LE value from device and constant by converting
the constant to LE.
Reported-by: Ben Hutchings <ben.hutchings(a)codethink.co.uk>
Fixes: 2b02c20ce0c2 ("cdc_ncm: Set NTB format again after altsetting switch for Huawei devices")
Cc: Enrico Mioso <mrkiko.rs(a)gmail.com>
Cc: Christian Panton <christian(a)panton.org>
Signed-off-by: Bjørn Mork <bjorn(a)mork.no>
Acked-By: Enrico Mioso <mrkiko.rs(a)gmail.com>
Signed-off-by: David S. Miller <davem(a)davemloft.net>
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu(a)toshiba.co.jp>
---
drivers/net/usb/cdc_ncm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 36e1377fc954..1e921e5eddc7 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -727,7 +727,7 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
int err;
u8 iface_no;
struct usb_cdc_parsed_header hdr;
- u16 curr_ntb_format;
+ __le16 curr_ntb_format;
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
if (!ctx)
@@ -841,7 +841,7 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
goto error2;
}
- if (curr_ntb_format == USB_CDC_NCM_NTB32_FORMAT) {
+ if (curr_ntb_format == cpu_to_le16(USB_CDC_NCM_NTB32_FORMAT)) {
dev_info(&intf->dev, "resetting NTB format to 16-bit");
err = usbnet_write_cmd(dev, USB_CDC_SET_NTB_FORMAT,
USB_TYPE_CLASS | USB_DIR_OUT
--
2.20.1
From: Peter Chen <peter.chen(a)nxp.com>
commit 982555fc26f9d8bcdbd5f9db0378fe0682eb4188 upstream.
For isoc endpoint descriptor, the wMaxPacketSize is not real max packet
size (see Table 9-13. Standard Endpoint Descriptor, USB 2.0 specifcation),
it may contain the number of packet, so the real max packet should be
ep->desc->wMaxPacketSize && 0x7ff.
Cc: Felipe F. Tonello <eu(a)felipetonello.com>
Cc: Felipe Balbi <felipe.balbi(a)linux.intel.com>
Fixes: 16b114a6d797 ("usb: gadget: fix usb_ep_align_maybe
endianness and new usb_ep_align")
Signed-off-by: Peter Chen <peter.chen(a)nxp.com>
Signed-off-by: Felipe Balbi <felipe.balbi(a)linux.intel.com>
[iwamatsu: Fix Fixes tag]
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu(a)toshiba.co.jp>
---
include/linux/usb/gadget.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 7e84aac39ade..667e7f9fd877 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -671,7 +671,9 @@ static inline struct usb_gadget *dev_to_usb_gadget(struct device *dev)
*/
static inline size_t usb_ep_align(struct usb_ep *ep, size_t len)
{
- return round_up(len, (size_t)le16_to_cpu(ep->desc->wMaxPacketSize));
+ int max_packet_size = (size_t)usb_endpoint_maxp(ep->desc) & 0x7ff;
+
+ return round_up(len, max_packet_size);
}
/**
--
2.20.1
Hi Linus,
Please pull these pstore fixes for v5.2-rc4. They've been in linux-next
for a bit now and catch some pstore corner cases found recently.
Thanks!
-Kees
The following changes since commit a188339ca5a396acc588e5851ed7e19f66b0ebd9:
Linux 5.2-rc1 (2019-05-19 15:47:09 -0700)
are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git tags/pstore-v5.2-rc4
for you to fetch changes up to 8880fa32c557600f5f624084152668ed3c2ea51e:
pstore/ram: Run without kernel crash dump region (2019-05-31 01:19:06 -0700)
----------------------------------------------------------------
pstore fixes for v5.2-rc4
- Avoid NULL deref when unloading/reloading ramoops module (Pi-Hsun Shih)
- Run ramoops without crash dump region
----------------------------------------------------------------
Kees Cook (1):
pstore/ram: Run without kernel crash dump region
Pi-Hsun Shih (1):
pstore: Set tfm to NULL on free_buf_for_compression
fs/pstore/platform.c | 7 +++++--
fs/pstore/ram.c | 36 +++++++++++++++++++++++-------------
2 files changed, 28 insertions(+), 15 deletions(-)
--
Kees Cook
On Wed, Jun 05, 2019 at 11:08:13AM -0500, Alec Ari wrote:
> I'm having this problem too, build is failing:
>
> Invalid absolute R_X86_64_32S relocation: _etext
>
> I stayed on the 4.14 branch to help prevent these kind of breakages,
> so much for that idea. Gentoo GCC 8.3.0.
It seems to be a problem with the Gold linker. Using ld.bfd appears to
work. I haven't narrowed down the problem, unfortunately.
Greg, given that this change was only for special situations (Clang
CFI), can you revert this for the stable trees?
--
Kees Cook
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