From patchwork Fri Jul 21 21:02:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 108512 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1269878qge; Fri, 21 Jul 2017 14:03:03 -0700 (PDT) X-Received: by 10.98.99.198 with SMTP id x189mr8741790pfb.180.1500670983456; Fri, 21 Jul 2017 14:03:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500670983; cv=none; d=google.com; s=arc-20160816; b=RGbp0a+b5JM5bcMRzZMqNBf8S+f9S7cnPAX3WfB+jkX7YYEt+IjE512TWUa8A3mNzk PiwE52vY+f+RcCN4UU9s5WEFKcLJEvwhDyQgi81s3fUefDhph4QCo5zv3kzS2DmQKtdC psvIXnhVs6uDuHtvEDiTGk+GHefROaK2mqqNd+sZkJB8+a72evaHsK6WkNlviXIrYy1A QipR0tBiL9IGJ7N+x2mkLNmVRKNKIE1NpAphDjpWjL6CaTAIZS/L/h8eviwpE6SbimpQ 1akbI5jCHGcQlILgvQSxEDZ/sCEUpSd9bulWA++s7smst9sqYf2MsMNl8FGD6aXTJHSY AL0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=0XcL4FiufgHmpBrALY1u/QTWIDWscEJKCMN+TFBgjh4=; b=GJGlb1VyQ62adjQBkGxi/lRxGj/W9MyhJn4TRtrNDuaE8E7e9D/CpfO6bdPmL5fig9 pFgsk2NUA0DLHNfABLvWYw4p+rfHv8k6OI0N2ZX1NisU/iyV+Xzlyp7iweTNkRjUI57B /PNaKI/lTDEtOodBXL+KhjJwJwbxTXi4q1APWxdrdmwmD2sc86SBeogh65VcdwyfiV2C qsvtZvchn2uTVxSVgq5ZXz7lNGAa+S6td68rlEUoykjsd0DMmJ/OY1wGqYwMUicqSaHJ nOyqmaVZcymZB4AtVL+0lxPggTETMju8Rng5b0gE4TTU8durVtRku/+s//W1XHxhtvba AO+A== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k33si3551086pld.163.2017.07.21.14.03.03; Fri, 21 Jul 2017 14:03:03 -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 S1754740AbdGUVC7 (ORCPT + 26 others); Fri, 21 Jul 2017 17:02:59 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:63950 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753502AbdGUVC6 (ORCPT ); Fri, 21 Jul 2017 17:02:58 -0400 Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0MI8Ug-1dbP9v1Kqk-003vYS; Fri, 21 Jul 2017 23:02:53 +0200 From: Arnd Bergmann To: Andrey Ryabinin Cc: Arnd Bergmann , Alexander Potapenko , Dmitry Vyukov , Andrew Morton , Andrey Konovalov , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] kasan: avoid -Wmaybe-uninitialized warning Date: Fri, 21 Jul 2017 23:02:37 +0200 Message-Id: <20170721210251.3378996-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:i9jbGBFlcNcL/JGkrVPTRh21O0hWJNfeH90wAkG+/KVOWV6yVmc Lg06ihX4iEGmiCnTYtbDALTFDybuT+JBt3JC7BzDFeDXdzb8gAV6Tq5fl+VYRkXC985Y3AX lIbTprPwjiUSDUUb3JQwChNi2BCc64IMhMOksoEGl1QXrzES93tP3q9GgCPqntx2BbdiZvu 2QV4v1VEeonc3GYlFCh2Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:r0DU0brELFs=:MSRxBhsSNTqsrFq8Zm+Sg8 2x9Pd0cYYAG2NSP5bpHBfbbpNtRgBwXyPQpef09kfR0Hj/glcmJd9YCSPx1h4rTTwbXgCcspX lOLys2cnrhVEU7mcgkDuLOcg6sWA/CW72wJE/E4qsb/Y6PtqsDSjEhMpeFWe5ksDMa+OPS25R +lEijYC79ErxVlXinp97izL5OEVZLbyYH9OSqpuCMhKVrHbEEp3wnAx5RkoUv/2ERlYQBIERd k3cKfS387Qh8weHE6Es1LWDXvtnqZaBej12+Hv2/q5fcw+j7vrC5YEL9ytsGlufgtHU18uXMM A6AgRMwqwtWRrMjJGSqa70vIXf377w3wNBZ8v0dRHKGx2nLBANIZlbumLi/A9Mt9KI6BPWqmb Mu2dFo1AnpiL3X/p8kbhSjOYGlyI6qWAbVhbj7skMilbQLgoge+9nKCoG8jEhCzB+J/eV0rMm LSlG13rchvyjR/Y0a9/DTTtOikyNbYSa13DHgP4ZNZyvGBdC282Vf/SaD5BYcmzd3S8ck8HGB dT8NzbkH9yXxY8PAj1hC4zJjPoCFLEBwjcTOBs01w79DwfC0TFR3OwIlZEuT8GwDeTsvJJ28B m1cfnwqMrt6X3ayyTJBi3O8x6GAJkWK6BFFs43fiV96V7gYoKKNp/fHY8shdDUOxfU7Fih5IZ oK1AFVbKluWeHYeVK1EXKfFY6nPbt2X9piKs9NJ+FuHdsHoeKUcOaE39+/9cnvPc0kU896Y/f DSOCZ5Bqod/tF9TuqqcrXA1jJWCp+ngThtqudg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org gcc-7 produces this warning: mm/kasan/report.c: In function 'kasan_report': mm/kasan/report.c:351:3: error: 'info.first_bad_addr' may be used uninitialized in this function [-Werror=maybe-uninitialized] print_shadow_for_address(info->first_bad_addr); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mm/kasan/report.c:360:27: note: 'info.first_bad_addr' was declared here The code seems fine as we only print info.first_bad_addr when there is a shadow, and we always initialize it in that case, but this is relatively hard for gcc to figure out after the latest rework. Adding an intialization in the other code path gets rid of the warning. Fixes: b235b9808664 ("kasan: unify report headers") Link: https://patchwork.kernel.org/patch/9641417/ Acked-by: Dmitry Vyukov Signed-off-by: Arnd Bergmann --- Originally submitted on March 23, but unfortunately is still needed, as verified on 4.13-rc1, with aarch64-linux-gcc-7.1.1 v2: add a comment as Andrew suggested --- mm/kasan/report.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.9.0 diff --git a/mm/kasan/report.c b/mm/kasan/report.c index 04bb1d3eb9ec..28fb222ab149 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -111,6 +111,9 @@ static const char *get_wild_bug_type(struct kasan_access_info *info) { const char *bug_type = "unknown-crash"; + /* shut up spurious -Wmaybe-uninitialized warning */ + info->first_bad_addr = (void *)(-1ul); + if ((unsigned long)info->access_addr < PAGE_SIZE) bug_type = "null-ptr-deref"; else if ((unsigned long)info->access_addr < TASK_SIZE)