Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1339077imm; Fri, 27 Jul 2018 15:45:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe3KfeWvtHssy1TfstpztwVgPX3CBqzh5FDXj1k/LUwUmtZ2unBYVNPEk0rOLl1Z4BA0llk X-Received: by 2002:a17:902:24e:: with SMTP id 72-v6mr7603995plc.74.1532731525843; Fri, 27 Jul 2018 15:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532731525; cv=none; d=google.com; s=arc-20160816; b=TDc4s1cHdzrFfuEUKfwR/jZ3K7f5dhUwMNQbMY8Q3yWhN2m0TwUxvuDbn68S6AefKK D95/wfoYCqSLf6Z+7eRMoWxHnbYqaZ+GUJKIu/721es1Bs7pHd8aX0MDzzrszBY9PVPM DmpcpvcRA/LoxCkfOlUbdOsReGBJWMZGls4lTbX0zbkNbQ0enQQHkeXKDyb+jFWST8Gc 7pNRHWrDaVw72M5d7fqyp/2Ww0ylcfry7Xa5kZMgRXH5geF6jRLl37FZfGOrwBT1DuFh QU+MBo9rAW1jzYgpmA37ZMYRlLVJyII5TIvYOpr7eLsqqkOlZUQ4CdeA4mGoRXNv4pF7 9neA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=pd6ZmRSgLE92x+1U96PwNyZnjb7+K9HaXjCFa/rvXf0=; b=a0wFLKwR8zlnWYtiaS8RPSOXUa5h0nQj3c09zPurU070UnYLD5DegqMm1wn4aAFATw pZRX/rIhb7olMRNNTMcL3v19tze6PQq/3cS5TP3aF96i6Za10WMQv5zUKwaoH0Zi+cIy F7ZBuhrD/Hd8rLgEJZz9CHAQjKVh6T3V4gudW3XWX6ZhyWsEaWOQSlYA4bQIwbwqnhZr 2Zw0wLKQuRFSWE+C27QS/YU87hSDGv+t0kQup7QZR4L5V4DruHs8pbPYQPPDCnaYrD7g lKBkwZQB7AqHBmHpf4EsJVqZI4oC919ZD6/m+aHDHb1GxGV7M0Ri5Z3rDCjHr8zoqc+H 0JRQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v35-v6si4411302plg.117.2018.07.27.15.45.11; Fri, 27 Jul 2018 15:45:25 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389067AbeG1AIM (ORCPT + 99 others); Fri, 27 Jul 2018 20:08:12 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:42470 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388994AbeG1AIL (ORCPT ); Fri, 27 Jul 2018 20:08:11 -0400 Received: by mail-qt0-f195.google.com with SMTP id z8-v6so6681848qto.9 for ; Fri, 27 Jul 2018 15:44:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pd6ZmRSgLE92x+1U96PwNyZnjb7+K9HaXjCFa/rvXf0=; b=XxjcHDvdJvLfXbxAC+IrCbPRd82fKI+03hoT8i3UjjFF1WqJ7u7p0+0jQTTgja4gDh 1SmaWlTERHdu7WDgWLQUpSQDqm1WQupqVwbLEq6Oc2Eu37RYsOWjKXD0EJAwWEAJU91G tWsY7/y1P0A/FipOeS38yI36/sxooIV0WUgWSPKuVclhZBqMgGt90dIyhalQ1GfLFrLV TIbTqkaenTYbJ0Ku9/gqaYOT8bVEsfW6OdzO85ahYG4twL5wISvvY7ju+qzdZtYcghpd nVf33Stl1JfEUNHGfyklc1sqEz/um0woyqR4gOtpmLFoKyNdiv2Q/iUHrO6IqMugcfsX HJ5Q== X-Gm-Message-State: AOUpUlEj3dPcavTaMjUaNrg4Aw6/3YnbFYSWBoKY/sUMGfYvFM9P4dMC RSVmemgO8CX3HsqNiw9Fq8UFEL0661E= X-Received: by 2002:ac8:3a6:: with SMTP id t38-v6mr8096769qtg.68.1532731451904; Fri, 27 Jul 2018 15:44:11 -0700 (PDT) Received: from builder.jcline.org.com ([2605:a601:80ce:4700:77a5:8983:ea8b:82ec]) by smtp.gmail.com with ESMTPSA id g39-v6sm4145984qtb.47.2018.07.27.15.44.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Jul 2018 15:44:11 -0700 (PDT) From: Jeremy Cline To: "David S . Miller" Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Josh Poimboeuf , Jeremy Cline , stable@vger.kernel.org Subject: [PATCH 1/2] net: socket: fix potential spectre v1 gadget in socketcall Date: Fri, 27 Jul 2018 22:43:01 +0000 Message-Id: <20180727224302.5503-2-jcline@redhat.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180727224302.5503-1-jcline@redhat.com> References: <20180727224302.5503-1-jcline@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'call' is a user-controlled value, so sanitize the array index after the bounds check to avoid speculating past the bounds of the 'nargs' array. Found with the help of Smatch: net/socket.c:2508 __do_sys_socketcall() warn: potential spectre issue 'nargs' [r] (local cap) Cc: Josh Poimboeuf Cc: stable@vger.kernel.org Signed-off-by: Jeremy Cline --- net/socket.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/socket.c b/net/socket.c index 3015ddace71e..f15d5cbb3ba4 100644 --- a/net/socket.c +++ b/net/socket.c @@ -89,6 +89,7 @@ #include #include #include +#include #include #include @@ -2504,6 +2505,7 @@ SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args) if (call < 1 || call > SYS_SENDMMSG) return -EINVAL; + call = array_index_nospec(call, SYS_SENDMMSG + 1); len = nargs[call]; if (len > sizeof(a)) -- 2.17.1