Received: by 10.223.176.5 with SMTP id f5csp185772wra; Tue, 6 Feb 2018 20:07:10 -0800 (PST) X-Google-Smtp-Source: AH8x227lTLYcZAhHkbvosiPgHxEdAK4WWkx6L/IVdC95xCqOcow8Kro7CMJgrz8okLY2JZTsjG0X X-Received: by 10.101.85.15 with SMTP id f15mr3757515pgr.153.1517976430461; Tue, 06 Feb 2018 20:07:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517976430; cv=none; d=google.com; s=arc-20160816; b=go5wd4R8rsHhpJSCZAKTxME3CkSqOktfYGl7c+p3RH7hIpjqrbRdumM8b2uEkJ00QV Bjqoi9bAuL+FCBA6/st3rgo7Q+1j6aKXDrrdl2IqcVwE+7EopAzlIdndUjrlg7u2OeJh z/FNXjeeV19rd/TO4RGwGaNCoBtrBoinVEdIm0mrBsxGuWScWeSEa1n9+D2PLvTYiFS+ UyyycajZS2DTGIOMRNkdEOCBpkmQRL3UAIkFnx1fmPGDS4K10HHUyaCZiPSSSHl2xRY+ Jc8e1goYn+BxJGGTkkT82yHmAp0dVo+9iYptgn5Tz5zoiwYV6OiSuga/mdlzV5hYvbbr MaPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=ZWMeuj5CfpFAw/iXKtxwN68PVb4CYgh9m4uvPQSLIFA=; b=FmS1VrjVlsOAj6MPIGjI4vHZ6kILQLjS/2z5v66wy7ECFjKYkTPL7F0GzjLeBN/BJg IePecKsesJDY68YjCKcrmY+z9OmDaUP0mmdAaQg79lMJ1fuYAUvYtayNC2N1MCBssNKi ljVn8DacqVmAHqyR8UuUq6Z0CGpQzMS3IqW2/37Jxi8BEGYbqsPwsUEjVswgKBHOATQ0 Spie07OoDPPo+A3l0RBvSI/Nk/2fiwKPpKa5S1zruF+/Qe/VVCCkBhXcu3l3DeMEGbsF M5GGOskXu6pMvY1lc1yA0SxiF29XcX2i8tnRJlNq+b/rN76Scimi2GYjLzV8xI5dMhJt kdMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rJDRsqGF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 37-v6si437287plq.618.2018.02.06.20.06.56; Tue, 06 Feb 2018 20:07:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rJDRsqGF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753125AbeBGEGO (ORCPT + 99 others); Tue, 6 Feb 2018 23:06:14 -0500 Received: from mail-oi0-f47.google.com ([209.85.218.47]:42185 "EHLO mail-oi0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752862AbeBGEGN (ORCPT ); Tue, 6 Feb 2018 23:06:13 -0500 Received: by mail-oi0-f47.google.com with SMTP id u6so230494oiv.9; Tue, 06 Feb 2018 20:06:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=ZWMeuj5CfpFAw/iXKtxwN68PVb4CYgh9m4uvPQSLIFA=; b=rJDRsqGFQe9yPRK0k55hgdJz5fM2Qm5yd35971rdrgO2E1U+7dtKyVNceZysfC08Zp /hS/RYzJ6v5xeqzW0e87T6otqXWeIjQtritGY192ClC011vaLoPIbL59gY31BpYPZetv D5fuo741YenxMgtbEdkhdRQ5BdcuVqBajH7NOkvpB0M8vFAUIaOAf4ShKam9WfIVbwAn HDG3/vGlNsYaucfKBKW2I/90YmprZGPapjj9rJ/ChkwcbORqxFbmUWJcegCNxkWupe85 JVkBWnDvi/Bdfy3quTnMcOOPAhujbAA+57FjjrsSLsVEQzI2TlMzPinUPXeNBCQehyeK a8NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ZWMeuj5CfpFAw/iXKtxwN68PVb4CYgh9m4uvPQSLIFA=; b=S3DcU+hhSvJQ+uDoBp+h5RE63yZPXI8/ltso0cbsd85LyrQ3s1vokwxNbUNJVCS4fb iXEoImjyBIraYJSxcRhjKgRPJvqKMDpUXCfLcUd35B8m2ieef7J4aqE94PebtgIRWzA+ CdXWRo/ZJ+pconvUqovHMD5hA4nxNXbbcVbOX8TBN97JOe/6THoIv+y4SoXPqvPNPgAs oQqoM0z1oY3wNuRjgRsX9ugVhpfJE/ng5eBopMnzNxoz90MBRkHh79XNzHQhlISgRK05 Ds5XOEawgu29QiiKSw6Cq1jDkyhiIfGe/Vi4Laxz0CfiiMusfhKLusrS7lxrZb6v1q7u Z6Iw== X-Gm-Message-State: APf1xPCazzNV4ceh7ImZPg2lHacGPzit5YvOKhcXpUM4OK5PmQgYoVL+ 0qhwdp1HLOHPWedj7qM41M6gCa0JtdjeU96MgKc= X-Received: by 10.202.93.9 with SMTP id r9mr3064052oib.105.1517976372089; Tue, 06 Feb 2018 20:06:12 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.24.91 with HTTP; Tue, 6 Feb 2018 20:05:51 -0800 (PST) In-Reply-To: References: <224788c7-426b-d3a9-d0a6-412d2b8afb75@partner.samsung.com> From: Anand Moon Date: Wed, 7 Feb 2018 09:35:51 +0530 Message-ID: Subject: Re: [PATCH] crypto: s5p-sss.c: Fix kernel Oops in AES-ECB mode To: Kamil Konieczny Cc: Herbert Xu , Krzysztof Kozlowski , Vladimir Zapolskiy , "David S. Miller" , Bartlomiej Zolnierkiewicz , Marek Szyprowski , linux-crypto@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kamil On 6 February 2018 at 22:40, Kamil Konieczny wrote: > > On 06.02.2018 17:48, Anand Moon wrote: >> Hi Kamil, >> >> Thanks for providing the fix to this issue. >> >> On 5 February 2018 at 23:10, Kamil Konieczny >> wrote: >>> >>> In AES-ECB mode crypt is done with key only, so any use of IV >>> can cause kernel Oops, as reported by Anand Moon. >> >> If possible could you avoid the name in commit message. > > This is added after '---' line, so it will not appear in commit message. > I know about '---' delimiter, but to be precise this will be part of commit message. >>> Fixed it by using IV only in AES-CBC and AES-CTR. >>> >>> Signed-off-by: Kamil Konieczny >>> Reported-by: Anand Moon >> >> [snip] >> >> Please add my. Tested on Odroid HC2 >> >> Tested-by: Anand Moon > > This will add you name in commit message, > additionally with 'Reported-by:' line. > >> Below are the result at my end. >> >> aes-cbc-essiv:sha256 (128 bit key) >> WRITE: >> 100+0 records in >> 100+0 records out >> 838860800 bytes (839 MB, 800 MiB) copied, 11.7225 s, 71.6 MB/s >> [...] > > is it from 'cryptsetup benchmark' ? benchmark did not cause oops. > Please test with luksFormat, ie. use > > cryptsetup luksFormat --debug -q -d /tmp/testkey.key \ > --cipher aes-cbc-essiv:sha256 -h sha256 -s 128 /tmp/test.bin > [snip] Below is the out put of aes-cbc-essiv:sha256 and aes-ctr-plain root@odroid:~# fallocate -l 128MiB /tmp/test.bin root@odroid:~# dd if=/dev/urandom of=/tmp/testkey.key bs=128 count=1 1+0 records in 1+0 records out 128 bytes copied, 0.000231043 s, 554 kB/s root@odroid:~# sync root@odroid:~# cryptsetup luksFormat --debug -q -d /tmp/testkey.key \ > --cipher aes-cbc-essiv:sha256 -h sha256 -s 128 /tmp/test.bin # cryptsetup 1.6.6 processing "cryptsetup luksFormat --debug -q -d /tmp/testkey.key --cipher aes-cbc-essiv:sha256 -h sha256 -s 128 /tmp/test.bin" # Running command luksFormat. # Locking memory. # Installing SIGINT/SIGTERM handler. # Unblocking interruption on signal. # Allocating crypt device /tmp/test.bin context. # Trying to open and read device /tmp/test.bin. # Initialising device-mapper backend library. # Timeout set to 0 miliseconds. # Iteration time set to 1000 miliseconds. # File descriptor passphrase entry requested. # Formatting device /tmp/test.bin as type LUKS1. # Crypto backend (gcrypt 1.6.5) initialized. # Detected kernel Linux 4.15.0-xu4krck armv7l. # Topology info for /tmp/test.bin not supported, using default offset 1048576 bytes. # Checking if cipher aes-cbc-essiv:sha256 is usable. # Using userspace crypto wrapper to access keyslot area. # Generating LUKS header version 1 using hash sha256, aes, cbc-essiv:sha256, MK 16 bytes # KDF pbkdf2, hash sha256: 160824 iterations per second. # Data offset 2048, UUID fe5c0d54-9add-4454-a4cd-98eed8f2b75c, digest iterations 19625 # Updating LUKS header of size 1024 on device /tmp/test.bin # Key length 16, device size 262144 sectors, header size 1029 sectors. # Reading LUKS header of size 1024 from device /tmp/test.bin # Key length 16, device size 262144 sectors, header size 1029 sectors. # Adding new keyslot -1 using volume key. # Calculating data for key slot 0 # KDF pbkdf2, hash sha256: 161220 iterations per second. # Key slot 0 use 78720 password iterations. # Using hash sha256 for AF in key slot 0, 4000 stripes # Updating key slot 0 [0x1000] area. # Using userspace crypto wrapper to access keyslot area. # Key slot 0 was enabled in LUKS header. # Updating LUKS header of size 1024 on device /tmp/test.bin # Key length 16, device size 262144 sectors, header size 1029 sectors. # Reading LUKS header of size 1024 from device /tmp/test.bin # Key length 16, device size 262144 sectors, header size 1029 sectors. # Releasing crypt device /tmp/test.bin context. # Releasing device-mapper backend. # Unlocking memory. Command successful. root@odroid:~# root@odroid:~# root@odroid:~# fallocate -l 128MiB /tmp/test.bin root@odroid:~# dd if=/dev/urandom of=/tmp/testkey.key bs=128 count=1 1+0 records in 1+0 records out 128 bytes copied, 0.000324001 s, 395 kB/s root@odroid:~# sync root@odroid:~# cryptsetup luksFormat --debug -q -d /tmp/testkey.key \ > --cipher aes-ctr-plain -h sha256 -s 128 /tmp/test.bin # cryptsetup 1.6.6 processing "cryptsetup luksFormat --debug -q -d /tmp/testkey.key --cipher aes-ctr-plain -h sha256 -s 128 /tmp/test.bin" # Running command luksFormat. # Locking memory. # Installing SIGINT/SIGTERM handler. # Unblocking interruption on signal. # Allocating crypt device /tmp/test.bin context. # Trying to open and read device /tmp/test.bin. # Initialising device-mapper backend library. # Timeout set to 0 miliseconds. # Iteration time set to 1000 miliseconds. # File descriptor passphrase entry requested. # Formatting device /tmp/test.bin as type LUKS1. # Crypto backend (gcrypt 1.6.5) initialized. # Detected kernel Linux 4.15.0-xu4krck armv7l. # Topology info for /tmp/test.bin not supported, using default offset 1048576 bytes. # Checking if cipher aes-ctr-plain is usable. # Using userspace crypto wrapper to access keyslot area. # Generating LUKS header version 1 using hash sha256, aes, ctr-plain, MK 16 bytes # KDF pbkdf2, hash sha256: 162217 iterations per second. # Data offset 2048, UUID 3e2b2e4a-a908-4228-b2a1-746e163e8e7e, digest iterations 19750 # Updating LUKS header of size 1024 on device /tmp/test.bin # Key length 16, device size 262144 sectors, header size 1029 sectors. # Reading LUKS header of size 1024 from device /tmp/test.bin # Key length 16, device size 262144 sectors, header size 1029 sectors. # Adding new keyslot -1 using volume key. # Calculating data for key slot 0 # KDF pbkdf2, hash sha256: 160234 iterations per second. # Key slot 0 use 78239 password iterations. # Using hash sha256 for AF in key slot 0, 4000 stripes # Updating key slot 0 [0x1000] area. # Using userspace crypto wrapper to access keyslot area. # Key slot 0 was enabled in LUKS header. # Updating LUKS header of size 1024 on device /tmp/test.bin # Key length 16, device size 262144 sectors, header size 1029 sectors. # Reading LUKS header of size 1024 from device /tmp/test.bin # Key length 16, device size 262144 sectors, header size 1029 sectors. # Releasing crypt device /tmp/test.bin context. # Releasing device-mapper backend. # Unlocking memory. Command successful. Best Regards -Anand