Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3145295pxb; Mon, 16 Nov 2020 07:00:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxDmz4oOjAyqZqYw8YEc1URqlmhziqa1EHgdcdc1bQLZpUOmlamilikqfR0Y6U0yvn5xKi3 X-Received: by 2002:a17:906:4145:: with SMTP id l5mr14442738ejk.317.1605538851350; Mon, 16 Nov 2020 07:00:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605538851; cv=none; d=google.com; s=arc-20160816; b=LYORejUiSnQDBpEFu+siTRY4cApc34MNrVf+ohIH7ygCPAMcIz1i/rA3s6lI6+RlRa xX2zNpSiZxYK+i4dxPiEocpaDxclsOC388uu9cJZwa6QQoLoZfVYw08DmBfI7NjQEAr6 IyeXVf/tHtVmnRzNwmqBH7ZUjfT+X3sz8ZhdC6M6Vs7keYs0eJ5JkgwO4Yb4Q61jzzLG as7DKyUhy442R51BBFGWr6VRfQigsRiG4aqlkyHOlM1FE3fWqaqRyoPhqgpL0rxDxX++ LSsTNWM+vLf/TDA4Mr3zVNKMmTUFyMqlFI9E5niyMZeNIXqehotJfxN+ENoi2P7C2cHX iyqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=qrCGDNkL+nhtZBXe0/uYqrDi5a1/NgbXFeBkGGZnXHw=; b=SalSe83RGIt9+/e2qx5kOS8CEdyNX8tmuo6uw2PzsxtrlOErvd0oiUZkDgrP3TEcZN r8j3N2I3D6peXtBJNZRCkh7OEqoJ6SmfELti3LB5jf9LmD4Hl+t7Axz4bOQyyviIsaGY 36mwlr43RNVTJM4AYgdUgnbrOO02fUR2Kkgj/9PmawgpS8Uor6FsNCFi4k2ztrpbCUzh NF9VYiDbttyZWG/nkfc9ljpXKP0hoyrKFF6w+Xlh88koCFfvsaluCh8CuTbhWeojPzSl 9VpUbe/DktT4gx7aJEkTZKbMw22L1Mz20Ok2rxQaFexLGxHFUfT+WaIAOF521vgmnGvc DJfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z96si7684630ede.180.2020.11.16.07.00.13; Mon, 16 Nov 2020 07:00:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730428AbgKPOzO convert rfc822-to-8bit (ORCPT + 99 others); Mon, 16 Nov 2020 09:55:14 -0500 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:55390 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730398AbgKPOzN (ORCPT ); Mon, 16 Nov 2020 09:55:13 -0500 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-98-JkwNPBRkP3WlYXkMFARcSg-1; Mon, 16 Nov 2020 14:54:59 +0000 X-MC-Unique: JkwNPBRkP3WlYXkMFARcSg-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Mon, 16 Nov 2020 14:54:58 +0000 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Mon, 16 Nov 2020 14:54:58 +0000 From: David Laight To: 'Corentin Labbe' , "arnd@arndb.de" , "davem@davemloft.net" , "herbert@gondor.apana.org.au" , "jernej.skrabec@siol.net" , "mripard@kernel.org" , "wens@csie.org" CC: "linux-arm-kernel@lists.infradead.org" , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-sunxi@googlegroups.com" , "stable@vger.kernel.org" Subject: RE: [PATCH v3 2/7] crypto: sun4i-ss: checking sg length is not sufficient Thread-Topic: [PATCH v3 2/7] crypto: sun4i-ss: checking sg length is not sufficient Thread-Index: AQHWvCBry++55PgsQECGWrYMz9WH2qnK16lg Date: Mon, 16 Nov 2020 14:54:58 +0000 Message-ID: <0a9e713557104048b535958b5fe6cb10@AcuMS.aculab.com> References: <20201116135345.11834-1-clabbe@baylibre.com> <20201116135345.11834-3-clabbe@baylibre.com> In-Reply-To: <20201116135345.11834-3-clabbe@baylibre.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Corentin Labbe > Sent: 16 November 2020 13:54 > > The optimized cipher function need length multiple of 4 bytes. > But it get sometimes odd length. > This is due to SG data could be stored with an offset. > > So the fix is to check also if the offset is aligned with 4 bytes. > Fixes: 6298e948215f2 ("crypto: sunxi-ss - Add Allwinner Security System crypto accelerator") > Cc: > Signed-off-by: Corentin Labbe > --- > drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c b/drivers/crypto/allwinner/sun4i- > ss/sun4i-ss-cipher.c > index 19f1aa577ed4..4dd736ee5a4d 100644 > --- a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c > +++ b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c > @@ -186,12 +186,12 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq) > * we can use the SS optimized function > */ > while (in_sg && no_chunk == 1) { > - if (in_sg->length % 4) > + if (in_sg->length % 4 || !IS_ALIGNED(in_sg->offset, sizeof(u32))) You probably ought to do the test in a consistent manner. Probably something that reduces to: ((unsigned long)in_sg->offset | in_sg->length) & 3u David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)