Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3013634imm; Sun, 1 Jul 2018 10:18:15 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeFr1snUyTKpLhurY6FsJfvyWzgp6aLzgwgKJ+1uBpW63xpk2cFpAcoMpoLh31O8pBMsaRl X-Received: by 2002:a63:7c18:: with SMTP id x24-v6mr6644932pgc.311.1530465495775; Sun, 01 Jul 2018 10:18:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530465495; cv=none; d=google.com; s=arc-20160816; b=gjTKr34SVp53zduczO6YxaK+uCpECsRlA/+pgCxDNlbCnhPFhIFXytyddsn2Ur8G/+ SyW9oCaGCN4XCmUwG3hrxawxpJtIkTd0Uy6k7JVkmXrCdN3vkKckZ0AB8U6LUyxzhBZs bSNuN+eqDGiO8uTJ61KF0BrX8hcIC9FKckK6qBkbPBHxBUz4qCCcTZJB9HM1hjWwZD8s dB7KksH/o9aSnpPNg01SVqNYbpdD2G1KWWi55GxdlbDO3P2fXzRRjQIt2hPNCogUAxSm wEmIYRYbFY4zkfGqmP96RQqZjGkw8E1kqCAbLEDL6wnmJOojQEGqhYVTVweyTJVkrcTs VvsA== 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=3p7OUAc/DQYX/ys5kVJffFlpJVma75T1gbAXLR+iceU=; b=gOmrGGFzIUMwn6CnAoF2yPrdV1Ui0PDmyk++GK8j8MdjGPTUjf+SLhLJtRQC2Gv0/5 JBXw65eyX4V+PK43eBKKgqjcyRhvTNLB6RSABdP7WuWzRA6d/Cjtpd2imY4Ha5PBiLOU 66xr235sb8Aq0hGfTDRNg6MIhX0O+JzwZjCuKSSksMfsAuPWMteYMhANBZc0KZzFyOY3 OkXlpX3NGbfUnxINaLoGbmgvFun36SV6MePH9EczSk2H8RHi0BU2wWpNc/xDW+THkwMi Fc6OzsA3SoGnUj0gISXhFX2zC96sW7HESjSfgjxPYQzRgYWjINuaHCzCDpLPwiL4eWMZ YKKg== 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 q185-v6si13985462pfb.216.2018.07.01.10.18.01; Sun, 01 Jul 2018 10:18:15 -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 S1031762AbeGAQjf (ORCPT + 99 others); Sun, 1 Jul 2018 12:39:35 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36918 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031726AbeGAQj0 (ORCPT ); Sun, 1 Jul 2018 12:39:26 -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 7F6B5A73; Sun, 1 Jul 2018 16:39:25 +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.17 036/220] branch-check: fix long->int truncation when profiling branches Date: Sun, 1 Jul 2018 18:21:00 +0200 Message-Id: <20180701160909.841009088@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@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.17-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 @@ -21,7 +21,7 @@ void ftrace_likely_update(struct ftrace_ #define unlikely_notrace(x) __builtin_expect(!!(x), 0) #define __branch_check__(x, expect, is_constant) ({ \ - int ______r; \ + long ______r; \ static struct ftrace_likely_data \ __attribute__((__aligned__(4))) \ __attribute__((section("_ftrace_annotated_branch"))) \