* [PATCH] NFS: remove unneeded check in decode_devicenotify_args()
@ 2022-02-15 10:17 Alexey Khoroshilov
2022-02-16 15:30 ` Anna Schumaker
0 siblings, 1 reply; 3+ messages in thread
From: Alexey Khoroshilov @ 2022-02-15 10:17 UTC (permalink / raw)
To: Trond Myklebust, Anna Schumaker
Cc: Alexey Khoroshilov, linux-nfs, linux-kernel, ldv-project
Overflow check in not needed anymore after we switch to kmalloc_array().
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Fixes: a4f743a6bb20 ("NFSv4.1: Convert open-coded array allocation calls to kmalloc_array()")
---
fs/nfs/callback_xdr.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
index f90de8043b0f..8dcb08e1a885 100644
--- a/fs/nfs/callback_xdr.c
+++ b/fs/nfs/callback_xdr.c
@@ -271,10 +271,6 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp,
n = ntohl(*p++);
if (n == 0)
goto out;
- if (n > ULONG_MAX / sizeof(*args->devs)) {
- status = htonl(NFS4ERR_BADXDR);
- goto out;
- }
args->devs = kmalloc_array(n, sizeof(*args->devs), GFP_KERNEL);
if (!args->devs) {
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] NFS: remove unneeded check in decode_devicenotify_args()
2022-02-15 10:17 [PATCH] NFS: remove unneeded check in decode_devicenotify_args() Alexey Khoroshilov
@ 2022-02-16 15:30 ` Anna Schumaker
2022-02-16 17:44 ` Alexey Khoroshilov
0 siblings, 1 reply; 3+ messages in thread
From: Anna Schumaker @ 2022-02-16 15:30 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: Trond Myklebust, Linux NFS Mailing List,
Linux Kernel Mailing List, ldv-project
Hi Alexey,
On Tue, Feb 15, 2022 at 5:17 AM Alexey Khoroshilov
<khoroshilov@ispras.ru> wrote:
>
> Overflow check in not needed anymore after we switch to kmalloc_array().
Don't we still need the overflow check since 'n' is used in the
for-loop end condition farther down in this function?
Thanks,
Anna
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> Fixes: a4f743a6bb20 ("NFSv4.1: Convert open-coded array allocation calls to kmalloc_array()")
> ---
> fs/nfs/callback_xdr.c | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
> index f90de8043b0f..8dcb08e1a885 100644
> --- a/fs/nfs/callback_xdr.c
> +++ b/fs/nfs/callback_xdr.c
> @@ -271,10 +271,6 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp,
> n = ntohl(*p++);
> if (n == 0)
> goto out;
> - if (n > ULONG_MAX / sizeof(*args->devs)) {
> - status = htonl(NFS4ERR_BADXDR);
> - goto out;
> - }
>
> args->devs = kmalloc_array(n, sizeof(*args->devs), GFP_KERNEL);
> if (!args->devs) {
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] NFS: remove unneeded check in decode_devicenotify_args()
2022-02-16 15:30 ` Anna Schumaker
@ 2022-02-16 17:44 ` Alexey Khoroshilov
0 siblings, 0 replies; 3+ messages in thread
From: Alexey Khoroshilov @ 2022-02-16 17:44 UTC (permalink / raw)
To: Anna Schumaker
Cc: Trond Myklebust, Linux NFS Mailing List,
Linux Kernel Mailing List, ldv-project
Hi Anna,
On 16.02.2022 18:30, Anna Schumaker wrote:
> On Tue, Feb 15, 2022 at 5:17 AM Alexey Khoroshilov
> <khoroshilov@ispras.ru> wrote:
>>
>> Overflow check in not needed anymore after we switch to kmalloc_array().
>
> Don't we still need the overflow check since 'n' is used in the
> for-loop end condition farther down in this function?
It is not, because it will be detected by kmalloc_array(), it returns
NULL and we will go out before the loop:
args->devs = kmalloc_array(n, sizeof(*args->devs), GFP_KERNEL);
if (!args->devs) {
status = htonl(NFS4ERR_DELAY);
goto out;
}
Best regards,
Alexey
>>
>> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
>> Fixes: a4f743a6bb20 ("NFSv4.1: Convert open-coded array allocation calls to kmalloc_array()")
>> ---
>> fs/nfs/callback_xdr.c | 4 ----
>> 1 file changed, 4 deletions(-)
>>
>> diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
>> index f90de8043b0f..8dcb08e1a885 100644
>> --- a/fs/nfs/callback_xdr.c
>> +++ b/fs/nfs/callback_xdr.c
>> @@ -271,10 +271,6 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp,
>> n = ntohl(*p++);
>> if (n == 0)
>> goto out;
>> - if (n > ULONG_MAX / sizeof(*args->devs)) {
>> - status = htonl(NFS4ERR_BADXDR);
>> - goto out;
>> - }
>>
>> args->devs = kmalloc_array(n, sizeof(*args->devs), GFP_KERNEL);
>> if (!args->devs) {
>> --
>> 2.7.4
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-16 17:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-15 10:17 [PATCH] NFS: remove unneeded check in decode_devicenotify_args() Alexey Khoroshilov
2022-02-16 15:30 ` Anna Schumaker
2022-02-16 17:44 ` Alexey Khoroshilov
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).