From: Julia Lawall <julia.lawall@lip6.fr>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
Lv Zheng <lv.zheng@intel.com>, Len Brown <lenb@kernel.org>,
linux-acpi@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch 2/2] ACPI / debugger: copy_to_user doesn't return errors
Date: Thu, 24 Dec 2015 08:39:06 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.02.1512240838170.2053@localhost6.localdomain6> (raw)
In-Reply-To: <20151224072437.GB29642@mwanda>
On Thu, 24 Dec 2015, Dan Carpenter wrote:
> The copy_to/from_user() functions don't return error codes, they return
> the number of bytes remaining. We had intended to return -EFUALT here.
> We actually have already checked access_ok() in an earlier function so
> I don't think these functions will fail but let's fix it anyway.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/acpi/acpi_dbg.c b/drivers/acpi/acpi_dbg.c
> index f2c92ab..2a1777b 100644
> --- a/drivers/acpi/acpi_dbg.c
> +++ b/drivers/acpi/acpi_dbg.c
> @@ -592,9 +592,10 @@ static int acpi_aml_read_user(char __user *buf, int len)
> smp_rmb();
> p = &crc->buf[crc->tail];
> n = min(len, circ_count_to_end(crc));
> - ret = copy_to_user(buf, p, n);
> - if (IS_ERR_VALUE(ret))
I'm not familiar with IS_ERR_VALUE. Is it to allow functions that return
unsigned values to also return negative error codes?
thanks,
julia
> + if (copy_to_user(buf, p, n)) {
> + ret = -EFAULT;
> goto out;
> + }
> /* sync tail after removing logs */
> smp_mb();
> crc->tail = (crc->tail + n) & (ACPI_AML_BUF_SIZE - 1);
> @@ -661,9 +662,10 @@ static int acpi_aml_write_user(const char __user *buf, int len)
> smp_mb();
> p = &crc->buf[crc->head];
> n = min(len, circ_space_to_end(crc));
> - ret = copy_from_user(p, buf, n);
> - if (IS_ERR_VALUE(ret))
> + if (copy_from_user(p, buf, n)) {
> + ret = -EFAULT;
> goto out;
> + }
> /* sync head after inserting cmds */
> smp_wmb();
> crc->head = (crc->head + n) & (ACPI_AML_BUF_SIZE - 1);
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2015-12-24 7:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-24 7:24 [patch 2/2] ACPI / debugger: copy_to_user doesn't return errors Dan Carpenter
2015-12-24 7:39 ` Julia Lawall [this message]
2015-12-24 19:15 ` Dan Carpenter
2015-12-25 3:25 ` Zheng, Lv
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=alpine.DEB.2.02.1512240838170.2053@localhost6.localdomain6 \
--to=julia.lawall@lip6.fr \
--cc=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=lv.zheng@intel.com \
--cc=rjw@rjwysocki.net \
/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