Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2964924imm; Sun, 1 Jul 2018 09:17:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd1u05ZajO+OrMJUcXw/gokVEE1neKdSj8BxTSMGzrRkHG2X/lHr9dXCW8UXlvnFzSghP2E X-Received: by 2002:a62:1f8c:: with SMTP id l12-v6mr13514564pfj.143.1530461847962; Sun, 01 Jul 2018 09:17:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530461847; cv=none; d=google.com; s=arc-20160816; b=hIHPpfBr0QfSfwk8M6jMQRu5zokgshpK360CMwivBsk4EPTWfWfYJ4OfN907iUyhkz Cmg9yDi3yTwYXLiRjD2Em0qbId6+bshy1eScjXoy/V3hwi9XSCY9a3S6hs2njUe+Qbb7 /KIeRO523IJJzb7ISprAGkh+BCIDemPVsFfY43Qbm6++v/DhvhAPZgjAuWn+Zs0aej2c DEuI2SAL7cn8Sb6sMM/dKC1D9EVTEytzamRysCVx8HsooLwpJsyaSpqkB9tlbo2HvID0 oAy4+U7su7Necc8jXwLtX/IZNKIaxVWK+O9oXTfS9cHsxKPrpcq6c8YKqCYRc4sV2p3E Ow2Q== 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=GUWbCXW1bUOo37D7wiH2bBqt26DSt3c7YMjxLCcdBck=; b=CXWMGvwAYxPVOSddU3hRPsz9VtZKXNcy8EnYh7h5ofNkpwcxbsEE9rIoTagnVcmq5n 75tdREtBL120idCs+7NehbnqWXtfRye6WtKEpi33KXzrslsoLFOmhD6NeNJ2XX8mb9kd cKoCfhwyRHD4EhzctSILDskV+E58p8wv6keXM7kHH2Z7DjDQv5T4Li2WvWHAouo21Yzo JURVXz+e2Cp2Bqk2h5A8CmPHnOAbJqfjmjHraJJO5m0p9ZttrBLmVwP1YURUAiRUYNIY X2WKRbiShwnZBZf2UsCgtLpX2mPxRdwSVD4aUQU/M2/rjs4seL80pfEWXGmiZl2wboSI jJgg== 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 q79-v6si15061980pfk.268.2018.07.01.09.17.13; Sun, 01 Jul 2018 09:17:27 -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 S1752461AbeGAQPK (ORCPT + 99 others); Sun, 1 Jul 2018 12:15:10 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60500 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932926AbeGAQPH (ORCPT ); Sun, 1 Jul 2018 12:15:07 -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 62BF3ACC; Sun, 1 Jul 2018 16:15:06 +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 3.18 54/85] branch-check: fix long->int truncation when profiling branches Date: Sun, 1 Jul 2018 18:02:12 +0200 Message-Id: <20180701153124.510326197@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701153122.365061142@linuxfoundation.org> References: <20180701153122.365061142@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 3.18-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 @@ -105,7 +105,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"))) \