* RE: [PATCH] KVM: dereference of NULL pointer in set_pal_result()
2010-01-07 22:11 [PATCH] KVM: dereference of NULL pointer in set_pal_result() Roel Kluin
@ 2010-01-07 23:28 ` Zhang, Xiantao
2010-01-08 7:12 ` Gabor Gombas
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Zhang, Xiantao @ 2010-01-07 23:28 UTC (permalink / raw)
To: kvm-ia64
For the check "(p && p->exit_reason = EXIT_REASON_PAL_CALL", if p is NULL, the reference about "p->exit_reason = EXIT_REASON_PAL_CALL" won't be checked any more, so no issue here.
Xiantao
Roel Kluin wrote:
> Do not dereference a NULL pointer
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> arch/ia64/kvm/kvm_fw.c | 6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/ia64/kvm/kvm_fw.c b/arch/ia64/kvm/kvm_fw.c
> index e4b8231..d28494f 100644
> --- a/arch/ia64/kvm/kvm_fw.c
> +++ b/arch/ia64/kvm/kvm_fw.c
> @@ -75,9 +75,11 @@ static void set_pal_result(struct kvm_vcpu *vcpu,
> struct exit_ctl_data *p;
>
> p = kvm_get_exit_data(vcpu);
> - if (p && p->exit_reason = EXIT_REASON_PAL_CALL) {
> + if (!p)
> + return;
> + if (p->exit_reason = EXIT_REASON_PAL_CALL) {
> p->u.pal_data.ret = result;
> - return ;
> + return;
> }
> INIT_PAL_STATUS_UNIMPLEMENTED(p->u.pal_data.ret);
> }
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] KVM: dereference of NULL pointer in set_pal_result()
2010-01-07 22:11 [PATCH] KVM: dereference of NULL pointer in set_pal_result() Roel Kluin
2010-01-07 23:28 ` Zhang, Xiantao
@ 2010-01-08 7:12 ` Gabor Gombas
2010-01-08 9:14 ` Zhang, Xiantao
2010-01-08 12:25 ` roel kluin
3 siblings, 0 replies; 5+ messages in thread
From: Gabor Gombas @ 2010-01-08 7:12 UTC (permalink / raw)
To: kvm-ia64
On Fri, Jan 08, 2010 at 07:28:57AM +0800, Zhang, Xiantao wrote:
> For the check "(p && p->exit_reason = EXIT_REASON_PAL_CALL", if p is NULL, the reference about "p->exit_reason = EXIT_REASON_PAL_CALL" won't be checked any more, so no issue here.
> > diff --git a/arch/ia64/kvm/kvm_fw.c b/arch/ia64/kvm/kvm_fw.c
> > index e4b8231..d28494f 100644
> > --- a/arch/ia64/kvm/kvm_fw.c
> > +++ b/arch/ia64/kvm/kvm_fw.c
> > @@ -75,9 +75,11 @@ static void set_pal_result(struct kvm_vcpu *vcpu,
> > struct exit_ctl_data *p;
> >
> > p = kvm_get_exit_data(vcpu);
> > - if (p && p->exit_reason = EXIT_REASON_PAL_CALL) {
> > + if (!p)
> > + return;
> > + if (p->exit_reason = EXIT_REASON_PAL_CALL) {
> > p->u.pal_data.ret = result;
> > - return ;
> > + return;
> > }
> > INIT_PAL_STATUS_UNIMPLEMENTED(p->u.pal_data.ret);
IMHO it's not the test but the INIT_PAL_STATUS_UNIMPLEMENTED() that does
the unwanted dereferencing, and that's fixed by the patch.
Gabor
--
---------------------------------------------------------
MTA SZTAKI Computer and Automation Research Institute
Hungarian Academy of Sciences
---------------------------------------------------------
^ permalink raw reply [flat|nested] 5+ messages in thread* RE: [PATCH] KVM: dereference of NULL pointer in set_pal_result()
2010-01-07 22:11 [PATCH] KVM: dereference of NULL pointer in set_pal_result() Roel Kluin
2010-01-07 23:28 ` Zhang, Xiantao
2010-01-08 7:12 ` Gabor Gombas
@ 2010-01-08 9:14 ` Zhang, Xiantao
2010-01-08 12:25 ` roel kluin
3 siblings, 0 replies; 5+ messages in thread
From: Zhang, Xiantao @ 2010-01-08 9:14 UTC (permalink / raw)
To: kvm-ia64
Gabor Gombas wrote:
> On Fri, Jan 08, 2010 at 07:28:57AM +0800, Zhang, Xiantao wrote:
>
>> For the check "(p && p->exit_reason = EXIT_REASON_PAL_CALL", if p
>> is NULL, the reference about "p->exit_reason =
>> EXIT_REASON_PAL_CALL" won't be checked any more, so no issue here.
>
>>> diff --git a/arch/ia64/kvm/kvm_fw.c b/arch/ia64/kvm/kvm_fw.c
>>> index e4b8231..d28494f 100644
>>> --- a/arch/ia64/kvm/kvm_fw.c
>>> +++ b/arch/ia64/kvm/kvm_fw.c
>>> @@ -75,9 +75,11 @@ static void set_pal_result(struct kvm_vcpu
>>> *vcpu, struct exit_ctl_data *p;
>>>
>>> p = kvm_get_exit_data(vcpu);
>>> - if (p && p->exit_reason = EXIT_REASON_PAL_CALL) { + if (!p)
>>> + return;
>>> + if (p->exit_reason = EXIT_REASON_PAL_CALL) {
>>> p->u.pal_data.ret = result;
>>> - return ;
>>> + return;
>>> }
>>> INIT_PAL_STATUS_UNIMPLEMENTED(p->u.pal_data.ret);
>
> IMHO it's not the test but the INIT_PAL_STATUS_UNIMPLEMENTED() that
> does the unwanted dereferencing, and that's fixed by the patch.
Make sense.
Xiantao
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] KVM: dereference of NULL pointer in set_pal_result()
2010-01-07 22:11 [PATCH] KVM: dereference of NULL pointer in set_pal_result() Roel Kluin
` (2 preceding siblings ...)
2010-01-08 9:14 ` Zhang, Xiantao
@ 2010-01-08 12:25 ` roel kluin
3 siblings, 0 replies; 5+ messages in thread
From: roel kluin @ 2010-01-08 12:25 UTC (permalink / raw)
To: kvm-ia64
>> For the check "(p && p->exit_reason = EXIT_REASON_PAL_CALL", if p is NULL, the reference about "p->exit_reason = EXIT_REASON_PAL_CALL" won't be checked any more, so no issue here.
>> > p = kvm_get_exit_data(vcpu);
>> > - if (p && p->exit_reason = EXIT_REASON_PAL_CALL) {
>> > + if (!p)
>> > + return;
>> > + if (p->exit_reason = EXIT_REASON_PAL_CALL) {
>> > p->u.pal_data.ret = result;
>> > - return ;
>> > + return;
>> > }
>> > INIT_PAL_STATUS_UNIMPLEMENTED(p->u.pal_data.ret);
>
> IMHO it's not the test but the INIT_PAL_STATUS_UNIMPLEMENTED() that does
> the unwanted dereferencing, and that's fixed by the patch.
>
> Gabor
Correct. Thanks,
Roel
^ permalink raw reply [flat|nested] 5+ messages in thread