Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp339709ybl; Fri, 9 Aug 2019 06:49:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPIfLTYUuSgXkJ4xyS+ZDJKF3D2xjXR3aWk2Kyx9KjBGNn6Hpilh5NpiiMI9G/DIO5CjFe X-Received: by 2002:a63:fe52:: with SMTP id x18mr18301227pgj.344.1565358584277; Fri, 09 Aug 2019 06:49:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565358584; cv=none; d=google.com; s=arc-20160816; b=ukqv5wOfAvlvBg0x7Xdsbux6FlEzmtCVbFaK22GeA+WMdzCqN0yiQnFiwDa3XsAdyE ifrGIWQeEB//NK+eP+S+5m1GNvkgEa7SsFXDsscGfuBKDINcwoM20CTOcR12hCsyn9i6 zcwnsOjEHz0UZvIFpQlMPgm9YTf/fCAb3eSjRNhQ0E6Bb5Qiazru8i6E4BCG8ZbX7yCM 17JHHJHCOHcDFbzu8fNHOTRo/W9LNtd/xaMDUmmCUY+15l7D1IEim76KUVNXyrfs5Iic GVr22qdOdh1r/A4xaQZPGWYVzwc80r3xtc5MKJTbq1Vg+HZYS6b4XBzjByfBDeWaNSBF XIhA== 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=GM+nOcdyg+IE3AG5ymDANhLNrWb9m4arUaShfsNso7U=; b=ba8fMsz/RbYwmIceTwxhO8SCK9Rk7b1OoVz7RyDO8xWKotd1y5QKA/L2fikh21rQ3e v/ohcWGpnpRHLwYDnJC5QGSZQDxMsHsQHB/5zQNcQUzL/CFM58Z/PwZFy6sxoSvuo69U dawdWwRe0AUdFezzMaQBF7wkgwr+YYUDnu8SB6wyizzQ3H8bqUbse2IvKbLcHJ6GI3wG eUrA+6WXMC2JvZBb7cqklXE8ez+LV/5D99Pdus5MKFOEFqi1LrCmnQGI/xvmGE/z1r7R 0IkOt8XhD7hIwUr3Ln3lRmtvBxOgdyEssXQccGME7Tq93bz7h+44iL7zZchLGy13VPYH w4DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hIct4kHu; 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 z14si51117925plo.104.2019.08.09.06.49.28; Fri, 09 Aug 2019 06:49:44 -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; dkim=pass header.i=@kernel.org header.s=default header.b=hIct4kHu; 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 S2436669AbfHINsD (ORCPT + 99 others); Fri, 9 Aug 2019 09:48:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:38136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436660AbfHINr5 (ORCPT ); Fri, 9 Aug 2019 09:47:57 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 76DE1214C6; Fri, 9 Aug 2019 13:47:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565358477; bh=MTFwszCrmSaCj63SpvMh7Xi8g7NApYngPDhIgzx0W1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hIct4kHuOXH4Su1+mgLH2rgQjvCfoaTrvPjZjlXNRU7XQRsmjB2UotZhVdA6Ti0xp D+C5V/gXzFzVvnpNDsBfx5EajsNlMWpW6uOATlJo9kRJfX5KFyQ8NuSIzGBPPfsNRa lteoyluWjxTPLYOK2rqGp30wCmWkvz9sO0scjgbI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Gustavo A. R. Silva" , "David S. Miller" Subject: [PATCH 4.9 15/32] atm: iphase: Fix Spectre v1 vulnerability Date: Fri, 9 Aug 2019 15:45:18 +0200 Message-Id: <20190809133923.456414485@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190809133922.945349906@linuxfoundation.org> References: <20190809133922.945349906@linuxfoundation.org> User-Agent: quilt/0.66 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 From: "Gustavo A. R. Silva" [ Upstream commit ea443e5e98b5b74e317ef3d26bcaea54931ccdee ] board is controlled by user-space, hence leading to a potential exploitation of the Spectre variant 1 vulnerability. This issue was detected with the help of Smatch: drivers/atm/iphase.c:2765 ia_ioctl() warn: potential spectre issue 'ia_dev' [r] (local cap) drivers/atm/iphase.c:2774 ia_ioctl() warn: possible spectre second half. 'iadev' drivers/atm/iphase.c:2782 ia_ioctl() warn: possible spectre second half. 'iadev' drivers/atm/iphase.c:2816 ia_ioctl() warn: possible spectre second half. 'iadev' drivers/atm/iphase.c:2823 ia_ioctl() warn: possible spectre second half. 'iadev' drivers/atm/iphase.c:2830 ia_ioctl() warn: potential spectre issue '_ia_dev' [r] (local cap) drivers/atm/iphase.c:2845 ia_ioctl() warn: possible spectre second half. 'iadev' drivers/atm/iphase.c:2856 ia_ioctl() warn: possible spectre second half. 'iadev' Fix this by sanitizing board before using it to index ia_dev and _ia_dev Notice that given that speculation windows are large, the policy is to kill the speculation on the first load and not worry if it can be completed with a dependent load/store [1]. [1] https://lore.kernel.org/lkml/20180423164740.GY17484@dhcp22.suse.cz/ Signed-off-by: Gustavo A. R. Silva Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/atm/iphase.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/atm/iphase.c +++ b/drivers/atm/iphase.c @@ -63,6 +63,7 @@ #include #include #include +#include #include "iphase.h" #include "suni.h" #define swap_byte_order(x) (((x & 0xff) << 8) | ((x & 0xff00) >> 8)) @@ -2760,8 +2761,11 @@ static int ia_ioctl(struct atm_dev *dev, } if (copy_from_user(&ia_cmds, arg, sizeof ia_cmds)) return -EFAULT; board = ia_cmds.status; - if ((board < 0) || (board > iadev_count)) - board = 0; + + if ((board < 0) || (board > iadev_count)) + board = 0; + board = array_index_nospec(board, iadev_count + 1); + iadev = ia_dev[board]; switch (ia_cmds.cmd) { case MEMDUMP: