Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1912584rwd; Thu, 15 Jun 2023 18:18:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6tzQUY7XNMJhC95ekU893K32xMS7Rt+FriMAMDSenvkW4bHf6NkFcuHOo7vPa8CAbor4ac X-Received: by 2002:aca:db43:0:b0:39e:8a65:ada2 with SMTP id s64-20020acadb43000000b0039e8a65ada2mr892301oig.0.1686878335597; Thu, 15 Jun 2023 18:18:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686878335; cv=none; d=google.com; s=arc-20160816; b=tQY4RfMrqcUBaIhp8ho0ccwlDXgd4dVxQpvURZCMSs5TWPn/93XxoeRieZeIukJZvF xPnjL36Jh/ya3WwABKelBq2Awe6EJYKKc8elelrknwHszRSmQUvSawKnQ8nXrhv3rn0S a+I5qY0u9HFP4/HfVVLxLCdsoXquePcwu86t0sFQNsEnaDTPmgfp85EAgO8aRqONe3vG 2JiGIU/xZ9YTY0j9y43G5apTSWB7dV/tKwmWCfzzeJX+mBzZBHXIY8ccnSZpmU/woJIS lbRvIjBg9vCYgHSzRP5tc1Vzxo/dS2OscHe/TABIm886m4WINuE/tb564skRK7HiVdv3 60Mw== 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=kcEnbXGcWdas9JneXh0Lv5Rsvonbjggxw0qCFC163g8=; b=cR+GuawqhS6vIn+CkUFppoHxNhGosiNeGqLnd+KO3kHMBnf+CE97Tv/4GvChXN0I0/ emDXgtRGaqufj9Le9rR0KJ91kTlClQm4XCqpIcolilMLAjnMmteJlyFx66TlhNxOcdem E6tv9+wupHWNDb4MlKLz1s2LekR8sONRvT+yEK5ZKyyUdLnKCIsV2e/CKm1s0eQyTNuK tDvIUvvYdHc/dCVogGpYUKzBiufgBi9Ce6PkCAqI14sPMS8G2qQiETOSxdsrqaH1BgeA 8ZUAjHy8PPV4TgssGC0lzRiiWg5Ja2aWkA2yvwMvriBl+hi07Z+/DnRbOKjy3g/lYH5R bWDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ELyNMjV0; 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=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 m21-20020a637115000000b0051367d909efsi8853676pgc.106.2023.06.15.18.18.42; Thu, 15 Jun 2023 18:18:55 -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=@redhat.com header.s=mimecast20190719 header.b=ELyNMjV0; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232752AbjFPBEW (ORCPT + 99 others); Thu, 15 Jun 2023 21:04:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229581AbjFPBEU (ORCPT ); Thu, 15 Jun 2023 21:04:20 -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 19D5F2972 for ; Thu, 15 Jun 2023 18:03:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686877414; 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=kcEnbXGcWdas9JneXh0Lv5Rsvonbjggxw0qCFC163g8=; b=ELyNMjV05NMOei3qp9wQLjMosL7cNVerTg0JUaMN0pmf8oqH/sTP0uSAbE0X8itAhIP2fU sDVxyHH88831pDM5D2Q9hAXSXRgX093x/8BZCkW9mpvLV4NyObqrqsxFiw5jZn3a8ifzhh WosFGx1lM+Yt/RvhhKmHJgnIft4/mv8= 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-209-5ATaZ5wBOeK4-I-YWKB-ew-1; Thu, 15 Jun 2023 21:03:30 -0400 X-MC-Unique: 5ATaZ5wBOeK4-I-YWKB-ew-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1D04D85A58A; Fri, 16 Jun 2023 01:03:30 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03B47492C38; Fri, 16 Jun 2023 01:03:28 +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: References: <000000000000b928f705fdeb873a@google.com> <1433015.1686741914@warthog.procyon.org.uk> To: Herbert Xu Cc: dhowells@redhat.com, syzbot , davem@davemloft.net, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [crypto?] general protection fault in shash_async_final MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <415468.1686877408.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Fri, 16 Jun 2023 02:03:28 +0100 Message-ID: <415469.1686877408@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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, 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-crypto@vger.kernel.org Hi Herbert, Here's a slightly more comprehensive test program for the hashing code to exercise some combinations of sendmsg, sendmsg+MSG_MORE and recvmsg. David --- #define _GNU_SOURCE #include #include #include #include #include #include #include #include #define OSERROR(R, S) do { if ((long)(R) =3D=3D -1L) { perror((S)); exit(1= ); } } while(0) static int hashfd; static unsigned char buf[1024], sbuf[1024]; static const unsigned char no_zeros[2] =3D { 0xe3, 0xb0 }; static const unsigned char one_zero[2] =3D { 0x6e, 0x34 }; static const unsigned char two_zeros[2] =3D { 0x96, 0xa2 }; static void do_send(unsigned int n, unsigned int flags) { struct msghdr msg; struct iovec iov[1]; int res; memset(&msg, 0, sizeof(msg)); iov[0].iov_base =3D sbuf; iov[0].iov_len =3D n; msg.msg_iov =3D iov; msg.msg_iovlen =3D 1; res =3D sendmsg(hashfd, &msg, flags); OSERROR(res, "sendmsg"); } static void do_recv(unsigned int ix, const unsigned char r[2]) { struct msghdr msg; struct iovec iov[1]; int res, i; memset(&msg, 0, sizeof(msg)); iov[0].iov_base =3D buf; iov[0].iov_len =3D sizeof(buf); msg.msg_iov =3D iov; msg.msg_iovlen =3D 1; res =3D recvmsg(hashfd, &msg, 0); OSERROR(res, "recvmsg"); printf("%3u: ", ix); for (i =3D 0; i < res; i++) printf("%02x", buf[i]); printf("\n"); if (buf[0] !=3D r[0] || buf[1] !=3D r[1]) fprintf(stderr, " ^ Bad result!\n"); } int main(void) { struct sockaddr_alg salg; int algfd, res; algfd =3D socket(AF_ALG, SOCK_SEQPACKET, 0); OSERROR(algfd, "socket"); memset(&salg, 0, sizeof(salg)); salg.salg_family =3D AF_ALG; strcpy(salg.salg_type, "hash"); strcpy(salg.salg_name, "sha256"); res =3D bind(algfd, (struct sockaddr *)&salg, sizeof(salg)); OSERROR(res, "bind/alg"); hashfd =3D accept4(algfd, NULL, 0, 0); OSERROR(hashfd, "accept/alg"); //res =3D setsockopt(3, SOL_ALG, ALG_SET_KEY, NULL, 0); //OSERROR(res, "setsockopt/ALG_SET_KEY"); = /* Test no send */ do_recv(__LINE__, no_zeros); /* Test single send of 0 */ do_send(0, 0); do_recv(__LINE__, no_zeros); do_send(0, MSG_MORE); do_recv(__LINE__, no_zeros); /* Test single send of 1 */ do_send(1, 0); do_recv(__LINE__, one_zero); do_send(1, MSG_MORE); do_recv(__LINE__, one_zero); /* Test single send of 2 */ do_send(2, 0); do_recv(__LINE__, two_zeros); do_send(2, MSG_MORE); do_recv(__LINE__, two_zeros); /* Test two sends of 1 */ do_send(1, 0); do_send(1, 0); do_recv(__LINE__, one_zero); do_send(1, 0); do_send(1, MSG_MORE); do_recv(__LINE__, one_zero); do_send(1, MSG_MORE); do_send(1, 0); do_recv(__LINE__, two_zeros); do_send(1, MSG_MORE); do_send(1, MSG_MORE); do_recv(__LINE__, two_zeros); /* Test send of 0 then send of 2 */ do_send(0, 0); do_send(2, 0); do_recv(__LINE__, two_zeros); do_send(0, 0); do_send(2, MSG_MORE); do_recv(__LINE__, two_zeros); do_send(0, MSG_MORE); do_send(2, 0); do_recv(__LINE__, two_zeros); do_send(0, MSG_MORE); do_send(2, MSG_MORE); do_recv(__LINE__, two_zeros); /* Test send of 2 then send of 0 */ do_send(2, 0); do_send(0, 0); do_recv(__LINE__, no_zeros); do_send(2, 0); do_send(0, MSG_MORE); do_recv(__LINE__, no_zeros); do_send(2, MSG_MORE); do_send(0, 0); do_recv(__LINE__, two_zeros); do_send(2, MSG_MORE); do_send(0, MSG_MORE); do_recv(__LINE__, two_zeros); return 0; }