Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2279486imb; Mon, 4 Mar 2019 00:36:44 -0800 (PST) X-Google-Smtp-Source: APXvYqx1CFm/bTcutulPrjq+oN+W3hFRSZsxB69fPICoTxyLXs+nelgSVCPzNwXUkgUskpWRkcNh X-Received: by 2002:a62:574d:: with SMTP id l74mr19287267pfb.9.1551688604737; Mon, 04 Mar 2019 00:36:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551688604; cv=none; d=google.com; s=arc-20160816; b=Avm6mXgtdCYULBw2g3WuJ49tiklA1R0xYax2RALNxRTnL9/E+pc24XleJ4qQ4abaTL 3EvBxUh/hViWJIojxrAd9ZqjJWXsHI+7FgWMSdv1GgMYz9Brvq9nt7qEtBaPPwXEGefz pwghnFDgrqr9EDm7lzzr5w+v2DV8PFX0KqmjTvlkVjCL/Rx+q7uFnLJVfFnV9g4k4S3N FOoXTK/k+0/OCb2t/gcROmHzRca0i/UeIQyc5buLCkYcbc+nTDwJ4Q/XKDZ9nzJ5NIVJ cTfabRbq58vAzRNrSxh952E+Uiq6qWfe3s+slIWNQh3k3OPYLBpF/cPgXJ7O7Ycw4188 Ov/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VjoUrGc8uhCEATRZwO7kY4t3jtvWrPi+5nc05cvDiNM=; b=yHl3qWt9pUl/d2RDYhGKK+t6ov0pZEnsqWTP+onLM4OF1jXrv87TyMa+axVOpEk6vA Q7fgId5YDftt0OKg2fiAySzXahf4oE2py3RYJkeaSQlHflbiJsjnEJw234dAz5TlSm6T Ojx12GNvOXU4uZMW6DjreLCXOhuq9uok0MBwsi06BD8voNktjdwPRsfoFLJURHeMT7CZ +i1FrnTuJJQipbfw6ecDPOpCkbdbVHlz+da8MM7mPbHfgEX0Hfx4gBD8zs+coPuvToES AQO2QO6+RqqN+fJNeXkNhXL0GenunVMeRfqwGiUXMG0uU1gCehpVF7wSA1P6J8Vcx3Jx FT3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kxEuEFRS; 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 d18si1086892pll.436.2019.03.04.00.36.29; Mon, 04 Mar 2019 00:36:44 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=kxEuEFRS; 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 S1728525AbfCDIf5 (ORCPT + 99 others); Mon, 4 Mar 2019 03:35:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:44384 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726738AbfCDIfy (ORCPT ); Mon, 4 Mar 2019 03:35:54 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C50BE20836; Mon, 4 Mar 2019 08:35:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551688553; bh=vA/5Uu1z+XNB6p6M2/VUIVP3yVRueMTxRYUhsFPBAWc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kxEuEFRSYRnuQFfPvxnSF0pujQeFFW5zNZHk/8YPzJP/WLduUCj/eNgVF32BvAmCi +u4YfhXlnh6rHIXuu6f7EwnJIxRTrOUGDEOoxJ9fbr3/ME7hP8l+qg2CO+LYpew1JS G8BW2ho8EujFixUrGkC9zLx9d8ddejrcyeuj/RJs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, RISC-V Patches , Linux RISC-V , Linux MIPS , Michael Clark , Paul Burton Subject: [PATCH 4.20 79/88] MIPS: fix truncation in __cmpxchg_small for short values Date: Mon, 4 Mar 2019 09:23:02 +0100 Message-Id: <20190304081633.795783861@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190304081630.610632175@linuxfoundation.org> References: <20190304081630.610632175@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Clark commit 94ee12b507db8b5876e31c9d6c9d84f556a4b49f upstream. __cmpxchg_small erroneously uses u8 for load comparison which can be either char or short. This patch changes the local variable to u32 which is sufficiently sized, as the loaded value is already masked and shifted appropriately. Using an integer size avoids any unnecessary canonicalization from use of non native widths. This patch is part of a series that adapts the MIPS small word atomics code for xchg and cmpxchg on short and char to RISC-V. Cc: RISC-V Patches Cc: Linux RISC-V Cc: Linux MIPS Signed-off-by: Michael Clark [paul.burton@mips.com: - Fix varialble typo per Jonas Gorski. - Consolidate load variable with other declarations.] Signed-off-by: Paul Burton Fixes: 3ba7f44d2b19 ("MIPS: cmpxchg: Implement 1 byte & 2 byte cmpxchg()") Cc: stable@vger.kernel.org # v4.13+ Signed-off-by: Greg Kroah-Hartman --- arch/mips/kernel/cmpxchg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/arch/mips/kernel/cmpxchg.c +++ b/arch/mips/kernel/cmpxchg.c @@ -54,10 +54,9 @@ unsigned long __xchg_small(volatile void unsigned long __cmpxchg_small(volatile void *ptr, unsigned long old, unsigned long new, unsigned int size) { - u32 mask, old32, new32, load32; + u32 mask, old32, new32, load32, load; volatile u32 *ptr32; unsigned int shift; - u8 load; /* Check that ptr is naturally aligned */ WARN_ON((unsigned long)ptr & (size - 1));