In general, there are several candidates for the definition of $C^\infty(K)$: One is the space $\lbrace f|_K: f\in C^\infty(\mathbb R^n)\rbrace$ of all restrictions (endowed with the quotient topology), another is the intersection $\bigcap\limits_{k\in\mathbb N_0} \lbrace f|_K: f\in C^k(\mathbb R^n)\rbrace$ (which is equal to the former for $n=1$ due to Merrien but different in general, — an elementary example is in Wieslaw Pawlucki, On the algebra of functions $\scr C^k$-extendable for each $k$ finite, Proc. Amer. Math. Soc. 133 (2005), no. 2, 481--484. 481–484), and finally the probably best understood definition is that of Whitney jets, i.e. families $(f^{(\alpha)})_{\alpha \in \mathbb N_0^d}$ of continuous functions which satisfy the correct Taylor approximations on $K$ as if $f^{(\alpha)}=\partial^{\alpha} f$ for some $f\in C^\infty(\mathbb R^n)$.
If $K$ is the closure of its interior the definitions coincide and you should consult the literature about extension of Whitney jets. The article Leonhard Frerick, Extension operators for spaces of infinite differentiable Whitney jets, J. Reine Angew. Math. 602 (2007), 123--154.123–154, contains a lot of information. As mentioned by Deane Yang. Lipschitz boundary is enough for having a continuous linear extension operator (this is due to E.M. Stein). However, a sharp cusp like $K=\lbrace (x,y)\in [0,1]^2: y\le \exp(-1/x)\rbrace$ does not have such an extension. For general $K$ and the space of all restrictions, the question is wide open, besides the examples of Fefferman and Ricci mentioned by David Roberts there are some results of Dietmar Vogt, Restriction spaces of $A^\infty$, Rev. Mat. Iberoam. 30 (2014), no. 1, 65--7865–78.