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 <cite authors="Wieslaw Pawlucki" mrnumber="2093071" cite="_Proc. Amer. Math. Soc._ **133** (2005), no. 2, 481--484 (electronic)">_Wieslaw Pawlucki_, [**On the algebra of functions $\scr C^k$-extendable for each $k$ finite**](http://dx.doi.org/10.1090/S0002-9939-04-07756-1), _Proc. Amer. Math. Soc._ **133** (2005), no. 2, 481–484</cite>), 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 <cite authors="Leonhard Frerick" mrnumber="2300454" cite="_J. Reine Angew. Math._ **602** (2007), 123--154">_Leonhard Frerick_, [**Extension operators for spaces of infinite differentiable Whitney jets**](http://dx.doi.org/10.1515/CRELLE.2007.005), _J. Reine Angew. Math._ **602** (2007), 123–154</cite>, 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 <cite authors="Dietmar Vogt" mrnumber="3186931" cite="_Rev. Mat. Iberoam._ **30** (2014), no. 1, 65--78">_Dietmar Vogt_, [**Restriction spaces of $A^\infty$**](http://dx.doi.org/10.4171/RMI/769), _Rev. Mat. Iberoam._ **30** (2014), no. 1, 65–78.</cite>