Re: [PATCH bpf-next v2 1/4] bpf: Don't EFAULT for {g,s}setsockopt with wrong optlen

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Apr 30, 2023 at 10:52 PM Martin KaFai Lau <martin.lau@xxxxxxxxx> wrote:
>
> On 4/27/23 1:04 PM, Stanislav Fomichev wrote:
> > @@ -1881,8 +1886,10 @@ int __cgroup_bpf_run_filter_getsockopt(struct sock *sk, int level,
> >               .optname = optname,
> >               .current_task = current,
> >       };
> > +     int orig_optlen;
> >       int ret;
> >
> > +     orig_optlen = max_optlen;
>
> For getsockopt, when the kernel's getsockopt finished successfully (the
> following 'if (!retval)' case), how about also setting orig_optlen to the kernel
> returned 'optlen'. For example, the user's orig_optlen is 8096 and the kernel
> returned optlen is 1024. If the bpf prog still sets the ctx.optlen to something
>  > PAGE_SIZE, -EFAULT will be returned.

Wouldn't it defeat the purpose? Or am I missing something?

ctx.optlen would still be 8096, not 1024, right (regardless of what
the kernel returns)?
So it would trigger EFAULT case which we try to avoid.




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux