All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chinmay Rath <rathc@linux.ibm.com>
To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Cc: harshpb@linux.ibm.com
Subject: Re: [PATCH v3] target/ppc: Add lower bound check for watchdogNumber
Date: Wed, 19 Aug 2026 15:34:04 +0530	[thread overview]
Message-ID: <1a184add-d994-4635-a9ca-f1a74aefd27d@linux.ibm.com> (raw)
In-Reply-To: <01070c86-0a61-43e5-8f55-7f217a3f96a9@linux.ibm.com>


On 8/18/26 17:11, Chinmay Rath wrote:
>
> On 8/18/26 16:15, Chinmay Rath wrote:
>> Add missing lower bound check for H_WATCHDOG H_CALL's watchdogNumber 
>> parameter
>> as per PAPR documentation ver 12.10.00 section 14.15.5 'H_WATCHDOG'.
>>
>> Closes : https://gitlab.com/qemu-project/qemu/-/work_items/3600
>> Reviewed-by: Amit Machhiwal <amachhiw@linux.ibm.com>
> Reported-by: huntr bubble <bubblehuntr@gmail.com>
Hi Harsh,
I missed adding the correct commit message header here. Should have use 
hw/watchdog instead of target/ppc.
If possible please correct this while you pull in the patch along with 
the extra Reported-by tag.
Lemme know if that works.

TIA,
Chinmay
>> Signed-off-by: Chinmay Rath <rathc@linux.ibm.com>
>> ---
>>
>> Changes from v2:
>> Renamed watchdogNumber_valid to watchdog_number_valid - Amit
>> Retained Amit's Reviewed-by
>>
>>   hw/watchdog/spapr_watchdog.c | 16 +++++++++++-----
>>   1 file changed, 11 insertions(+), 5 deletions(-)
>>
>> diff --git a/hw/watchdog/spapr_watchdog.c b/hw/watchdog/spapr_watchdog.c
>> index 5b3f50de3a..5a72896066 100644
>> --- a/hw/watchdog/spapr_watchdog.c
>> +++ b/hw/watchdog/spapr_watchdog.c
>> @@ -127,6 +127,12 @@ static void watchdog_expired(void *pw)
>>       }
>>   }
>>   +static inline bool watchdog_number_valid(target_ulong watchdogNumber,
>> +                                        SpaprMachineState *spapr)
>> +{
>> +    return watchdogNumber >= 1 && watchdogNumber <= 
>> ARRAY_SIZE(spapr->wds);
>> +}
>> +
>>   static target_ulong h_watchdog(PowerPCCPU *cpu,
>>                                  SpaprMachineState *spapr,
>>                                  target_ulong opcode, target_ulong 
>> *args)
>> @@ -145,7 +151,7 @@ static target_ulong h_watchdog(PowerPCCPU *cpu,
>>         switch (operation) {
>>       case PSERIES_WDTF_OP_START:
>> -        if (watchdogNumber > ARRAY_SIZE(spapr->wds)) {
>> +        if (!watchdog_number_valid(watchdogNumber, spapr)) {
>>               return H_P2;
>>           }
>>           if (timeoutInMs <= WDT_MIN_TIMEOUT) {
>> @@ -170,11 +176,11 @@ static target_ulong h_watchdog(PowerPCCPU *cpu,
>>       case PSERIES_WDTF_OP_STOP:
>>           if (watchdogNumber == PSERIES_WDT_STOP_ALL) {
>>               ret = watchdog_stop_all(spapr);
>> -        } else if (watchdogNumber <= ARRAY_SIZE(spapr->wds)) {
>> +        } else if (!watchdog_number_valid(watchdogNumber, spapr)) {
>> +            return H_P2;
>> +        } else {
>>               ret = watchdog_stop(watchdogNumber,
>> &spapr->wds[watchdogNumber - 1]);
>> -        } else {
>> -            return H_P2;
>>           }
>>           break;
>>       case PSERIES_WDTF_OP_QUERY:
>> @@ -184,7 +190,7 @@ static target_ulong h_watchdog(PowerPCCPU *cpu,
>>           trace_spapr_watchdog_query(args[0]);
>>           break;
>>       case PSERIES_WDTF_OP_QUERY_LPM:
>> -        if (watchdogNumber > ARRAY_SIZE(spapr->wds)) {
>> +        if (!watchdog_number_valid(watchdogNumber, spapr)) {
>>               return H_P2;
>>           }
>>           args[0] = PSERIES_WDTQL_QUERY_NOT_STOPPED;
>


  reply	other threads:[~2026-08-19 10:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-18 10:45 [PATCH v3] target/ppc: Add lower bound check for watchdogNumber Chinmay Rath
2026-08-18 11:41 ` Chinmay Rath
2026-08-19 10:04   ` Chinmay Rath [this message]
2026-08-23  6:08     ` Harsh Prateek Bora

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=1a184add-d994-4635-a9ca-f1a74aefd27d@linux.ibm.com \
    --to=rathc@linux.ibm.com \
    --cc=harshpb@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.