From owner-svn-src-head@freebsd.org Fri May 29 07:46:31 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0B58E3321F1 for ; Fri, 29 May 2020 07:46:31 +0000 (UTC) (envelope-from mindal@semihalf.com) Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49YGpt27HRz4FNj for ; Fri, 29 May 2020 07:46:30 +0000 (UTC) (envelope-from mindal@semihalf.com) Received: by mail-ej1-x633.google.com with SMTP id y13so1149252eju.2 for ; Fri, 29 May 2020 00:46:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0HCefSK5jAfhO1mppwLQhl2SYUalyVbC38G70KXHlYM=; b=afrDKigXGp1rq+eQII/MYXdSbuZiCGx1d/QIvWVuTggwKCB2fzLT21KFtAvurhzvaU g06HKD1JdYzaL22iTq2OHnTrxC6NqgTyrcKQnsVmNrqbo2s3GCPHndqToTK8ic4POurb fx2BZmmko5zxN382fbM0pWw2rjYu+MNnEYf1TYpkWr0uaMQ8GONHRUBrOr/epTkzlzhP 9qfOaExZxKIC9flW2UtWx+HtEiJSiPz3qfGbUrXl4ClG+72l0UC9hm5EfSoWRBC4k4GK KzPy+qdzliOjRRYsJ1krwGdD1x/ECd55lUTaCZvu1gZH+GLWhTSaqTMTdckSGCPEa50C saBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0HCefSK5jAfhO1mppwLQhl2SYUalyVbC38G70KXHlYM=; b=F0C/Pb7nzcwW3vKBoq8WHGhRJ3pS6d2Hhqi/fGB7nyLEDqlbzVajxTq82AnWQEbnJ5 VFRuZWld21PtEhUxx1BOZP+A7LHYV6U0HBKLvJGz1ce4h1YKXpDjQsWA6lY+9WRtS6Qb 7z+g7JCPEjCNqPhFAo42qMRVF0USDrBbjAlFGVpcfKFsTeYaiBi+S4i/7Xztb2R3azaU DqI1FM2E8SrQ79ELj9UVcm8Z+8ZZk0skPxIFZzs5mrS6ojO8g6TcjJ32txhzqduqcRJw hsEK8IWiDGWnDKeqQRSgYIZ6QFhfhMryvUeHPrbq0fQglV7eL93MizcbhLcSL+gDFtnW fO+g== X-Gm-Message-State: AOAM533wDzTvwduxPC8KVT1kcVWlFmwFB3Gx2lT8B2+Qp2g0pZKeDY3z Khu5bNKx6+fnQREcamt9jgA/HrR+iKtIkY6jsBmbNg== X-Google-Smtp-Source: ABdhPJydF7v9ZFfJl3wSqJX8blerIbxefnHu128NLrZEXB6BXu5Ep248seYBEZ9NLs6tsKxFLcELPIqxZMv65IWQ/Yo= X-Received: by 2002:a17:906:2b88:: with SMTP id m8mr6428144ejg.514.1590738388718; Fri, 29 May 2020 00:46:28 -0700 (PDT) MIME-Version: 1.0 References: <202005280913.04S9DKWv013795@repo.freebsd.org> <9fdb00be-00e0-6aff-51ad-7a84b4215a4e@FreeBSD.org> In-Reply-To: <9fdb00be-00e0-6aff-51ad-7a84b4215a4e@FreeBSD.org> From: =?UTF-8?Q?Kornel_Dul=C4=99ba?= Date: Fri, 29 May 2020 09:46:18 +0200 Message-ID: Subject: Re: svn commit: r361583 - head/sys/crypto/aesni To: John Baldwin Cc: Marcin Wojtas , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-Rspamd-Queue-Id: 49YGpt27HRz4FNj X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=afrDKigX; dmarc=none; spf=none (mx1.freebsd.org: domain of mindal@semihalf.com has no SPF policy when checking 2a00:1450:4864:20::633) smtp.mailfrom=mindal@semihalf.com X-Spamd-Result: default: False [-1.88 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.89)[-0.885]; R_DKIM_ALLOW(-0.20)[semihalf-com.20150623.gappssmtp.com:s=20150623]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; NEURAL_SPAM_SHORT(0.27)[0.268]; NEURAL_HAM_LONG(-0.96)[-0.961]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[svn-src-head@freebsd.org]; DMARC_NA(0.00)[semihalf.com]; RCPT_COUNT_FIVE(0.00)[5]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[semihalf-com.20150623.gappssmtp.com:+]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::633:from]; R_SPF_NA(0.00)[no SPF record]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.33 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 May 2020 07:46:31 -0000 On Thu, May 28, 2020 at 8:30 PM John Baldwin wrote: > On 5/28/20 2:13 AM, Marcin Wojtas wrote: > > Author: mw > > Date: Thu May 28 09:13:20 2020 > > New Revision: 361583 > > URL: https://svnweb.freebsd.org/changeset/base/361583 > > > > Log: > > Change return types of hash update functions in SHA-NI > > > > r359374 introduced crypto_apply function which takes as argument a > function pointer > > that is expected to return an int, however aesni hash update functions > > return void. > > Because of that the function pointer passed was simply cast with > > its return value changed. > > This resulted in undefined behavior, in particular when mbuf is used, > (ipsec) > > m_apply checks return value of function pointer passed to it > > and in our case bogusly fails after calculating hash of the first mbuf > > in chain. > > Fix it by changing signatures of sha update routines in aesni and > > dropping the casts. > > Hmm, I missed one nit in the review. r359374 didn't introduce > crypto_apply, it just changed some of the arguments arguments (crp > instead of crp_buf and crp_flags). This fix needs to be MFC'd to 12 > as well since the issue with the return type is also present there. > > -- > John Baldwin > Whoops, I should have read the diff more carefully. Before debugging I did some bisecting and found r359374 as the culprit. In r359374 return types of intel_sha256_update and intel_sha1_update were changed to void which is the root cause. SHA-NI on stable/12 should work just fine right now. Sorry for the noise.