Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3063596imm; Sun, 1 Jul 2018 11:23:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIiV+h+XlIbnKLp+nN+AhyHnGQvwH0CneMyLrD/ugCLr0U/sw+gesieMwuTq0osaw9ha7qs X-Received: by 2002:a17:902:be0b:: with SMTP id r11-v6mr23688522pls.182.1530469397939; Sun, 01 Jul 2018 11:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530469397; cv=none; d=google.com; s=arc-20160816; b=zMpBe00xQpY12wUI4a60UvpIaTaH9//STRdHuJpO4nlcIrKypZzFRCaYuvLHz6uv9e ppC5Qya9Ep8Nr5yrhAsYKgZkPNJDXvwPn63/YnyDSYiRWsj6HeJi1Vw4LrFrWmJ2o3Sb +MESQ19LaKj/mRJfRH/Lu2UEJceKAv6QnnSwzclGYApAGjV6p9mWK3hJuNhCNWsirbXe Vr8qVC9KLusufZJ5rlmnZhnW5w7RGiBr/dyFXKOgRvj1UVEOhHVLxPxbmU7yJI0cOb5n K7NR9z+CicgznS17hhRgbUvAswHDlHwmTDQb4madl1T/WTvjZ/c2XG3O6rN/QoRPSP4/ o8UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=nN/r7xCqwtb7SG+AvT40nRQcHsRqD+K0byhwUHIWjrM=; b=SWse6hJQsnxL8mycbVzFs+UffT10lwpenY5mhsvGqPsRdJubNAgsTKZEES/3Ww+cM4 yotJzbtzTmRhI6wQZy3ABp0QmGSFKk+dgPPJ+ZtKIx3KWThALSapY1unsaTgcwWTh8YZ K5sYv1uYR3CZ9/dG93L0o4ZbmQljJL2JksCo/ugJn4PtJoMBaAWuINywv/9k54yt4fbx udZwad0wWB1oiQEDvwK81zPNEcSsdaFYrGAcupKVMFYAlhu+qfcs0Hf2EVpM1Hixwum9 cKxiwRvw/bUyum+429L8qeUl/gw0y4/tniDfFD3vT4LVOCOdjEUgHHMf7+rCDkAeIo7E wnHQ== 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 a5-v6si3447738pll.412.2018.07.01.11.23.03; Sun, 01 Jul 2018 11:23:17 -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 S934201AbeGASVv (ORCPT + 99 others); Sun, 1 Jul 2018 14:21:51 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33538 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965203AbeGAQYn (ORCPT ); Sun, 1 Jul 2018 12:24:43 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id BDD7FAE0; Sun, 1 Jul 2018 16:24:42 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ingo Molnar , Mikulas Patocka , "Steven Rostedt (VMware)" Subject: [PATCH 4.9 018/101] branch-check: fix long->int truncation when profiling branches Date: Sun, 1 Jul 2018 18:21:04 +0200 Message-Id: <20180701160757.866490495@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160757.138608453@linuxfoundation.org> References: <20180701160757.138608453@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mikulas Patocka commit 2026d35741f2c3ece73c11eb7e4a15d7c2df9ebe upstream. The function __builtin_expect returns long type (see the gcc documentation), and so do macros likely and unlikely. Unfortunatelly, when CONFIG_PROFILE_ANNOTATED_BRANCHES is selected, the macros likely and unlikely expand to __branch_check__ and __branch_check__ truncates the long type to int. This unintended truncation may cause bugs in various kernel code (we found a bug in dm-writecache because of it), so it's better to fix __branch_check__ to return long. Link: http://lkml.kernel.org/r/alpine.LRH.2.02.1805300818140.24812@file01.intranet.prod.int.rdu2.redhat.com Cc: Ingo Molnar Cc: stable@vger.kernel.org Fixes: 1f0d69a9fc815 ("tracing: profile likely and unlikely annotations") Signed-off-by: Mikulas Patocka Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- include/linux/compiler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -113,7 +113,7 @@ void ftrace_likely_update(struct ftrace_ #define unlikely_notrace(x) __builtin_expect(!!(x), 0) #define __branch_check__(x, expect) ({ \ - int ______r; \ + long ______r; \ static struct ftrace_branch_data \ __attribute__((__aligned__(4))) \ __attribute__((section("_ftrace_annotated_branch"))) \