From nobody Tue Oct 29 21:51:21 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XdP8n5zmrz5byy7; Tue, 29 Oct 2024 21:51:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XdP8n5Cv0z55vt; Tue, 29 Oct 2024 21:51:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730238681; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=w96JnFotI10hqZ+haEbZLguOTAd8Ryz/D5KOO64LDlA=; b=g1DHphnLpik4BBztF4yKH21MjRBvkWBh8X2c7tjUlIqSNllQKAJPmh82+hcWLPxHGP8uSH zXPPMMqa4h2gc+Z2/P8jfCX6NshYhzDMi9wRoPyl4Bya5OLpxRyKn1BTHU8k98IaYrBy7q odYCtAhV7AOmzU65psyiQ8eTOQUaBx5c86BOs/M1Y+2njwdGODGCu48RVbA1w+hUbvXFy/ /RgzPSElNyHzFHMzjOo2KSyXSVibeGzSdsMxfFy1jDFkHUBq4dD1Qq6RNLYf+H67DwgxY8 XUzOAmgzgm7HMUgH2ynaGOtNQ2wvfliVO8g8plQPxLMfPMW+hI/DHxzCuyUECw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730238681; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=w96JnFotI10hqZ+haEbZLguOTAd8Ryz/D5KOO64LDlA=; b=J0St5nzF/PiQZLuTbgpT30Wd+X6S6nkvQU9aw/I/iFztO6U/EdkofKGqYsyxk1W+LXFoYE +yZPpFuC1ZuIKLvP7kPc+4I/XP5xebRWyCE5JHnWY1BVxkGcLe2ClYq/fFXa2KIlbr0Zj9 baLiT3ZTzvbpfQ4roTQyOP1O7MAxVlT8AsRIMw0ukqtsHs33E9NgczW2ffPBhJw685W19j lUnv4xc+JRlQX8osofPtvc7jsQO+I+AcWhMxk0UTyANoNScWiwt3+CEGJ43wfa99zqUqaE 3B3OBuyqW3bRADqS4UHtM13eaxNMXpHHTTquRiBsKzLYsDL0yNQXquEl7GD3Ag== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730238681; a=rsa-sha256; cv=none; b=o4VYZiGJdlaQvroheo9SXt4pXRjJjboT19iT8AlAZPDWqEuYroTm0UTk2fTL2vz214SMpz 6RsBgP0psdlM9TULQclfo7JCRcEBpMtNk+00g59sTJ7tLUXkXDwutl9oqxvnHuUpNujgy0 j1/nc/HfpOagQA6m8EnqAw65pStAB03eN/MsCUnQw+nt5L98qoaNPl5P+m6bf75eLNjqpD QoE8lUC1gP+5TcVAhgSJOA/JOCJlOEkfCZKS4hjsqZSMNtpl4000hpTk1TEUPKuzbq0djM 6sl/8UO03KX4QkvMBW35cZe1mALznH9dCSHw/LqFMkIY3Tt9bg/4bVE6gfNcGA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XdP8n4pz9zgsH; Tue, 29 Oct 2024 21:51:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49TLpLNN066209; Tue, 29 Oct 2024 21:51:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49TLpLHA066206; Tue, 29 Oct 2024 21:51:21 GMT (envelope-from git) Date: Tue, 29 Oct 2024 21:51:21 GMT Message-Id: <202410292151.49TLpLHA066206@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: b426202aaf76 - stable/14 - Fix gcc uninitialized warning in FreeBSD zio_crypt.c List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: b426202aaf76c0f815db60dc5aa392ac0625b4f6 Auto-Submitted: auto-generated The branch stable/14 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=b426202aaf76c0f815db60dc5aa392ac0625b4f6 commit b426202aaf76c0f815db60dc5aa392ac0625b4f6 Author: Dimitry Andric AuthorDate: 2024-10-25 12:51:05 +0000 Commit: Dimitry Andric CommitDate: 2024-10-29 21:49:16 +0000 Fix gcc uninitialized warning in FreeBSD zio_crypt.c With gcc we are seeing the following -Werror warning: In file included from /workspace/src/sys/contrib/openzfs/include/os/freebsd/spl/sys/sunddi.h:28, from /workspace/src/sys/contrib/openzfs/include/sys/zfs_context.h:69: In function 'zfs_uio_init', inlined from 'zio_do_crypt_data' at /workspace/src/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c:1690:2: /workspace/src/sys/contrib/openzfs/include/os/freebsd/spl/sys/uio.h:102:45: error: 'puio_s.uio_offset' is used uninitialized [-Werror=uninitialized] 102 | zfs_uio_soffset(uio) = uio_s->uio_offset; | ~~~~~^~~~~~~~~~~~ /workspace/src/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c: In function 'zio_do_crypt_data': /workspace/src/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c:1683:20: note: 'puio_s' declared here 1683 | struct uio puio_s, cuio_s; | ^~~~~~ In function 'zfs_uio_init', inlined from 'zio_do_crypt_data' at /workspace/src/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c:1691:2: /workspace/src/sys/contrib/openzfs/include/os/freebsd/spl/sys/uio.h:102:45: error: 'cuio_s.uio_offset' is used uninitialized [-Werror=uninitialized] 102 | zfs_uio_soffset(uio) = uio_s->uio_offset; | ~~~~~^~~~~~~~~~~~ /workspace/src/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c: In function 'zio_do_crypt_data': /workspace/src/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c:1683:28: note: 'cuio_s' declared here 1683 | struct uio puio_s, cuio_s; | ^~~~~~ Indeed, `zfs_uio_init()` does: static __inline void zfs_uio_init(zfs_uio_t *uio, struct uio *uio_s) { memset(uio, 0, sizeof (zfs_uio_t)); if (uio_s != NULL) { GET_UIO_STRUCT(uio) = uio_s; zfs_uio_soffset(uio) = uio_s->uio_offset; } } while the code in `zio_crypt.c` has: /* * Primary encryption / decryption entrypoint for zio data. */ int zio_do_crypt_data(boolean_t encrypt, zio_crypt_key_t *key, dmu_object_type_t ot, boolean_t byteswap, uint8_t *salt, uint8_t *iv, uint8_t *mac, uint_t datalen, uint8_t *plainbuf, uint8_t *cipherbuf, boolean_t *no_crypt) { int ret; boolean_t locked = B_FALSE; uint64_t crypt = key->zk_crypt; uint_t keydata_len = zio_crypt_table[crypt].ci_keylen; uint_t enc_len, auth_len; zfs_uio_t puio, cuio; struct uio puio_s, cuio_s; uint8_t enc_keydata[MASTER_KEY_MAX_LEN]; crypto_key_t tmp_ckey, *ckey = NULL; freebsd_crypt_session_t *tmpl = NULL; uint8_t *authbuf = NULL; zfs_uio_init(&puio, &puio_s); zfs_uio_init(&cuio, &cuio_s); memset(GET_UIO_STRUCT(&puio), 0, sizeof (struct uio)); memset(GET_UIO_STRUCT(&cuio), 0, sizeof (struct uio)); So between the declaration of `puio_s` and `cuio_s`, there is no initialization of these variables before `zfs_uio_init()` gets called. Similar to the Linux variant of zio_crypt.c, I think it would be better to memset the structs `puio_s` and `cuis_s` _before_ calling `zfs_uio_init()`. Reviewed by: tsoome MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D47281 (cherry picked from commit 3ceba58a7509418b47b8fca2d2b6bbf088714e26) --- sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c b/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c index b08916b317f8..ebf18aaa3403 100644 --- a/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c +++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c @@ -1692,11 +1692,10 @@ zio_do_crypt_data(boolean_t encrypt, zio_crypt_key_t *key, freebsd_crypt_session_t *tmpl = NULL; uint8_t *authbuf = NULL; - + memset(&puio_s, 0, sizeof (puio_s)); + memset(&cuio_s, 0, sizeof (cuio_s)); zfs_uio_init(&puio, &puio_s); zfs_uio_init(&cuio, &cuio_s); - memset(GET_UIO_STRUCT(&puio), 0, sizeof (struct uio)); - memset(GET_UIO_STRUCT(&cuio), 0, sizeof (struct uio)); #ifdef FCRYPTO_DEBUG printf("%s(%s, %p, %p, %d, %p, %p, %u, %s, %p, %p, %p)\n",