[cryptodev:master 54/61] net/sctp/sm_make_chunk.c:1688:1: warning: 'sctp_pack_cookie.isra.6' uses dynamic stack allocation
From: kbuild test robot <hidden>
Date: 2016-01-28 05:10:38
tree: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master head: 2f313e029020f1fa5f58f38f48ff6988d67fc3c1 commit: 5821c769706561da81e9fcec4a6ca6dbbb2f30cb [54/61] sctp: Use shash config: s390-allyesconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout 5821c769706561da81e9fcec4a6ca6dbbb2f30cb # save the attached .config to linux build tree make.cross ARCH=s390 All warnings (new ones prefixed by >>): net/sctp/sm_make_chunk.c: In function 'sctp_pack_cookie.isra.6':
quoted
net/sctp/sm_make_chunk.c:1688:1: warning: 'sctp_pack_cookie.isra.6' uses dynamic stack allocation
}
^
net/sctp/sm_make_chunk.c: In function 'sctp_unpack_cookie':quoted
net/sctp/sm_make_chunk.c:1865:1: warning: 'sctp_unpack_cookie' uses dynamic stack allocation
}
^
--
net/sctp/auth.c: In function 'sctp_auth_calculate_hmac':quoted
net/sctp/auth.c:761:1: warning: 'sctp_auth_calculate_hmac' uses dynamic stack allocation
}
^
vim +1688 net/sctp/sm_make_chunk.c
1b489e11d Herbert Xu 2006-08-20 1682
1b489e11d Herbert Xu 2006-08-20 1683 free_cookie:
1b489e11d Herbert Xu 2006-08-20 1684 kfree(retval);
1b489e11d Herbert Xu 2006-08-20 1685 nodata:
1b489e11d Herbert Xu 2006-08-20 1686 *cookie_len = 0;
1b489e11d Herbert Xu 2006-08-20 1687 return NULL;
^1da177e4 Linus Torvalds 2005-04-16 @1688 }
^1da177e4 Linus Torvalds 2005-04-16 1689
^1da177e4 Linus Torvalds 2005-04-16 1690 /* Unpack the cookie from COOKIE ECHO chunk, recreating the association. */
^1da177e4 Linus Torvalds 2005-04-16 1691 struct sctp_association *sctp_unpack_cookie(
^1da177e4 Linus Torvalds 2005-04-16 1692 const struct sctp_endpoint *ep,
^1da177e4 Linus Torvalds 2005-04-16 1693 const struct sctp_association *asoc,
dd0fc66fb Al Viro 2005-10-07 1694 struct sctp_chunk *chunk, gfp_t gfp,
^1da177e4 Linus Torvalds 2005-04-16 1695 int *error, struct sctp_chunk **errp)
^1da177e4 Linus Torvalds 2005-04-16 1696 {
^1da177e4 Linus Torvalds 2005-04-16 1697 struct sctp_association *retval = NULL;
^1da177e4 Linus Torvalds 2005-04-16 1698 struct sctp_signed_cookie *cookie;
^1da177e4 Linus Torvalds 2005-04-16 1699 struct sctp_cookie *bear_cookie;
^1da177e4 Linus Torvalds 2005-04-16 1700 int headersize, bodysize, fixed_size;
313e7b4d2 Vlad Yasevich 2006-01-17 1701 __u8 *digest = ep->digest;
570617e79 Daniel Borkmann 2013-02-12 1702 unsigned int len;
^1da177e4 Linus Torvalds 2005-04-16 1703 sctp_scope_t scope;
^1da177e4 Linus Torvalds 2005-04-16 1704 struct sk_buff *skb = chunk->skb;
52db882f3 Daniel Borkmann 2013-06-25 1705 ktime_t kt;
^1da177e4 Linus Torvalds 2005-04-16 1706
9834a2bb4 Vlad Yasevich 2006-01-17 1707 /* Header size is static data prior to the actual cookie, including
9834a2bb4 Vlad Yasevich 2006-01-17 1708 * any padding.
9834a2bb4 Vlad Yasevich 2006-01-17 1709 */
9834a2bb4 Vlad Yasevich 2006-01-17 1710 headersize = sizeof(sctp_chunkhdr_t) +
9834a2bb4 Vlad Yasevich 2006-01-17 1711 (sizeof(struct sctp_signed_cookie) -
9834a2bb4 Vlad Yasevich 2006-01-17 1712 sizeof(struct sctp_cookie));
^1da177e4 Linus Torvalds 2005-04-16 1713 bodysize = ntohs(chunk->chunk_hdr->length) - headersize;
^1da177e4 Linus Torvalds 2005-04-16 1714 fixed_size = headersize + sizeof(struct sctp_cookie);
^1da177e4 Linus Torvalds 2005-04-16 1715
^1da177e4 Linus Torvalds 2005-04-16 1716 /* Verify that the chunk looks like it even has a cookie.
^1da177e4 Linus Torvalds 2005-04-16 1717 * There must be enough room for our cookie and our peer's
^1da177e4 Linus Torvalds 2005-04-16 1718 * INIT chunk.
^1da177e4 Linus Torvalds 2005-04-16 1719 */
^1da177e4 Linus Torvalds 2005-04-16 1720 len = ntohs(chunk->chunk_hdr->length);
^1da177e4 Linus Torvalds 2005-04-16 1721 if (len < fixed_size + sizeof(struct sctp_chunkhdr))
^1da177e4 Linus Torvalds 2005-04-16 1722 goto malformed;
^1da177e4 Linus Torvalds 2005-04-16 1723
^1da177e4 Linus Torvalds 2005-04-16 1724 /* Verify that the cookie has been padded out. */
^1da177e4 Linus Torvalds 2005-04-16 1725 if (bodysize % SCTP_COOKIE_MULTIPLE)
^1da177e4 Linus Torvalds 2005-04-16 1726 goto malformed;
^1da177e4 Linus Torvalds 2005-04-16 1727
^1da177e4 Linus Torvalds 2005-04-16 1728 /* Process the cookie. */
^1da177e4 Linus Torvalds 2005-04-16 1729 cookie = chunk->subh.cookie_hdr;
^1da177e4 Linus Torvalds 2005-04-16 1730 bear_cookie = &cookie->c;
^1da177e4 Linus Torvalds 2005-04-16 1731
^1da177e4 Linus Torvalds 2005-04-16 1732 if (!sctp_sk(ep->base.sk)->hmac)
^1da177e4 Linus Torvalds 2005-04-16 1733 goto no_hmac;
^1da177e4 Linus Torvalds 2005-04-16 1734
^1da177e4 Linus Torvalds 2005-04-16 1735 /* Check the signature. */
5821c7697 Herbert Xu 2016-01-24 1736 {
5821c7697 Herbert Xu 2016-01-24 1737 SHASH_DESC_ON_STACK(desc, sctp_sk(ep->base.sk)->hmac);
5821c7697 Herbert Xu 2016-01-24 1738 int err;
5821c7697 Herbert Xu 2016-01-24 1739
5821c7697 Herbert Xu 2016-01-24 1740 desc->tfm = sctp_sk(ep->base.sk)->hmac;
5821c7697 Herbert Xu 2016-01-24 1741 desc->flags = 0;
5821c7697 Herbert Xu 2016-01-24 1742
5821c7697 Herbert Xu 2016-01-24 1743 err = crypto_shash_setkey(desc->tfm, ep->secret_key,
5821c7697 Herbert Xu 2016-01-24 1744 sizeof(ep->secret_key)) ?:
5821c7697 Herbert Xu 2016-01-24 1745 crypto_shash_digest(desc, (u8 *)bear_cookie, bodysize,
5821c7697 Herbert Xu 2016-01-24 1746 digest);
5821c7697 Herbert Xu 2016-01-24 1747 shash_desc_zero(desc);
5821c7697 Herbert Xu 2016-01-24 1748
5821c7697 Herbert Xu 2016-01-24 1749 if (err) {
1b489e11d Herbert Xu 2006-08-20 1750 *error = -SCTP_IERROR_NOMEM;
1b489e11d Herbert Xu 2006-08-20 1751 goto fail;
1b489e11d Herbert Xu 2006-08-20 1752 }
5821c7697 Herbert Xu 2016-01-24 1753 }
^1da177e4 Linus Torvalds 2005-04-16 1754
^1da177e4 Linus Torvalds 2005-04-16 1755 if (memcmp(digest, cookie->signature, SCTP_SIGNATURE_SIZE)) {
^1da177e4 Linus Torvalds 2005-04-16 1756 *error = -SCTP_IERROR_BAD_SIG;
^1da177e4 Linus Torvalds 2005-04-16 1757 goto fail;
^1da177e4 Linus Torvalds 2005-04-16 1758 }
^1da177e4 Linus Torvalds 2005-04-16 1759
^1da177e4 Linus Torvalds 2005-04-16 1760 no_hmac:
^1da177e4 Linus Torvalds 2005-04-16 1761 /* IG Section 2.35.2:
^1da177e4 Linus Torvalds 2005-04-16 1762 * 3) Compare the port numbers and the verification tag contained
^1da177e4 Linus Torvalds 2005-04-16 1763 * within the COOKIE ECHO chunk to the actual port numbers and the
^1da177e4 Linus Torvalds 2005-04-16 1764 * verification tag within the SCTP common header of the received
^1da177e4 Linus Torvalds 2005-04-16 1765 * packet. If these values do not match the packet MUST be silently
^1da177e4 Linus Torvalds 2005-04-16 1766 * discarded,
^1da177e4 Linus Torvalds 2005-04-16 1767 */
^1da177e4 Linus Torvalds 2005-04-16 1768 if (ntohl(chunk->sctp_hdr->vtag) != bear_cookie->my_vtag) {
^1da177e4 Linus Torvalds 2005-04-16 1769 *error = -SCTP_IERROR_BAD_TAG;
^1da177e4 Linus Torvalds 2005-04-16 1770 goto fail;
^1da177e4 Linus Torvalds 2005-04-16 1771 }
^1da177e4 Linus Torvalds 2005-04-16 1772
9b1dfad01 Al Viro 2006-11-20 1773 if (chunk->sctp_hdr->source != bear_cookie->peer_addr.v4.sin_port ||
^1da177e4 Linus Torvalds 2005-04-16 1774 ntohs(chunk->sctp_hdr->dest) != bear_cookie->my_port) {
^1da177e4 Linus Torvalds 2005-04-16 1775 *error = -SCTP_IERROR_BAD_PORTS;
^1da177e4 Linus Torvalds 2005-04-16 1776 goto fail;
^1da177e4 Linus Torvalds 2005-04-16 1777 }
^1da177e4 Linus Torvalds 2005-04-16 1778
^1da177e4 Linus Torvalds 2005-04-16 1779 /* Check to see if the cookie is stale. If there is already
^1da177e4 Linus Torvalds 2005-04-16 1780 * an association, there is no need to check cookie's expiration
^1da177e4 Linus Torvalds 2005-04-16 1781 * for init collision case of lost COOKIE ACK.
f236218b7 Vlad Yasevich 2006-09-29 1782 * If skb has been timestamped, then use the stamp, otherwise
f236218b7 Vlad Yasevich 2006-09-29 1783 * use current time. This introduces a small possibility that
f236218b7 Vlad Yasevich 2006-09-29 1784 * that a cookie may be considered expired, but his would only slow
f236218b7 Vlad Yasevich 2006-09-29 1785 * down the new association establishment instead of every packet.
^1da177e4 Linus Torvalds 2005-04-16 1786 */
f236218b7 Vlad Yasevich 2006-09-29 1787 if (sock_flag(ep->base.sk, SOCK_TIMESTAMP))
52db882f3 Daniel Borkmann 2013-06-25 1788 kt = skb_get_ktime(skb);
f236218b7 Vlad Yasevich 2006-09-29 1789 else
cb5e173ed Marcelo Ricardo Leitner 2015-12-04 1790 kt = ktime_get_real();
f236218b7 Vlad Yasevich 2006-09-29 1791
67cb9366f Daniel Borkmann 2014-06-11 1792 if (!asoc && ktime_before(bear_cookie->expiration, kt)) {
^1da177e4 Linus Torvalds 2005-04-16 1793 /*
^1da177e4 Linus Torvalds 2005-04-16 1794 * Section 3.3.10.3 Stale Cookie Error (3)
^1da177e4 Linus Torvalds 2005-04-16 1795 *
^1da177e4 Linus Torvalds 2005-04-16 1796 * Cause of error
^1da177e4 Linus Torvalds 2005-04-16 1797 * ---------------
^1da177e4 Linus Torvalds 2005-04-16 1798 * Stale Cookie Error: Indicates the receipt of a valid State
^1da177e4 Linus Torvalds 2005-04-16 1799 * Cookie that has expired.
^1da177e4 Linus Torvalds 2005-04-16 1800 */
^1da177e4 Linus Torvalds 2005-04-16 1801 len = ntohs(chunk->chunk_hdr->length);
^1da177e4 Linus Torvalds 2005-04-16 1802 *errp = sctp_make_op_error_space(asoc, chunk, len);
^1da177e4 Linus Torvalds 2005-04-16 1803 if (*errp) {
52db882f3 Daniel Borkmann 2013-06-25 1804 suseconds_t usecs = ktime_to_us(ktime_sub(kt, bear_cookie->expiration));
34bcca283 Al Viro 2006-11-20 1805 __be32 n = htonl(usecs);
^1da177e4 Linus Torvalds 2005-04-16 1806
^1da177e4 Linus Torvalds 2005-04-16 1807 sctp_init_cause(*errp, SCTP_ERROR_STALE_COOKIE,
00f1c2df2 Wei Yongjun 2007-08-21 1808 sizeof(n));
00f1c2df2 Wei Yongjun 2007-08-21 1809 sctp_addto_chunk(*errp, sizeof(n), &n);
^1da177e4 Linus Torvalds 2005-04-16 1810 *error = -SCTP_IERROR_STALE_COOKIE;
^1da177e4 Linus Torvalds 2005-04-16 1811 } else
^1da177e4 Linus Torvalds 2005-04-16 1812 *error = -SCTP_IERROR_NOMEM;
^1da177e4 Linus Torvalds 2005-04-16 1813
^1da177e4 Linus Torvalds 2005-04-16 1814 goto fail;
^1da177e4 Linus Torvalds 2005-04-16 1815 }
^1da177e4 Linus Torvalds 2005-04-16 1816
^1da177e4 Linus Torvalds 2005-04-16 1817 /* Make a new base association. */
^1da177e4 Linus Torvalds 2005-04-16 1818 scope = sctp_scope(sctp_source(chunk));
^1da177e4 Linus Torvalds 2005-04-16 1819 retval = sctp_association_new(ep, ep->base.sk, scope, gfp);
^1da177e4 Linus Torvalds 2005-04-16 1820 if (!retval) {
^1da177e4 Linus Torvalds 2005-04-16 1821 *error = -SCTP_IERROR_NOMEM;
^1da177e4 Linus Torvalds 2005-04-16 1822 goto fail;
^1da177e4 Linus Torvalds 2005-04-16 1823 }
^1da177e4 Linus Torvalds 2005-04-16 1824
^1da177e4 Linus Torvalds 2005-04-16 1825 /* Set up our peer's port number. */
^1da177e4 Linus Torvalds 2005-04-16 1826 retval->peer.port = ntohs(chunk->sctp_hdr->source);
^1da177e4 Linus Torvalds 2005-04-16 1827
^1da177e4 Linus Torvalds 2005-04-16 1828 /* Populate the association from the cookie. */
^1da177e4 Linus Torvalds 2005-04-16 1829 memcpy(&retval->c, bear_cookie, sizeof(*bear_cookie));
^1da177e4 Linus Torvalds 2005-04-16 1830
^1da177e4 Linus Torvalds 2005-04-16 1831 if (sctp_assoc_set_bind_addr_from_cookie(retval, bear_cookie,
^1da177e4 Linus Torvalds 2005-04-16 1832 GFP_ATOMIC) < 0) {
^1da177e4 Linus Torvalds 2005-04-16 1833 *error = -SCTP_IERROR_NOMEM;
^1da177e4 Linus Torvalds 2005-04-16 1834 goto fail;
^1da177e4 Linus Torvalds 2005-04-16 1835 }
^1da177e4 Linus Torvalds 2005-04-16 1836
^1da177e4 Linus Torvalds 2005-04-16 1837 /* Also, add the destination address. */
^1da177e4 Linus Torvalds 2005-04-16 1838 if (list_empty(&retval->base.bind_addr.address_list)) {
f57d96b2e Vlad Yasevich 2007-12-20 1839 sctp_add_bind_addr(&retval->base.bind_addr, &chunk->dest,
f57d96b2e Vlad Yasevich 2007-12-20 1840 SCTP_ADDR_SRC, GFP_ATOMIC);
^1da177e4 Linus Torvalds 2005-04-16 1841 }
^1da177e4 Linus Torvalds 2005-04-16 1842
^1da177e4 Linus Torvalds 2005-04-16 1843 retval->next_tsn = retval->c.initial_tsn;
^1da177e4 Linus Torvalds 2005-04-16 1844 retval->ctsn_ack_point = retval->next_tsn - 1;
^1da177e4 Linus Torvalds 2005-04-16 1845 retval->addip_serial = retval->c.initial_tsn;
^1da177e4 Linus Torvalds 2005-04-16 1846 retval->adv_peer_ack_point = retval->ctsn_ack_point;
^1da177e4 Linus Torvalds 2005-04-16 1847 retval->peer.prsctp_capable = retval->c.prsctp_capable;
0f3fffd8a Ivan Skytte Jorgensen 2006-12-20 1848 retval->peer.adaptation_ind = retval->c.adaptation_ind;
^1da177e4 Linus Torvalds 2005-04-16 1849
^1da177e4 Linus Torvalds 2005-04-16 1850 /* The INIT stuff will be done by the side effects. */
^1da177e4 Linus Torvalds 2005-04-16 1851 return retval;
^1da177e4 Linus Torvalds 2005-04-16 1852
^1da177e4 Linus Torvalds 2005-04-16 1853 fail:
^1da177e4 Linus Torvalds 2005-04-16 1854 if (retval)
^1da177e4 Linus Torvalds 2005-04-16 1855 sctp_association_free(retval);
^1da177e4 Linus Torvalds 2005-04-16 1856
^1da177e4 Linus Torvalds 2005-04-16 1857 return NULL;
^1da177e4 Linus Torvalds 2005-04-16 1858
^1da177e4 Linus Torvalds 2005-04-16 1859 malformed:
^1da177e4 Linus Torvalds 2005-04-16 1860 /* Yikes! The packet is either corrupt or deliberately
^1da177e4 Linus Torvalds 2005-04-16 1861 * malformed.
^1da177e4 Linus Torvalds 2005-04-16 1862 */
^1da177e4 Linus Torvalds 2005-04-16 1863 *error = -SCTP_IERROR_MALFORMED;
^1da177e4 Linus Torvalds 2005-04-16 1864 goto fail;
^1da177e4 Linus Torvalds 2005-04-16 @1865 }
^1da177e4 Linus Torvalds 2005-04-16 1866
^1da177e4 Linus Torvalds 2005-04-16 1867 /********************************************************************
^1da177e4 Linus Torvalds 2005-04-16 1868 * 3rd Level Abstractions
:::::: The code at line 1688 was first introduced by commit
:::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2
:::::: TO: Linus Torvalds [off-list ref]
:::::: CC: Linus Torvalds [off-list ref]
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation Attachments
- .config.gz [application/octet-stream] 40104 bytes