Commit 5102981
crypto: drbg - prevent invalid SG mappings
When using SGs, only heap memory (memory that is valid as per
virt_addr_valid) is allowed to be referenced. The CTR DRBG used to
reference the caller-provided memory directly in an SG. In case the
caller provided stack memory pointers, the SG mapping is not considered
to be valid. In some cases, this would even cause a paging fault.
The change adds a new scratch buffer that is used unconditionally to
catch the cases where the caller-provided buffer is not suitable for
use in an SG. The crypto operation of the CTR DRBG produces its output
with that scratch buffer and finally copies the content of the
scratch buffer to the caller's buffer.
The scratch buffer is allocated during allocation time of the CTR DRBG
as its access is protected with the DRBG mutex.
Signed-off-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>1 parent c8467f7 commit 5102981
2 files changed
Lines changed: 26 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
| 265 | + | |
265 | 266 | | |
266 | 267 | | |
267 | 268 | | |
| |||
1644 | 1645 | | |
1645 | 1646 | | |
1646 | 1647 | | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
1647 | 1651 | | |
1648 | 1652 | | |
1649 | 1653 | | |
| |||
1708 | 1712 | | |
1709 | 1713 | | |
1710 | 1714 | | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
1711 | 1724 | | |
1712 | 1725 | | |
1713 | 1726 | | |
| |||
1737 | 1750 | | |
1738 | 1751 | | |
1739 | 1752 | | |
| 1753 | + | |
1740 | 1754 | | |
1741 | 1755 | | |
1742 | 1756 | | |
1743 | 1757 | | |
1744 | | - | |
| 1758 | + | |
1745 | 1759 | | |
1746 | | - | |
1747 | 1760 | | |
1748 | | - | |
| 1761 | + | |
| 1762 | + | |
1749 | 1763 | | |
1750 | 1764 | | |
1751 | 1765 | | |
| |||
1761 | 1775 | | |
1762 | 1776 | | |
1763 | 1777 | | |
1764 | | - | |
| 1778 | + | |
1765 | 1779 | | |
1766 | 1780 | | |
1767 | 1781 | | |
| 1782 | + | |
| 1783 | + | |
1768 | 1784 | | |
1769 | 1785 | | |
| 1786 | + | |
1770 | 1787 | | |
1771 | | - | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
1772 | 1791 | | |
1773 | 1792 | | |
1774 | 1793 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
| 128 | + | |
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
| |||
0 commit comments