Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4431786rwb; Mon, 31 Jul 2023 06:54:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlFCQmZ/DbHpbd1YBF728nj038hzf2g3mCBb/YWBtDzUtXgGVniHI/5dSubJIy1k689QsijM X-Received: by 2002:a17:907:1dd9:b0:991:d5ad:f1b1 with SMTP id og25-20020a1709071dd900b00991d5adf1b1mr6444704ejc.47.1690811689040; Mon, 31 Jul 2023 06:54:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690811689; cv=none; d=google.com; s=arc-20160816; b=FMuZ3Ko5ulWNzg5lcIEdlS8RwhcmFYfO+2PUGIlo6ti8UuTxGZtwi6rqRVZxje5grr lH0P7rmOA+xHo1bWe3snj9JM8KJ4kMELnE2NRocdRLyhgecUm4bdyN0NhpGRP1RO6qEf rwfI/1+637htZk0SHODO+x1IER1TFF/AHPZxNMLt+NLNAFIXi1n9piXKFGfSVjZLqA4S IocmBeZf/El2oVgdQDX+GmhMz13BV6NWIyAg0YgbjcMUJcPaaZUKG2bXVzQRBtSdJG5g z8aHxhFy1uM1RyjXxRhhmOJEhk5kFNOcQtiQ2Pu48ajmEDODZnJHpD9RWzvODeoQZxoT emVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=oAyXH6ekoTa05SAgzmQb3wllKwSfvfzCrLBBn4jkkW4=; fh=wQWW9Xs9hA0W7aFOYGEqwVW5ywvINkQFbHYkJ71leJQ=; b=fIYOYfK0mFCWsgclzimK5gQ3nnEw9UCDxiR3TmqMFDqQGQJeoP+TS8l9LEliQQCYFK 8NQp+4fAQ5NHBghi6rqK93mfiwK7sKaiesZFDyMhs1YFqHJs17JBaDbyx8ouqo9XZcNL jwblsfHIiBywbQAOhFXAW5V+Opqa3BWcXGrSWl1l9scwj2b8JFE+cRgdCdAgOoD3qUlP EYmVkHvGwKdGWHJZtHlTWRdMp8YkO2pg5qjmP1FLlaxGhRIuZGnsxuzyFzHiqFJJSx5i /Ehqkg6Xwn2B8TyCW8a1QpPRE8m8X+bEBS2PYNdSnDxp4tKyzCVE2ElJqsG4Z/d+iuON 9ktw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=gLyC++uM; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p2-20020a170906838200b00988da9cd05csi3356806ejx.23.2023.07.31.06.54.23; Mon, 31 Jul 2023 06:54:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=gLyC++uM; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-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 S232356AbjGaNgC (ORCPT + 99 others); Mon, 31 Jul 2023 09:36:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232261AbjGaNgB (ORCPT ); Mon, 31 Jul 2023 09:36:01 -0400 Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41A0B1708; Mon, 31 Jul 2023 06:35:56 -0700 (PDT) Received: by mail-yb1-xb35.google.com with SMTP id 3f1490d57ef6-d09ba80fbcaso4675013276.2; Mon, 31 Jul 2023 06:35:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690810555; x=1691415355; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=oAyXH6ekoTa05SAgzmQb3wllKwSfvfzCrLBBn4jkkW4=; b=gLyC++uMA73NEwRZEkud6ZUJY1Dsimw7XhAv41TwiKC98Ik61qftRevUzwfUiCxVuh 3uiAbaiSuFE3ZrDVAso6i83lCKnNJ+FPzNkyVtSgjHfQuoGXYydiYmckIJwB5OfK2reR Pb/ym26WIkf73+Jgbx8ZvnV6cQU6id7zSxbjIZ9J584vqeqvMDGbk7CdMrtKp2LdVAx+ /1Ey3DbxGLl4U2VVP0YYA9XL79GU50m5t/jyuaca5rfNmOP1DYjW5RCNVUo4QUPNoi4p DY6ghdxqzyynDLBHa49ou/WG4Q/DI01xGlCKNv3htUCiMk0QXakVvdWP6f5gVqx6O9Gq x7IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690810555; x=1691415355; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oAyXH6ekoTa05SAgzmQb3wllKwSfvfzCrLBBn4jkkW4=; b=kjmaaDsSoJS6xiBmRZMIpu53NaUsr+kbubPhYDT9JVt3aNc7xsNHVdW51XwGP4msfp AbO+QHNLIA3p83MjYHQLNx5ipnhepZHQs1jDdogdf4kLaAoZ5weCzJ4PJd2WbvLBoyuQ PD/ze1ywR3Z8XMftJj/Jt7860Zw9YHu53xLe+G0VF2A3z+WutpffY+8c9uvg7Upspp8v p+Zd9fYJLKNvgYAtjWnn3f7TRFBFHZEeuce752LvshQVEmhEa7JHPfoyW+4lsb5JrEBR JVLfQ/m3Mp+YNxtuYu2A+NJykkDivwVDA7GV8HKc0zHwR1cHFxLbSlqZGZk6V4Ep0HMr XANg== X-Gm-Message-State: ABy/qLYxp1SPB37NA2iCO99Cfk4oHZcpJawpbHpRnSIMrp5Mxsal8S3X D4t/o1xgirPX7UeyaNwkIG95ytV3JtYl2lYXrqo= X-Received: by 2002:a25:ce04:0:b0:d0c:9ab2:72d3 with SMTP id x4-20020a25ce04000000b00d0c9ab272d3mr9716417ybe.14.1690810555377; Mon, 31 Jul 2023 06:35:55 -0700 (PDT) MIME-Version: 1.0 References: <97730.1690408399@warthog.procyon.org.uk> In-Reply-To: From: =?UTF-8?B?T25kcmVqIE1vc27DocSNZWs=?= Date: Mon, 31 Jul 2023 15:35:44 +0200 Message-ID: Subject: Re: [PATCH] crypto: Fix missing initialisation affecting gcm-aes-s390 To: Sven Schnelle Cc: David Howells , Herbert Xu , Paolo Abeni , Harald Freudenberger , Bagas Sanjaya , linux-crypto@vger.kernel.org, linux-s390@vger.kernel.org, netdev@vger.kernel.org, regressions@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, Jul 27, 2023 at 7:55=E2=80=AFAM Sven Schnelle = wrote: > > David Howells writes: > > > > > Fix af_alg_alloc_areq() to initialise areq->first_rsgl.sgl.sgt.sgl to p= oint > > to the scatterlist array in areq->first_rsgl.sgl.sgl. > > > > Without this, the gcm-aes-s390 driver will oops when it tries to do > > gcm_walk_start() on req->dst because req->dst is set to the value of > > areq->first_rsgl.sgl.sgl by _aead_recvmsg() calling > > aead_request_set_crypt(). > > > > The problem comes if an empty ciphertext is passed: the loop in > > af_alg_get_rsgl() just passes straight out and doesn't set areq->first_= rsgl > > up. > > > > This isn't a problem on x86_64 using gcmaes_crypt_by_sg() because, as f= ar > > as I can tell, that ignores req->dst and only uses req->src[*]. > > > > [*] Is this a bug in aesni-intel_glue.c? > > > > The s390x oops looks something like: > > > > Unable to handle kernel pointer dereference in virtual kernel address = space > > Failing address: 0000000a00000000 TEID: 0000000a00000803 > > Fault in home space mode while using kernel ASCE. > > AS:00000000a43a0007 R3:0000000000000024 > > Oops: 003b ilc:2 [#1] SMP > > ... > > Call Trace: > > [<000003ff7fc3d47e>] gcm_walk_start+0x16/0x28 [aes_s390] > > [<00000000a2a342f2>] crypto_aead_decrypt+0x9a/0xb8 > > [<00000000a2a60888>] aead_recvmsg+0x478/0x698 > > [<00000000a2e519a0>] sock_recvmsg+0x70/0xb0 > > [<00000000a2e51a56>] sock_read_iter+0x76/0xa0 > > [<00000000a273e066>] vfs_read+0x26e/0x2a8 > > [<00000000a273e8c4>] ksys_read+0xbc/0x100 > > [<00000000a311d808>] __do_syscall+0x1d0/0x1f8 > > [<00000000a312ff30>] system_call+0x70/0x98 > > Last Breaking-Event-Address: > > [<000003ff7fc3e6b4>] gcm_aes_crypt+0x104/0xa68 [aes_s390] > > > > Fixes: c1abe6f570af ("crypto: af_alg: Use extract_iter_to_sg() to creat= e scatterlists") > > Reported-by: Ondrej Mosn=C3=A1=C4=8Dek > > Link: https://lore.kernel.org/r/CAAUqJDuRkHE8fPgZJGaKjUjd3QfGwzfumuJBmS= tPqBhubxyk_A@mail.gmail.com/ > > Signed-off-by: David Howells > > cc: Herbert Xu > > cc: Sven Schnelle > > cc: Harald Freudenberger > > cc: "David S. Miller" > > cc: Paolo Abeni > > cc: linux-crypto@vger.kernel.org > > cc: linux-s390@vger.kernel.org > > cc: regressions@lists.linux.dev > > --- > > crypto/af_alg.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/crypto/af_alg.c b/crypto/af_alg.c > > index 06b15b9f661c..9ee8575d3b1a 100644 > > --- a/crypto/af_alg.c > > +++ b/crypto/af_alg.c > > @@ -1192,6 +1192,7 @@ struct af_alg_async_req *af_alg_alloc_areq(struct= sock *sk, > > > > areq->areqlen =3D areqlen; > > areq->sk =3D sk; > > + areq->first_rsgl.sgl.sgt.sgl =3D areq->first_rsgl.sgl.sgl; > > areq->last_rsgl =3D NULL; > > INIT_LIST_HEAD(&areq->rsgl_list); > > areq->tsgl =3D NULL; > > Just tested, with this fix the kernel no longer crashes. Thanks! > > Tested-by: Sven Schnelle Same here. Thanks for the fix! Tested-by: Ondrej Mosn=C3=A1=C4=8Dek