Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp96862rdb; Thu, 5 Oct 2023 18:42:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/HQ8rr5NRwFD0HJgbuuyr2WvkcZ7sddKTO5VTxgNQFaWs/Qzm3+OcBWqzbdmmWnaMBoqg X-Received: by 2002:a05:6a20:2447:b0:154:3f13:1bb7 with SMTP id t7-20020a056a20244700b001543f131bb7mr6943494pzc.49.1696556531678; Thu, 05 Oct 2023 18:42:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696556531; cv=none; d=google.com; s=arc-20160816; b=lRPawGitNCwr4hmtZ1UI60+bNxi8AFLyIrytMhwJWKR6z93hqlINMSYscWjjs+mzDd g6nxUjNzaEoqwGmF5Qy1fULq8IQaqgaBBKFwhK3MiUo5sAAyXL3ZkJYbpR/hxNFppdii f2oWZ4OsW8zXxRXMM3xu8Jlq0xURzSsWlcpFI4s9spETJDOEbshmEcZrYX+4e+yHXuJ2 qQuNhmqa2gBQhZwUM/CzoYPVcBzbfOB6KY24INb6leiVaB378ML8PlWO0kyD/HskbiqI IY7+zMsDPtGbaZ24SQkWUtJSPykB25/LOAlJNtg4+1W+mUOnQP7XNGApR/IutTrIUyUJ JNOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=6k+s2oh77h0Lck0WE4j7ys6Xh0pI4zuk5HzNsmyPJ88=; fh=2JgU+FP391bnUkQBxfCY4DB4fED79it/pD39D5OPqi4=; b=ad54mtLYLy7NPvKbbfdJBBPaBwsfd1jFEZq9Ysab7yVg50s9OzpGFS4AaekX/yXS8o f7vQjzSus5+LaXnupy32PBd/+tWXSoylqS9w/w2Z5KU5zNwrfe0fSR+jVMj+jTP5QtqQ T7GjXMNTvqvzQAR8iRdVy14Nkze8T3ARp688MsODTEQB6rpFEDKEz9YPdksIOg65xGBH Pa5p9Y6jmsz8fLvQu1NqU3jdvL/PVBbBwAOIw6/BZacdlmV2e01QWASRM/xZdwgVz5Bd vtemmrqZmM1fDJukOlWlMzMEna1diugJbubj1f2POxEIux1gvHj6/E4tSdL1iWknV6ir iQRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id bx30-20020a056a02051e00b00570505c5267si2794834pgb.262.2023.10.05.18.42.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 18:42:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 42A718087249; Thu, 5 Oct 2023 18:42:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229685AbjJFBmA (ORCPT + 99 others); Thu, 5 Oct 2023 21:42:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229666AbjJFBl6 (ORCPT ); Thu, 5 Oct 2023 21:41:58 -0400 Received: from abb.hmeau.com (abb.hmeau.com [144.6.53.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3785BE7; Thu, 5 Oct 2023 18:41:57 -0700 (PDT) Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1qoZqh-0043of-2s; Fri, 06 Oct 2023 09:41:52 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Fri, 06 Oct 2023 09:41:55 +0800 Date: Fri, 6 Oct 2023 09:41:55 +0800 From: Herbert Xu To: Bagas Sanjaya , Linux Crypto Mailing List Cc: Tatu =?iso-8859-1?Q?Heikkil=E4?= , Linux Kernel Mailing List , Linux Device Mapper , Mike Snitzer , Alasdair Kergon , Linux Regressions Subject: [PATCH] dm crypt: Fix reqsize in crypt_iv_eboiv_gen Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 05 Oct 2023 18:42:09 -0700 (PDT) On Fri, Oct 06, 2023 at 08:04:18AM +0700, Bagas Sanjaya wrote: > > > Git bisect lead me to: > > # first bad commit: [e3023094dffb41540330fb0c74cd3a019cd525c2] dm crypt: > > Avoid using MAX_CIPHER_BLOCKSIZE > > > > If I git revert e3023094dffb41540330fb0c74cd3a019cd525c2 on current Linus' > > git master, the issue goes away. So I'm personally not all that affected > > anymore (if I'm ready to compile my kernels from now on), and I understand > > that you have no clear way to reproduce this as it seems strongly bound to > > hardware, but seems like this could point to a potentially serious security > > issue since it involves both crypto and undefined behaviour. Thanks for the report. Sorry this is indeed my fault. The allocated buffer is too small as it's missing the size for the request object itself. Mike, would you be OK with me picking this fix up and pushing it to Linus? Cheers, ---8<--- A skcipher_request object is made up of struct skcipher_request followed by a variable-sized trailer. The allocation of the skcipher_request and IV in crypt_iv_eboiv_gen is missing the memory for struct skcipher_request. Fix it by adding it to reqsize. Fixes: e3023094dffb ("dm crypt: Avoid using MAX_CIPHER_BLOCKSIZE") Reported-by: Tatu Heikkil� Signed-off-by: Herbert Xu diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index f2662c21a6df..5315fd261c23 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -753,7 +753,8 @@ static int crypt_iv_eboiv_gen(struct crypt_config *cc, u8 *iv, int err; u8 *buf; - reqsize = ALIGN(crypto_skcipher_reqsize(tfm), __alignof__(__le64)); + reqsize = sizeof(*req) + crypto_skcipher_reqsize(tfm); + reqsize = ALIGN(reqsize, __alignof__(__le64)); req = kmalloc(reqsize + cc->iv_size, GFP_NOIO); if (!req) -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt