public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Hongling Zeng <zenghongling@kylinos.cn>
Cc: dpenkler@gmail.com, jkoolstra@xs4all.nl, lukeyang.dev@gmail.com,
	viro@zeniv.linux.org.uk, kees@kernel.org,
	harshit.m.mogalapalli@oracle.com, colin.i.king@gmail.com,
	linux-kernel@vger.kernel.org, zhongling0719@126.com
Subject: Re: [PATCH] gpib: fix spectre v1 vulnerabilities in descriptor handling
Date: Fri, 24 Apr 2026 11:35:35 +0200	[thread overview]
Message-ID: <2026042403-deceit-clamor-62e0@gregkh> (raw)
In-Reply-To: <20260424090012.13055-1-zenghongling@kylinos.cn>

On Fri, Apr 24, 2026 at 05:00:12PM +0800, Hongling Zeng wrote:
> Fix potential Spectre v1 vulnerabilities in the GPIB driver's
> descriptor handling code. The issues occur when using user-controlled
> handle values as array indices after bounds checking.
> 
> Use array_index_nospec() to prevent speculative execution from
> bypassing the bounds check, which could leak information via
> side-channel attacks.
> 
> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
> ---
>  drivers/gpib/common/gpib_os.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpib/common/gpib_os.c b/drivers/gpib/common/gpib_os.c
> index 5909274ddc12..ff4019d51b51 100644
> --- a/drivers/gpib/common/gpib_os.c
> +++ b/drivers/gpib/common/gpib_os.c
> @@ -19,6 +19,7 @@
>  #include <linux/string.h>
>  #include <linux/vmalloc.h>
>  #include <linux/fcntl.h>
> +#include <linux/nospec.h>
>  #include <linux/kmod.h>
>  #include <linux/uaccess.h>
>  
> @@ -1312,6 +1313,8 @@ static int close_dev_ioctl(struct file *filep, struct gpib_board *board, unsigne
>  
>  	if (cmd.handle >= GPIB_MAX_NUM_DESCRIPTORS)
>  		return -EINVAL;
> +	
> +	cmd.handle = array_index_nospec(cmd.handle, GPIB_MAX_NUM_DESCRIPTORS);
>  
>  	mutex_lock(&file_priv->descriptors_mutex);
>  	desc = file_priv->descriptors[cmd.handle];
> -- 
> 2.25.1
> 

What tool found this issue?

And why did you not run scripts/checkpatch.pl on the patch to notice the
error you added to the file with this change?  :(

thanks,

greg k-h

  reply	other threads:[~2026-04-24  9:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-24  9:00 [PATCH] gpib: fix spectre v1 vulnerabilities in descriptor handling Hongling Zeng
2026-04-24  9:35 ` Greg KH [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-04-24  9:50 Hongling Zeng
2026-04-24 10:01 ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2026042403-deceit-clamor-62e0@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=colin.i.king@gmail.com \
    --cc=dpenkler@gmail.com \
    --cc=harshit.m.mogalapalli@oracle.com \
    --cc=jkoolstra@xs4all.nl \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukeyang.dev@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=zenghongling@kylinos.cn \
    --cc=zhongling0719@126.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox