Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp31592266rwd; Fri, 7 Jul 2023 01:22:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlEYJ4XazZoc3dYuLLMT96/dgIRodxJoQbZJy1wr9mTZiXhcq1S/birVVJpZhVhskJmc1CTd X-Received: by 2002:a05:6808:bc9:b0:3a3:7fd6:aa63 with SMTP id o9-20020a0568080bc900b003a37fd6aa63mr4658499oik.29.1688718128294; Fri, 07 Jul 2023 01:22:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688718128; cv=none; d=google.com; s=arc-20160816; b=Sla390YtwvoKBZdAUzb9nce+2gryqARx+uem+N6twDipBiar9ApqPqQ7FVGuLeGzUu v/xDoxDlYFAcgu5FqcYGEADPVbJtGCPifyiQ4hLxTwmVDhap5iA2XpbTzlmjgLTk6XXA IxH9g1xxot3fjfIwZr7ush0ofB1Z7UiWV0dApd1V4Ah6ZAqXUMHhHqLlX6H4Z7guUiJO T2yv/mbOSP2f9Br2nd1X9q19/tKcrFKKJcEKjfzunwiaNkYWoHTRfp3+z+g6FFkog+av kP4AVvuZtGt31yfNn7SKQtIviqDVDBMqOmFHm8pEN6UV3S8HtsEm0g8JJgw9x4hjamjs Adqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-transfer-encoding :content-id:mime-version:subject:cc:to:references:in-reply-to:from :organization:dkim-signature; bh=aT1O9BlEBxtT7uHpuo6KAf/C4BqVJdHsv1uVQtgiXH4=; fh=iWcEARF11I9p6uwRjzF01ot/JmLPW+TrcRa+uVRJE/Q=; b=OlGw6Ug/rBVkdml4dziTf+UuEVngoyFClWPuvGQzLVYWzsIug3FXY+0nzu6j/UmnOH k1s3x3l/dKZkzJ+zQhEEB6hy9X98gLuavz9GYWSPSA+R/csDHTMf6RDkSGtnNshUCxd0 hzBLwCXMGuX+rijeWLTWikuSOMjRjnLpP3xp2SSlU0yObSFCpFsB12LxWY1DbLI5nWNM HdlrecTrocIuZbjhSvZxb79v3ZnFbYFchwapaRCzOJds92NbXT+0boAn9wR5ozuDQkVZ 6SQCWAxtYlMHkn3yi5qzUP4QtKPKHmMIg5zFU3F0tzBp+mjDaTPYU7AASt9EOLb4fHS/ jRDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KEnB3AyU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l191-20020a6391c8000000b0055ac5fed58dsi3496283pge.363.2023.07.07.01.21.56; Fri, 07 Jul 2023 01:22:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@redhat.com header.s=mimecast20190719 header.b=KEnB3AyU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232570AbjGGIHu (ORCPT + 99 others); Fri, 7 Jul 2023 04:07:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231281AbjGGIHt (ORCPT ); Fri, 7 Jul 2023 04:07:49 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9ADD1991 for ; Fri, 7 Jul 2023 01:07:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688717221; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aT1O9BlEBxtT7uHpuo6KAf/C4BqVJdHsv1uVQtgiXH4=; b=KEnB3AyUaF8N03SyXjCm/3lSHrSSLG5zTMnPJO5HtzcufGbBhRKwdMd/iNX244U/nu79Qs 3Ac5JUpoARLM9yOTMCxP/qnRBlk90vejhN9ds1BBOAM47zigD8FfJRVjxc43oKWkOOHAm7 CLZCsnYYzdr9f6sAUrc/hhqQmOML2MI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-395-awU6C2hJPu-5QVduIKa6ZA-1; Fri, 07 Jul 2023 04:06:57 -0400 X-MC-Unique: awU6C2hJPu-5QVduIKa6ZA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D46A10504AA; Fri, 7 Jul 2023 08:06:57 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id 257FE1121330; Fri, 7 Jul 2023 08:06:55 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <000000000000554b8205ffdea64e@google.com> References: <000000000000554b8205ffdea64e@google.com> To: syzbot Cc: dhowells@redhat.com, adilger.kernel@dilger.ca, boqun.feng@gmail.com, herbert@gondor.apana.org.au, kuba@kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, longman@redhat.com, mingo@redhat.com, netdev@vger.kernel.org, peterz@infradead.org, syzkaller-bugs@googlegroups.com, tytso@mit.edu, will@kernel.org Subject: Re: [syzbot] [ext4?] general protection fault in ext4_finish_bio MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2224783.1688717214.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Fri, 07 Jul 2023 09:06:54 +0100 Message-ID: <2224784.1688717214@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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-kernel@vger.kernel.org #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.gi= t main crypto: algif/hash: Fix race between MORE and non-MORE sends = The 'MSG_MORE' state of the previous sendmsg() is fetched without the socket lock held, so two sendmsg calls can race. This can be seen wit= h a large sendfile() as that now does a series of sendmsg() calls, and if = a write() comes in on the same socket at an inopportune time, it can fli= p the state. = Fix this by moving the fetch of ctx->more inside the socket lock. = Fixes: c662b043cdca ("crypto: af_alg/hash: Support MSG_SPLICE_PAGES") Reported-by: syzbot+689ec3afb1ef07b766b2@syzkaller.appspotmail.com Link: https://lore.kernel.org/r/000000000000554b8205ffdea64e@google.co= m/ Signed-off-by: David Howells cc: Herbert Xu cc: Paolo Abeni cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: linux-crypto@vger.kernel.org cc: netdev@vger.kernel.org diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c index 0ab43e149f0e..82c44d4899b9 100644 --- a/crypto/algif_hash.c +++ b/crypto/algif_hash.c @@ -68,13 +68,15 @@ static int hash_sendmsg(struct socket *sock, struct ms= ghdr *msg, struct hash_ctx *ctx =3D ask->private; ssize_t copied =3D 0; size_t len, max_pages, npages; - bool continuing =3D ctx->more, need_init =3D false; + bool continuing, need_init =3D false; int err; = max_pages =3D min_t(size_t, ALG_MAX_PAGES, DIV_ROUND_UP(sk->sk_sndbuf, PAGE_SIZE)); = lock_sock(sk); + continuing =3D ctx->more; + if (!continuing) { /* Discard a previous request that wasn't marked MSG_MORE. */ hash_free_result(sk, ctx);