Date: Wed, 3 Apr 2019 08:22:58 +0000 (UTC) From: Marcin Wojtas <mw@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345842 - head/sys/dev/tpm Message-ID: <201904030822.x338Mwqe081430@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mw Date: Wed Apr 3 08:22:58 2019 New Revision: 345842 URL: https://svnweb.freebsd.org/changeset/base/345842 Log: Add a cv_wait to the TPM2.0 harvesting function Harvesting has to compete for the TPM chip with userspace. Before this change the callout could hijack an unread buffer causing a userspace call to the TPM to fail. Submitted by: Kornel Duleba <mindal@semihalf.com> Reviewed by: delphij Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D19712 Modified: head/sys/dev/tpm/tpm20.c Modified: head/sys/dev/tpm/tpm20.c ============================================================================== --- head/sys/dev/tpm/tpm20.c Wed Apr 3 08:18:18 2019 (r345841) +++ head/sys/dev/tpm/tpm20.c Wed Apr 3 08:22:58 2019 (r345842) @@ -263,6 +263,8 @@ tpm20_harvest(void *arg) sc = arg; sx_xlock(&sc->dev_lock); + while (sc->pending_data_length != 0) + cv_wait(&sc->buf_cv, &sc->dev_lock); memcpy(sc->buf, cmd, sizeof(cmd)); result = sc->transmit(sc, sizeof(cmd));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904030822.x338Mwqe081430>