* [PATCH][next] powerpc/vas: Fix potential NULL pointer dereference
@ 2021-10-15 5:03 Gustavo A. R. Silva
2021-10-18 21:09 ` Tyrel Datwyler
2021-11-02 10:11 ` Michael Ellerman
0 siblings, 2 replies; 8+ messages in thread
From: Gustavo A. R. Silva @ 2021-10-15 5:03 UTC (permalink / raw)
To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Nicholas Piggin, Haren Myneni
Cc: linux-hardening, linuxppc-dev, linux-kernel, Gustavo A. R. Silva
(!ptr && !ptr->foo) strikes again. :)
The expression (!ptr && !ptr->foo) is bogus and in case ptr is NULL,
it leads to a NULL pointer dereference: ptr->foo.
Fix this by converting && to ||
This issue was detected with the help of Coccinelle, and audited and
fixed manually.
Fixes: 1a0d0d5ed5e3 ("powerpc/vas: Add platform specific user window operations")
Cc: stable@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
arch/powerpc/platforms/book3s/vas-api.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/book3s/vas-api.c b/arch/powerpc/platforms/book3s/vas-api.c
index 30172e52e16b..4d82c92ddd52 100644
--- a/arch/powerpc/platforms/book3s/vas-api.c
+++ b/arch/powerpc/platforms/book3s/vas-api.c
@@ -303,7 +303,7 @@ static int coproc_ioc_tx_win_open(struct file *fp, unsigned long arg)
return -EINVAL;
}
- if (!cp_inst->coproc->vops && !cp_inst->coproc->vops->open_win) {
+ if (!cp_inst->coproc->vops || !cp_inst->coproc->vops->open_win) {
pr_err("VAS API is not registered\n");
return -EACCES;
}
@@ -373,7 +373,7 @@ static int coproc_mmap(struct file *fp, struct vm_area_struct *vma)
return -EINVAL;
}
- if (!cp_inst->coproc->vops && !cp_inst->coproc->vops->paste_addr) {
+ if (!cp_inst->coproc->vops || !cp_inst->coproc->vops->paste_addr) {
pr_err("%s(): VAS API is not registered\n", __func__);
return -EACCES;
}
--
2.27.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH][next] powerpc/vas: Fix potential NULL pointer dereference
2021-10-15 5:03 [PATCH][next] powerpc/vas: Fix potential NULL pointer dereference Gustavo A. R. Silva
@ 2021-10-18 21:09 ` Tyrel Datwyler
2021-10-18 21:26 ` Gustavo A. R. Silva
2021-10-26 18:42 ` Gustavo A. R. Silva
2021-11-02 10:11 ` Michael Ellerman
1 sibling, 2 replies; 8+ messages in thread
From: Tyrel Datwyler @ 2021-10-18 21:09 UTC (permalink / raw)
To: Gustavo A. R. Silva, Michael Ellerman, Benjamin Herrenschmidt,
Paul Mackerras, Nicholas Piggin, Haren Myneni
Cc: linuxppc-dev, linux-hardening, linux-kernel
On 10/14/21 10:03 PM, Gustavo A. R. Silva wrote:
> (!ptr && !ptr->foo) strikes again. :)
>
> The expression (!ptr && !ptr->foo) is bogus and in case ptr is NULL,
> it leads to a NULL pointer dereference: ptr->foo.
>
> Fix this by converting && to ||
>
> This issue was detected with the help of Coccinelle, and audited and
> fixed manually.
>
> Fixes: 1a0d0d5ed5e3 ("powerpc/vas: Add platform specific user window operations")
> Cc: stable@vger.kernel.org
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Looking at the usage pattern it is obvious that if we determine !ptr attempting
to also confirm !ptr->ops is going to blow up.
LGTM.
Reviewed-by: Tyrel Datwyler <tyreld@linux.ibm.com>
> ---
> arch/powerpc/platforms/book3s/vas-api.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/platforms/book3s/vas-api.c b/arch/powerpc/platforms/book3s/vas-api.c
> index 30172e52e16b..4d82c92ddd52 100644
> --- a/arch/powerpc/platforms/book3s/vas-api.c
> +++ b/arch/powerpc/platforms/book3s/vas-api.c
> @@ -303,7 +303,7 @@ static int coproc_ioc_tx_win_open(struct file *fp, unsigned long arg)
> return -EINVAL;
> }
>
> - if (!cp_inst->coproc->vops && !cp_inst->coproc->vops->open_win) {
> + if (!cp_inst->coproc->vops || !cp_inst->coproc->vops->open_win) {
> pr_err("VAS API is not registered\n");
> return -EACCES;
> }
> @@ -373,7 +373,7 @@ static int coproc_mmap(struct file *fp, struct vm_area_struct *vma)
> return -EINVAL;
> }
>
> - if (!cp_inst->coproc->vops && !cp_inst->coproc->vops->paste_addr) {
> + if (!cp_inst->coproc->vops || !cp_inst->coproc->vops->paste_addr) {
> pr_err("%s(): VAS API is not registered\n", __func__);
> return -EACCES;
> }
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH][next] powerpc/vas: Fix potential NULL pointer dereference
2021-10-18 21:09 ` Tyrel Datwyler
@ 2021-10-18 21:26 ` Gustavo A. R. Silva
2021-10-26 18:42 ` Gustavo A. R. Silva
1 sibling, 0 replies; 8+ messages in thread
From: Gustavo A. R. Silva @ 2021-10-18 21:26 UTC (permalink / raw)
To: Tyrel Datwyler
Cc: Haren Myneni, linux-kernel, Nicholas Piggin, Paul Mackerras,
linux-hardening, linuxppc-dev
On Mon, Oct 18, 2021 at 02:09:31PM -0700, Tyrel Datwyler wrote:
> On 10/14/21 10:03 PM, Gustavo A. R. Silva wrote:
> > (!ptr && !ptr->foo) strikes again. :)
> >
> > The expression (!ptr && !ptr->foo) is bogus and in case ptr is NULL,
> > it leads to a NULL pointer dereference: ptr->foo.
> >
> > Fix this by converting && to ||
> >
> > This issue was detected with the help of Coccinelle, and audited and
> > fixed manually.
> >
> > Fixes: 1a0d0d5ed5e3 ("powerpc/vas: Add platform specific user window operations")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> Looking at the usage pattern it is obvious that if we determine !ptr attempting
> to also confirm !ptr->ops is going to blow up.
>
> LGTM.
>
> Reviewed-by: Tyrel Datwyler <tyreld@linux.ibm.com>
Thanks, Tyrel.
--
Gustavo
>
> > ---
> > arch/powerpc/platforms/book3s/vas-api.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/powerpc/platforms/book3s/vas-api.c b/arch/powerpc/platforms/book3s/vas-api.c
> > index 30172e52e16b..4d82c92ddd52 100644
> > --- a/arch/powerpc/platforms/book3s/vas-api.c
> > +++ b/arch/powerpc/platforms/book3s/vas-api.c
> > @@ -303,7 +303,7 @@ static int coproc_ioc_tx_win_open(struct file *fp, unsigned long arg)
> > return -EINVAL;
> > }
> >
> > - if (!cp_inst->coproc->vops && !cp_inst->coproc->vops->open_win) {
> > + if (!cp_inst->coproc->vops || !cp_inst->coproc->vops->open_win) {
> > pr_err("VAS API is not registered\n");
> > return -EACCES;
> > }
> > @@ -373,7 +373,7 @@ static int coproc_mmap(struct file *fp, struct vm_area_struct *vma)
> > return -EINVAL;
> > }
> >
> > - if (!cp_inst->coproc->vops && !cp_inst->coproc->vops->paste_addr) {
> > + if (!cp_inst->coproc->vops || !cp_inst->coproc->vops->paste_addr) {
> > pr_err("%s(): VAS API is not registered\n", __func__);
> > return -EACCES;
> > }
> >
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH][next] powerpc/vas: Fix potential NULL pointer dereference
2021-10-18 21:09 ` Tyrel Datwyler
2021-10-18 21:26 ` Gustavo A. R. Silva
@ 2021-10-26 18:42 ` Gustavo A. R. Silva
2021-10-26 22:30 ` Michael Ellerman
1 sibling, 1 reply; 8+ messages in thread
From: Gustavo A. R. Silva @ 2021-10-26 18:42 UTC (permalink / raw)
To: Tyrel Datwyler
Cc: Haren Myneni, linux-kernel, Nicholas Piggin, Paul Mackerras,
linux-hardening, linuxppc-dev
On Mon, Oct 18, 2021 at 02:09:31PM -0700, Tyrel Datwyler wrote:
> On 10/14/21 10:03 PM, Gustavo A. R. Silva wrote:
> > (!ptr && !ptr->foo) strikes again. :)
> >
> > The expression (!ptr && !ptr->foo) is bogus and in case ptr is NULL,
> > it leads to a NULL pointer dereference: ptr->foo.
> >
> > Fix this by converting && to ||
> >
> > This issue was detected with the help of Coccinelle, and audited and
> > fixed manually.
> >
> > Fixes: 1a0d0d5ed5e3 ("powerpc/vas: Add platform specific user window operations")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> Looking at the usage pattern it is obvious that if we determine !ptr attempting
> to also confirm !ptr->ops is going to blow up.
>
> LGTM.
>
> Reviewed-by: Tyrel Datwyler <tyreld@linux.ibm.com>
I think I'll take this in my tree.
Thanks, Tyrel.
--
Gustavo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH][next] powerpc/vas: Fix potential NULL pointer dereference
2021-10-26 18:42 ` Gustavo A. R. Silva
@ 2021-10-26 22:30 ` Michael Ellerman
2021-10-26 22:40 ` Gustavo A. R. Silva
0 siblings, 1 reply; 8+ messages in thread
From: Michael Ellerman @ 2021-10-26 22:30 UTC (permalink / raw)
To: Gustavo A. R. Silva, Tyrel Datwyler
Cc: Haren Myneni, linux-kernel, Nicholas Piggin, Paul Mackerras,
linux-hardening, linuxppc-dev
"Gustavo A. R. Silva" <gustavoars@kernel.org> writes:
> On Mon, Oct 18, 2021 at 02:09:31PM -0700, Tyrel Datwyler wrote:
>> On 10/14/21 10:03 PM, Gustavo A. R. Silva wrote:
>> > (!ptr && !ptr->foo) strikes again. :)
>> >
>> > The expression (!ptr && !ptr->foo) is bogus and in case ptr is NULL,
>> > it leads to a NULL pointer dereference: ptr->foo.
>> >
>> > Fix this by converting && to ||
>> >
>> > This issue was detected with the help of Coccinelle, and audited and
>> > fixed manually.
>> >
>> > Fixes: 1a0d0d5ed5e3 ("powerpc/vas: Add platform specific user window operations")
>> > Cc: stable@vger.kernel.org
>> > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
>> Looking at the usage pattern it is obvious that if we determine !ptr attempting
>> to also confirm !ptr->ops is going to blow up.
>>
>> LGTM.
>>
>> Reviewed-by: Tyrel Datwyler <tyreld@linux.ibm.com>
>
> I think I'll take this in my tree.
I've already put it in powerpc/next:
https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?h=next&id=61cb9ac66b30374c7fd8a8b2a3c4f8f432c72e36
If you need to pick it up as well for some reason that's fine.
cheers
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH][next] powerpc/vas: Fix potential NULL pointer dereference
2021-10-26 22:30 ` Michael Ellerman
@ 2021-10-26 22:40 ` Gustavo A. R. Silva
2021-10-27 11:21 ` Michael Ellerman
0 siblings, 1 reply; 8+ messages in thread
From: Gustavo A. R. Silva @ 2021-10-26 22:40 UTC (permalink / raw)
To: Michael Ellerman
Cc: Tyrel Datwyler, Haren Myneni, linux-kernel, Nicholas Piggin,
Paul Mackerras, linux-hardening, linuxppc-dev
On Wed, Oct 27, 2021 at 09:30:53AM +1100, Michael Ellerman wrote:
[..]
> > I think I'll take this in my tree.
>
> I've already put it in powerpc/next:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?h=next&id=61cb9ac66b30374c7fd8a8b2a3c4f8f432c72e36
Oh, great. :)
> If you need to pick it up as well for some reason that's fine.
I just didn't want it to get lost somehow. I'll drop it from tree now.
Thanks
--
Gustavo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH][next] powerpc/vas: Fix potential NULL pointer dereference
2021-10-26 22:40 ` Gustavo A. R. Silva
@ 2021-10-27 11:21 ` Michael Ellerman
0 siblings, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2021-10-27 11:21 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Tyrel Datwyler, Haren Myneni, linux-kernel, Nicholas Piggin,
Paul Mackerras, linux-hardening, linuxppc-dev
"Gustavo A. R. Silva" <gustavoars@kernel.org> writes:
> On Wed, Oct 27, 2021 at 09:30:53AM +1100, Michael Ellerman wrote:
> [..]
>> > I think I'll take this in my tree.
>>
>> I've already put it in powerpc/next:
>>
>> https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?h=next&id=61cb9ac66b30374c7fd8a8b2a3c4f8f432c72e36
>
> Oh, great. :)
>
>> If you need to pick it up as well for some reason that's fine.
>
> I just didn't want it to get lost somehow. I'll drop it from tree now.
No worries, sorry I've been so slow lately.
cheers
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH][next] powerpc/vas: Fix potential NULL pointer dereference
2021-10-15 5:03 [PATCH][next] powerpc/vas: Fix potential NULL pointer dereference Gustavo A. R. Silva
2021-10-18 21:09 ` Tyrel Datwyler
@ 2021-11-02 10:11 ` Michael Ellerman
1 sibling, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2021-11-02 10:11 UTC (permalink / raw)
To: Michael Ellerman, Paul Mackerras, Haren Myneni, Nicholas Piggin,
Gustavo A. R. Silva, Benjamin Herrenschmidt
Cc: linuxppc-dev, linux-kernel, linux-hardening
On Fri, 15 Oct 2021 00:03:45 -0500, Gustavo A. R. Silva wrote:
> (!ptr && !ptr->foo) strikes again. :)
>
> The expression (!ptr && !ptr->foo) is bogus and in case ptr is NULL,
> it leads to a NULL pointer dereference: ptr->foo.
>
> Fix this by converting && to ||
>
> [...]
Applied to powerpc/next.
[1/1] powerpc/vas: Fix potential NULL pointer dereference
https://git.kernel.org/powerpc/c/61cb9ac66b30374c7fd8a8b2a3c4f8f432c72e36
cheers
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-11-02 11:45 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-15 5:03 [PATCH][next] powerpc/vas: Fix potential NULL pointer dereference Gustavo A. R. Silva
2021-10-18 21:09 ` Tyrel Datwyler
2021-10-18 21:26 ` Gustavo A. R. Silva
2021-10-26 18:42 ` Gustavo A. R. Silva
2021-10-26 22:30 ` Michael Ellerman
2021-10-26 22:40 ` Gustavo A. R. Silva
2021-10-27 11:21 ` Michael Ellerman
2021-11-02 10:11 ` Michael Ellerman
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).