Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2966735imm; Sun, 1 Jul 2018 09:19:50 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfcVdda42vdsYcTfuvVFIRw0RlulKBnSPcwlBN5c2mtlM4UNwhVwRktt0INOvv87K63a+YD X-Received: by 2002:a62:e903:: with SMTP id j3-v6mr22260226pfh.228.1530461990907; Sun, 01 Jul 2018 09:19:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530461990; cv=none; d=google.com; s=arc-20160816; b=Q0J/p9bJIjiTXjsGqCkxZLL2Fm1VobkuSdi30lFYkFYhadRfu+H/cxnebqm1f32L9D X40DpjeC7vWnMJZFCkS7Fv3O7Cmm1mqqwK+s5TYdC4dsFStsFKnzJERgDbGYu0lhC+TD E36GaIXfrCopHFkxtOz9oy5zen5dVrWwxaldf4iiPFwn01WgfdrFTcJMnpCUVlmjN6Ur GZKesuQrxCauLDGD7R5B9R38HidLKYBNvcKSPxRtLHw1yFQfg7TiNU/psf06TN5ZacSc uDot5yvG33m0F6a1UbqN2g+DPDl6Zv5Dol4YkR4A+RdlLUFBwELI9+NZ2BBxjRMTpMsu 8Dvw== 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=o71NuBi7wFWFDcEUsS61qzRF1GN0QRp0jvd/eJNH18w=; b=Ui9S45hCCFmDZFuHT8RogUC71tAPGZNp8U5OLNLbSyRnBA2RPGfA6Rmy/iHZvtMk3w r5FoPo7caW2YZtdXJ9Ey27KTKRl48eIP9hPZ6+2XgcVFxYVHna9DI0PyZ1k/x2f5cwR1 U0VPQdxuztew0wGxCD1YemF2n+l1++GAc3r4CFKdNlVNaiUmwqleOa8dhI6q4NAbHRuC sbhuhBaNmYHV/uhygCSx+oyoQcz9OntNiFBXgFkVCAnBs7QD7+9cJ8A1wPKd+AqWIwB0 Gmhqw4T3h+n8iuw8pWXbCyWFFWhIpJ/lFTV0vlMnskmDHMR6/EiCDnfpaUqkKlx5ao/h Jxgg== 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 u10-v6si12186241pgc.261.2018.07.01.09.19.36; Sun, 01 Jul 2018 09:19:50 -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 S964796AbeGAQRc (ORCPT + 99 others); Sun, 1 Jul 2018 12:17:32 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:32770 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932954AbeGAQRT (ORCPT ); Sun, 1 Jul 2018 12:17:19 -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 CD38692B; Sun, 1 Jul 2018 16:17:18 +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.4 037/105] branch-check: fix long->int truncation when profiling branches Date: Sun, 1 Jul 2018 18:01:47 +0200 Message-Id: <20180701153151.900623724@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701153149.382300170@linuxfoundation.org> References: <20180701153149.382300170@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.4-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 @@ -111,7 +111,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"))) \