From nobody Tue Jun 30 00:06:34 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 677D9C433EF for ; Sat, 29 Jan 2022 14:37:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234478AbiA2Oht (ORCPT ); Sat, 29 Jan 2022 09:37:49 -0500 Received: from h2.fbrelay.privateemail.com ([131.153.2.43]:45151 "EHLO h2.fbrelay.privateemail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230431AbiA2Oho (ORCPT ); Sat, 29 Jan 2022 09:37:44 -0500 Received: from MTA-12-4.privateemail.com (mta-12-1.privateemail.com [198.54.122.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by h1.fbrelay.privateemail.com (Postfix) with ESMTPS id 2B2201806B6E for ; Sat, 29 Jan 2022 09:37:43 -0500 (EST) Received: from mta-12.privateemail.com (localhost [127.0.0.1]) by mta-12.privateemail.com (Postfix) with ESMTP id 722A818000AE; Sat, 29 Jan 2022 09:37:41 -0500 (EST) Received: from localhost.localdomain (unknown [10.20.151.157]) by mta-12.privateemail.com (Postfix) with ESMTPA id 168591800350; Sat, 29 Jan 2022 09:37:39 -0500 (EST) From: Jordy Zomer To: linux-kernel@vger.kernel.org Cc: Jordy Zomer , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com Subject: [PATCH] dm ioct: prevent potential specter v1 gadget Date: Sat, 29 Jan 2022 15:37:22 +0100 Message-Id: <20220129143722.3460829-1-jordy@pwning.systems> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" It appears like cmd could be a Spectre v1 gadget as it's supplied by a user and used as an array index. Prevent the contents of kernel memory from being leaked to userspace via speculative execution by using array_index_nospec. Signed-off-by: Jordy Zomer Reported-by: kernel test robot --- drivers/md/dm-ioctl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index 21fe8652b095..0c1f9983f080 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -1788,6 +1788,7 @@ static ioctl_fn lookup_ioctl(unsigned int cmd, int *i= octl_flags) if (unlikely(cmd >=3D ARRAY_SIZE(_ioctls))) return NULL; =20 + cmd =3D array_index_nospec(cmd, ARRAY_SIZE(_ioctls)); *ioctl_flags =3D _ioctls[cmd].flags; return _ioctls[cmd].fn; } --=20 2.27.0