[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210209085938.579f3187@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
Date: Tue, 9 Feb 2021 08:59:38 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: Leon Romanovsky <leon@...nel.org>
Cc: Arjun Roy <arjunroy.kdev@...il.com>, davem@...emloft.net,
netdev@...r.kernel.org, arjunroy@...gle.com, edumazet@...gle.com,
soheil@...gle.com, David Ahern <dsahern@...il.com>
Subject: Re: [net-next v2] tcp: Explicitly mark reserved field in
tcp_zerocopy_receive args.
On Tue, 9 Feb 2021 08:15:11 +0200 Leon Romanovsky wrote:
> At least in my tree, we have the length check:
> 4155 if (len > sizeof(zc)) {
> 4156 len = sizeof(zc);
> 4157 if (put_user(len, optlen))
> 4158 return -EFAULT;
> 4159 }
>
>
> Ad David wrote below, the "if (zc.reserved)" is enough.
>
> We have following options:
> 1. Old kernel that have sizeof(sz) upto .reserved and old userspace
> -> len <= sizeof(sz) - works correctly.
> 2. Old kernel that have sizeof(sz) upto .reserved and new userspace that
> sends larger struct -> "f (len > sizeof(zc))" will return -EFAULT
Based on the code you quoted? I don't see how. Maybe I need a vacation.
put_user() just copies len back to user space after truncation.
> 3. New kernel that have sizeof(sz) beyond reserved and old userspace
> -> any new added field to struct sz should be checked and anyway it is the same as item 1.
> 4. New kernel and new userspace
> -> standard flow.
Powered by blists - more mailing lists