Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3327806imu; Sun, 11 Nov 2018 12:28:15 -0800 (PST) X-Google-Smtp-Source: AJdET5cZZNtx3qigMwZgt35PLefC8c7B9KT8nLRuAYWVewD7yE/naIlJOE5WhuSFEif1csTFSKKb X-Received: by 2002:a63:170c:: with SMTP id x12mr14653849pgl.364.1541968095608; Sun, 11 Nov 2018 12:28:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541968095; cv=none; d=google.com; s=arc-20160816; b=vtN0qg3maoA03dmlhUBGWtLcSXYNcWuqbAyLnr4ruMSAVEwZqeI3MyVjVSHIZPZIcb 4gpbiEKj038irmBP3orOqt3AynvT4bpfiXg5Mpp8gShcZYwbysXmKhtmDLd9n88GOwZ9 NZuAU9Lb7BKGpgNLIXwYrPs1gr/pJB/o5MJO3GFBKuArhLE/ywFJefVExNNhgk6pgsol fuP6GaV+6L9yfMHNNWIfEPWzqLOkY+4Mi5bZBgh8272P+UmzpnZQVWqZs43t+C9QFttf 7Rfm5zsRRe4LC8g8P8J0rO3UCUjfkBlUd8pzfqK54u6wn4pyTPNGRjBa7UIfYqZhn8jP epkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=iRtcRFbF52qlKoX8lV0IknmMp+hUMyR/YRwPZLw6lRE=; b=k8SwqfLl+5n9idg/y0vkhtlHVi+LOV67GCt9t88BJbWrKmKb7QJ1WfPUE9IMiYXrW0 nFCCwFxHc+J2Vfrs9iWN8cmVQcIZ83Kzfbel3SqYFUYxrHSYIoZEAjwEaRuz2/w+EpUf K5mTq478ROLYsSgY3HMPKPN5z02UNJftZIM/ZVV0SakprN8UEfkbfXVv5uO/mswhig7c KIzI+uAMn9QdhnSTlyCqP3KCP78mZZq/gW96lMyGh8TygPQbsyj98RRBvmGLSJOn4UMu 9evxFBasaaZFfIHfbidBsepTatlRqnpyStwPl7bmk6QPxClGc0sUD/ajmOoHmgQizDKM mV0Q== 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 d5-v6si15958095pla.80.2018.11.11.12.28.00; Sun, 11 Nov 2018 12:28:15 -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; 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 S1730678AbeKLGQ5 (ORCPT + 99 others); Mon, 12 Nov 2018 01:16:57 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:50810 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730597AbeKLFs0 (ORCPT ); Mon, 12 Nov 2018 00:48:26 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvsl-0000lF-EH; Sun, 11 Nov 2018 19:58:55 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsY-0001nK-Ls; Sun, 11 Nov 2018 19:58:42 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Josh Poimboeuf" , "David S. Miller" , "Jeremy Cline" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 300/366] net: socket: fix potential spectre v1 gadget in socketcall In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Jeremy Cline commit c8e8cd579bb4265651df8223730105341e61a2d1 upstream. '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 Signed-off-by: Jeremy Cline Signed-off-by: David S. Miller Signed-off-by: Ben Hutchings --- net/socket.c | 2 ++ 1 file changed, 2 insertions(+) --- a/net/socket.c +++ b/net/socket.c @@ -89,6 +89,7 @@ #include #include #include +#include #include #include @@ -2494,6 +2495,7 @@ SYSCALL_DEFINE2(socketcall, int, call, u if (call < 1 || call > SYS_SENDMMSG) return -EINVAL; + call = array_index_nospec(call, SYS_SENDMMSG + 1); len = nargs[call]; if (len > sizeof(a))