From: "Zhang, Tianfei" <tianfei.zhang@intel.com>
To: "Huang, Wei" <wei.huang@intel.com>, "dev@dpdk.org" <dev@dpdk.org>,
"Xu, Rosen" <rosen.xu@intel.com>,
"Zhang, Qi Z" <qi.z.zhang@intel.com>
Cc: "Huang, Wei" <wei.huang@intel.com>
Subject: Re: [dpdk-dev] [PATCH v2 2/2] raw/ifpga: use trusted buffer to free
Date: Fri, 30 Oct 2020 06:56:47 +0000 [thread overview]
Message-ID: <DM6PR11MB313157E4A739B09CABB883C6E3150@DM6PR11MB3131.namprd11.prod.outlook.com> (raw)
In-Reply-To: <1604017294-23479-3-git-send-email-wei.huang@intel.com>
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Wei Huang
> Sent: 2020年10月30日 8:22
> To: dev@dpdk.org; Xu, Rosen <rosen.xu@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>
> Cc: Huang, Wei <wei.huang@intel.com>
> Subject: [dpdk-dev] [PATCH v2 2/2] raw/ifpga: use trusted buffer to free
>
> In rte_fpga_do_pr, calling function read() may taints argument buffer which
> turn to an untrusted value as argumen of rte_free().
>
> Fixes: ef1e8ede3da5 ("raw/ifpga: add Intel FPGA bus rawdev driver")
It is better add Coverity issue number , like "Coverity issue: xxxx ".
Missing “Cc: stable@dpdk.org”.
>
> Signed-off-by: Wei Huang <wei.huang@intel.com>
> ---
> v2: add fixes information to log
> ---
> drivers/raw/ifpga/ifpga_rawdev.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/raw/ifpga/ifpga_rawdev.c
> b/drivers/raw/ifpga/ifpga_rawdev.c
> index f9de167..27129b1 100644
> --- a/drivers/raw/ifpga/ifpga_rawdev.c
> +++ b/drivers/raw/ifpga/ifpga_rawdev.c
> @@ -786,7 +786,7 @@ rte_fpga_do_pr(struct rte_rawdev *rawdev, int
> port_id,
> int file_fd;
> int ret = 0;
> ssize_t buffer_size;
> - void *buffer;
> + void *buffer, *buf_to_free;
> u64 pr_error;
>
> if (!file_name)
> @@ -818,6 +818,7 @@ rte_fpga_do_pr(struct rte_rawdev *rawdev, int
> port_id,
> ret = -ENOMEM;
> goto close_fd;
> }
> + buf_to_free = buffer;
>
> /*read the raw data*/
> if (buffer_size != read(file_fd, (void *)buffer, buffer_size)) { @@ -835,8
> +836,8 @@ rte_fpga_do_pr(struct rte_rawdev *rawdev, int port_id,
> }
>
> free_buffer:
> - if (buffer)
> - rte_free(buffer);
> + if (buf_to_free)
> + rte_free(buf_to_free);
> close_fd:
> close(file_fd);
> file_fd = 0;
> --
> 2.7.3
next prev parent reply other threads:[~2020-10-30 6:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-30 0:21 [dpdk-dev] [PATCH v2 0/2] raw/ifpga: fix coverity defects Wei Huang
2020-10-30 0:21 ` [dpdk-dev] [PATCH v2 1/2] raw/ifpga: terminate string filled by readlink with null Wei Huang
2020-10-30 6:56 ` Zhang, Tianfei
2020-10-30 0:21 ` [dpdk-dev] [PATCH v2 2/2] raw/ifpga: use trusted buffer to free Wei Huang
2020-10-30 6:56 ` Zhang, Tianfei [this message]
2020-11-02 12:23 ` [dpdk-dev] [PATCH v2 0/2] raw/ifpga: fix coverity defects Zhang, Qi Z
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=DM6PR11MB313157E4A739B09CABB883C6E3150@DM6PR11MB3131.namprd11.prod.outlook.com \
--to=tianfei.zhang@intel.com \
--cc=dev@dpdk.org \
--cc=qi.z.zhang@intel.com \
--cc=rosen.xu@intel.com \
--cc=wei.huang@intel.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;
as well as URLs for NNTP newsgroup(s).