Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1338919imm; Fri, 27 Jul 2018 15:45:14 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfwkVjK9FItYbeybhPsaMVJ5Xm7s+yu6aYiHBlHLhdjCYmZGcQl+002iQuIsfQlMAmxLxU9 X-Received: by 2002:a63:4f1a:: with SMTP id d26-v6mr7865077pgb.121.1532731514184; Fri, 27 Jul 2018 15:45:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532731514; cv=none; d=google.com; s=arc-20160816; b=AW/Dqo2sLmxYBWRj19ow1qSaUWhiWDI6AMqzVSG7O3I4KDvWeqfe6AQLCq5wRf5u2V qlktsb+IZTHPu6hDdFcVpYM/6s8J6Co9phPUtS/DidTy1PGu7QFxhLD47m1x5hO52tpt Zinu4sO88xLr2hlMnLZC3BQM4QWDO5eCS4SK8Ctz9JGB797EzOMvNNBLX0UVjLlKuuz/ D7UR/m/eHoCMqeR2D3x5HlnQyVZV8VmIcqGhxDfAmyjAiXyzn0Zz0pZj4gDn7OiD1kaP rMbTqjkkgV6W22/6tygrSH7zAHo8ylM9159NAubdc0i5qQe+zogm9d6VIx8NVINcc5z3 7Pyw== 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=lHNb2W+15FcTjTJNR8ymJ/LEpkmvgA15d7wOWrGq98I=; b=Oz90eB7pXVIGrDNRf2whNOlaXM+cfwv0Ans8l1+inPybbUnnlN3jwCcW9pG++oRW1b 6FkIwMZt9QecYT5AL8WWrtznZFTzIeepXEVKLiT07jxC0vFZ+SXrhWalz/EwDRmVabXS ooPG5zCzSyYgw2et42/okI8I3Cz2t1t4qSXPfl780XR5sgX1vK4THh0xtyAeAP70tihZ X8L2OiMHIoL8WQLWseaSGVrcR5x4Vvpi2hl2Idsg+No/FkA7WiKBu3J108rEc616zzFH Tg5rrhIQGcsz78PGxjrS4/zsW87YxDGXUCwWUQsdgcsuxSkQwp8oKsYysD1egKtfHv3m l7jA== 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 c38-v6si4502604pgb.489.2018.07.27.15.44.59; Fri, 27 Jul 2018 15:45:14 -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 S2389121AbeG1AIN (ORCPT + 99 others); Fri, 27 Jul 2018 20:08:13 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:36598 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389008AbeG1AIM (ORCPT ); Fri, 27 Jul 2018 20:08:12 -0400 Received: by mail-qt0-f196.google.com with SMTP id t5-v6so6691126qtn.3 for ; Fri, 27 Jul 2018 15:44:13 -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=lHNb2W+15FcTjTJNR8ymJ/LEpkmvgA15d7wOWrGq98I=; b=d4ojau/xe6A8Sx69ycYO5Zvzg6cnZ+n59m2tCLbqY7OhHZhjQl5usqwyylA0KJ0MqF E6nFGCygBzcr3wTAP5zT7k8Y5ySxbD0BeP+//VDasTeLbA6FK4AnmUOACFHw2O6h+R/w ZbLRv9PrIHdNayIbh4yhRNyFghbmcEVOQrqjBL3Esw6/Y+x+l9djv0Ink9/llF9k0Wrq LAAOrb3viwklG11J2PrN94AlowlpNuoqSCY89Xn+T5srDZP4yuMXiCXcF3b/jdNpru4l cQ4wozXaZqpMzRHCTgZJ1y8CbToaFMazln4dI/U85oFeR0AyTSlVKCBWKXymVx8s3VJG Jg5g== X-Gm-Message-State: AOUpUlFvkdE6XG+jI6Y2rN1tgLFNn64H9Q+IpbkHHwpzFKGoruGcoIrJ jnWGKMXk5S8cijYjYEtQOCIdsw== X-Received: by 2002:ac8:16dd:: with SMTP id y29-v6mr8220773qtk.34.1532731452758; Fri, 27 Jul 2018 15:44:12 -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:12 -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 2/2] net: socket: Fix potential spectre v1 gadget in sock_is_registered Date: Fri, 27 Jul 2018 22:43:02 +0000 Message-Id: <20180727224302.5503-3-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 'family' can be a user-controlled value, so sanitize it after the bounds check to avoid speculative out-of-bounds access. Cc: Josh Poimboeuf Cc: stable@vger.kernel.org Signed-off-by: Jeremy Cline --- net/socket.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/socket.c b/net/socket.c index f15d5cbb3ba4..608e29ae6baf 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2672,7 +2672,8 @@ EXPORT_SYMBOL(sock_unregister); bool sock_is_registered(int family) { - return family < NPROTO && rcu_access_pointer(net_families[family]); + return family < NPROTO && + rcu_access_pointer(net_families[array_index_nospec(family, NPROTO)]); } static int __init sock_init(void) -- 2.17.1