Linux PCI subsystem development
 help / color / mirror / Atom feed
From: "Krzysztof Wilczyński" <kw@linux.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: oe-kbuild@lists.linux.dev,
	Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
	lkp@intel.com, oe-kbuild-all@lists.linux.dev,
	linux-pci@vger.kernel.org
Subject: Re: [pci:ptm-debugfs 1/4] drivers/pci/pcie/ptm.c:275 context_update_write() error: buffer overflow 'buf' 7 <= 7
Date: Thu, 15 May 2025 18:19:54 +0900	[thread overview]
Message-ID: <20250515091954.GA1059401@rocinante> (raw)
In-Reply-To: <b41c1754-c6b7-4805-9f14-7c643d6c5304@suswa.mountain>

Hello,

[...]
> smatch warnings:
> drivers/pci/pcie/ptm.c:275 context_update_write() error: buffer overflow 'buf' 7 <= 7
> 
> vim +/buf +275 drivers/pci/pcie/ptm.c
> 
> 1130deffd29ab2 Manivannan Sadhasivam 2025-05-05  257  static ssize_t context_update_write(struct file *file, const char __user *ubuf,
> 1130deffd29ab2 Manivannan Sadhasivam 2025-05-05  258  			     size_t count, loff_t *ppos)
> 1130deffd29ab2 Manivannan Sadhasivam 2025-05-05  259  {
> 1130deffd29ab2 Manivannan Sadhasivam 2025-05-05  260  	struct pci_ptm_debugfs *ptm_debugfs = file->private_data;
> 1130deffd29ab2 Manivannan Sadhasivam 2025-05-05  261  	char buf[7];
> 1130deffd29ab2 Manivannan Sadhasivam 2025-05-05  262  	int ret;
> 1130deffd29ab2 Manivannan Sadhasivam 2025-05-05  263  	u8 mode;
> 1130deffd29ab2 Manivannan Sadhasivam 2025-05-05  264  
> 1130deffd29ab2 Manivannan Sadhasivam 2025-05-05  265  	if (!ptm_debugfs->ops->context_update_write)
> 1130deffd29ab2 Manivannan Sadhasivam 2025-05-05  266  		return -EOPNOTSUPP;
> 1130deffd29ab2 Manivannan Sadhasivam 2025-05-05  267  
> 1130deffd29ab2 Manivannan Sadhasivam 2025-05-05  268  	if (count < 1 || count > sizeof(buf))
> 
> Should be >= instead of >.

Done.  Fixed directly on the branch, see:

  https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/commit/?h=ptm-debugfs&id=132833405e61463d47d6badff1b8080b09b5808e

Thank you, Dan!

	Krzysztof

      reply	other threads:[~2025-05-15  9:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-13 14:44 [pci:ptm-debugfs 1/4] drivers/pci/pcie/ptm.c:275 context_update_write() error: buffer overflow 'buf' 7 <= 7 Dan Carpenter
2025-05-15  9:19 ` Krzysztof Wilczyński [this message]

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=20250515091954.GA1059401@rocinante \
    --to=kw@linux.com \
    --cc=dan.carpenter@linaro.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oe-kbuild@lists.linux.dev \
    /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