Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5392826rwd; Mon, 12 Jun 2023 04:38:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6xyxRT3tPh9MwP2QeBd7OBvLEgrao7cruItWGrCtT2QaZwzByIbYmOBjOMfYSWWf0Qzirq X-Received: by 2002:a17:907:6e93:b0:97e:f120:e58a with SMTP id sh19-20020a1709076e9300b0097ef120e58amr4839994ejc.29.1686569903294; Mon, 12 Jun 2023 04:38:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686569903; cv=none; d=google.com; s=arc-20160816; b=fAOoeLlsP1nQOcH9aOiBdqF+by+FvQGbRY5yTGmN7tHznY0mu8+GWE2vqVA4N2uLgJ 1033DmMNi19B9r5Ta+SuUYgXtNGIfCWZu9GiGppWaQjzkC3kWyFmMV/3biCZjcsrE6uY 8825KcNZYRDv4AGppxEWWxiWn7vRR4DHr7o2AgPqv9YiofrLmxICopXsKPT+KSFLa5dg 3SekpS8bUnsC1CtptmgOXMHuMLDBXYkBqcD7XbYuQ4GnNNXMuQvO1dFQ7OQS9n0FCxDZ CGu95ifpLYp7rjNlfQToTQoPC+WVtqvFY15SfJj8uIPDb4iV3PM1lcG3SuKSMFj4GdO4 d0eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=vrffFIflVwj3iZ+X66V28jAT+UhtEyNmsUk1C8j7Lso=; b=uVfm8+p2B8q3cL8m5QoCPcnSHtfWnyy/3gp6OaBY6xuqYqQim6FX11exm4OY+0fJlo S8J42FKbpOBYbO9frQ3RJk3YpODY2AaGbFlQo6nF6KOe6GLtyguBYI5+kcFd1v/oZ/+3 FWieWHr4LVJirduLTywSJtHRRMVwUv4iy70/V/V0qoQEm3U5BbzGWAap/iQ6kV6nsa2e 8i0qbSGvzL0fs0yopr6LHcGRjG6ZDDzpZejnEf5dtXo7D99Oy0ylVZal9i6mvDZXwwAs xHe+wZia5YLirWZ5Y9Fpou+RpVPI74+IYSAeqHNQR5oWjyncJuTAWi+JB4HZC/XK5J2c /0Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=7yfLE6ek; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o10-20020a17090611ca00b0096f560fb6absi1758581eja.822.2023.06.12.04.37.58; Mon, 12 Jun 2023 04:38:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=7yfLE6ek; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237401AbjFLLMa (ORCPT + 99 others); Mon, 12 Jun 2023 07:12:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236745AbjFLLMO (ORCPT ); Mon, 12 Jun 2023 07:12:14 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26DE64491 for ; Mon, 12 Jun 2023 04:01:14 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-bacd408046cso6315626276.3 for ; Mon, 12 Jun 2023 04:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686567654; x=1689159654; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=vrffFIflVwj3iZ+X66V28jAT+UhtEyNmsUk1C8j7Lso=; b=7yfLE6ekqah/BETX2ejMRMU2HbxV+1ZKcTluxq1DmcKbbDcbnGGdVLqdUTvDqm24Ps jnPNtbmrm0WmOKyryH2cAteq3HcpL+ZVGXWX0XGs1BDHRXBf7rWUm/rp02EOYHMR8/Ul Wzh0iE9doj+UPTtGcEzPoBlfmX/GKwKUos6zTdE0lGNBWJvjW/JRgNoXLQsXZNRZd3Kk g5EdhuLvdBfPDDAGiCxtGqgmN4bgE71rjvmRD6ZO4JfPC8lsXoMGx8rEpk2n6mKw7LCX IHJGAJUeR/KaaM7YCfDh6ddekBLuIhfi1wHiPQgaiJRdMMapnIsl8/9Mhx94G/khcbpt x/OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686567654; x=1689159654; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vrffFIflVwj3iZ+X66V28jAT+UhtEyNmsUk1C8j7Lso=; b=axuw53g0f+zdHoHklfNkrpO7pI8zEev1dCeYHFOjOG5G1D3Lbc7zehhXerG930ivpP l8LO9u6nmEtRjW1NUoDdi3cHvI9sRc+O5GNxsfqefeUc31ROEeGHHgopqJKi7JDlQ+8X Ohhm3akJTSqYFE235Bnw7YS1UmwyMh2AjAzHKErbAIebY0LgbEGsVHARKzdWdDyqbQen czBieausZrfcOa3NIqCE+7RV1JMsXol9AIvtH1u14vt5Pxv0iUlnTo9yWYnDYB1+0Rot TMlvawurU2/wcEXw8hOZJrx6Kpe2DjX7v6I1C0w0wu2VowWtciK3cGPkYtTRAE0WEpyH TmGg== X-Gm-Message-State: AC+VfDwZ3HFvBM/WClLWjRrbowLHDNnpYrTUgmdavbb4c7H7KBrXdEGM gcShr1Vqcq6Xq2DWa3g5uzPgtWyW1klOLenmO8juWJwrFcCu+S0hJLT+vMQxbEhTf8iPIMX9OKR 0rGaFA2eJE3LJQFJ2dUIvaFZIys8aI1T3WsM4pP4gdeVUhTVjlvlkb0Zkajw07mfr87DsgIrf7n U6y+K8 X-Received: from jordy-spec.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:f2f]) (user=jordyzomer job=sendgmr) by 2002:a5b:7c4:0:b0:bc5:2869:d735 with SMTP id t4-20020a5b07c4000000b00bc52869d735mr3201011ybq.13.1686567653910; Mon, 12 Jun 2023 04:00:53 -0700 (PDT) Date: Mon, 12 Jun 2023 11:00:40 +0000 In-Reply-To: <20230612110040.849318-1-jordyzomer@google.com> Mime-Version: 1.0 References: <20230612110040.849318-1-jordyzomer@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230612110040.849318-2-jordyzomer@google.com> Subject: [PATCH v2 1/1] cdrom: Fix spectre-v1 gadget From: Jordy Zomer To: linux-kernel@vger.kernel.org Cc: phil@philpotter.co.uk, Jordy Zomer Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch fixes a spectre-v1 gadget in cdrom. The gadget could be triggered by, speculatviely bypassing the cdi->capacity check. Signed-off-by: Jordy Zomer --- drivers/cdrom/cdrom.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 416f723a2dbb..ecf2b458c108 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c @@ -264,6 +264,7 @@ #include #include #include +#include #include #include #include @@ -2329,6 +2330,9 @@ static int cdrom_ioctl_media_changed(struct cdrom_device_info *cdi, if (arg >= cdi->capacity) return -EINVAL; + /* Prevent arg from speculatively bypassing the length check */ + barrier_nospec(); + info = kmalloc(sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; -- 2.41.0.162.gfafddb0af9-goog