From patchwork Tue Jul 26 12:28:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101987 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1660306qga; Tue, 26 Jul 2016 05:28:33 -0700 (PDT) X-Received: by 10.66.80.2 with SMTP id n2mr38755672pax.134.1469536113290; Tue, 26 Jul 2016 05:28:33 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p6si609153pfi.102.2016.07.26.05.28.32; Tue, 26 Jul 2016 05:28:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756124AbcGZM2a (ORCPT + 29 others); Tue, 26 Jul 2016 08:28:30 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:55333 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755392AbcGZM22 (ORCPT ); Tue, 26 Jul 2016 08:28:28 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue002) with ESMTPA (Nemesis) id 0MbGLz-1bkvts2S3n-00Kg1e; Tue, 26 Jul 2016 14:28:23 +0200 From: Arnd Bergmann To: Kees Cook Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [PATCH] lkdtm: fix maybe-uninitialized warning Date: Tue, 26 Jul 2016 14:28:08 +0200 Message-Id: <20160726122820.877422-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:J4EX7m/kLEwhBwY2IVLA9jpAOdIFu3AkXplql5nP5sSvcH41KxC 33z4tQx1i4i02bSPcpJjEazIruH07BV8zuzFSwj2uNwV7RdYgialKf+8gvx3Lu3d6uLOVkB YIPgaI6cYC0uQ1iHSEjoRpKd6EIe42hc0EOr0QzjPT9t3YPAbazHl1zmHn68PZT6ra3b4LV myfjYEmh1zMIb/nyGa79g== X-UI-Out-Filterresults: notjunk:1; V01:K0:K0UTHHKn2IM=:dQluIvVbtllIBU9Ckt08p9 pc1v/iRAfNc6SfXo/R+1P33LsBLhR5sEuBxsZe3xwCay8JBEfMd8BNy4nvGIHv2aUKzAE1Na+ LJr5mUaIHwVwWVmhQpvJMkRWF4njPIQb3lbwbcr4uAnEo8ZqIePVxQTTae+EpxLSfsduPxB+e beWIkVISBAoM4yr6DMvEkxiW06Bej3S2YLeFejOsQpJ+HKFOxw+/NXWUooAzank86IduyHAkJ 5ZsCeMZWqbMdrEhOsvEHT7488+u3nukqpFJHw1u/RIJKASrVm/hzDMKTy63d2ato9Fgj1we8L oHRbEnwVeuw7AQJ4k2be/DvRQPepG7XlKrLEdyZJlU/aV3WqmGhJ5y3N7y14HBH+4hFeOdra7 mCVVCaTzTubrnlxu9niBO85EUR68caWxpj8DKuksPvykk+VasPfyvT/+xmoQbb0bSl9+owAcM Y46dsAd5p2DDVfjcG8wMNBPX2p1eUgKDpuAiC8jaAzexsqr6eQmv3YQ+hdOwlWXRAinKN9+5Z WWYbmXun+e+zHrAJxxKu75ufFqmliqoI7zEiChh6SSa0750zXeMssXdeGzMglEoFt14v73aJL ENUw18eopQKDejQAchl5IsmXt6wysS0IhN9XHd3RgqO3+t4JFgRj1tcf52ZLk3ykBgkRt4wr3 q584Ikx0QyVJFFABhjC0pBXJi5Y9Agpcs4I9X1TB0ulbNT0wZJAcMIzLxjf4X3u7RGvg= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The do_usercopy_stack() function uses uninitialized stack data to initialize more of the stack, which causes a warning in some configurations (ARM allmodconfig): drivers/misc/lkdtm_usercopy.c:52:15: warning: 'bad_stack' may be used uninitialized in this function [-Wmaybe-uninitialized] The warning gets reports by Mark Brown's build bot and looks correct (we are trying to trick the compiler here, and sometimes the compiler notices), and I could reproduce it with gcc-4.7 through gcc-5.3 but not gcc-6.1 for some reason. This changes the code to use the low byte of the address of the stack to initialize the stack data, instead of using data from the stack itself, to avoid the warning. Signed-off-by: Arnd Bergmann Fixes: a3dff71c1c88 ("lkdtm: split usercopy tests to separate file") --- drivers/misc/lkdtm_usercopy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.0 diff --git a/drivers/misc/lkdtm_usercopy.c b/drivers/misc/lkdtm_usercopy.c index 5a3fd76eec27..5525a204db93 100644 --- a/drivers/misc/lkdtm_usercopy.c +++ b/drivers/misc/lkdtm_usercopy.c @@ -49,7 +49,7 @@ static noinline void do_usercopy_stack(bool to_user, bool bad_frame) /* This is a pointer to outside our current stack frame. */ if (bad_frame) { - bad_stack = do_usercopy_stack_callee((uintptr_t)bad_stack); + bad_stack = do_usercopy_stack_callee((uintptr_t)&bad_stack); } else { /* Put start address just inside stack. */ bad_stack = task_stack_page(current) + THREAD_SIZE;