Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-16 Thread Al Viro
On Fri, Apr 16, 2021 at 05:30:41PM +, Al Viro wrote: > On Fri, Apr 16, 2021 at 05:58:15PM +0200, Christian Brauner wrote: > > > They could probably refactor this but I'm not sure why they'd bother. If > > they fail processing any of those files they end up aborting the > > whole transaction. >

Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-16 Thread Al Viro
On Fri, Apr 16, 2021 at 05:58:15PM +0200, Christian Brauner wrote: > They could probably refactor this but I'm not sure why they'd bother. If > they fail processing any of those files they end up aborting the > whole transaction. > (And the original code didn't check the error code btw.) Wait a s

Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-16 Thread Al Viro
On Fri, Apr 16, 2021 at 06:00:38PM +0200, Christian Brauner wrote: > (dma_buf_fd() seems like another good candidate. But again, I don't have > any plans to shove this down anyone's throat.) Sure, there are candidates for such a helper. Just as there are legitimate users of anon_inode_getfd().

Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-16 Thread Christian Brauner
On Fri, Apr 16, 2021 at 05:58:25PM +0200, Christian Brauner wrote: > On Fri, Apr 16, 2021 at 03:35:59PM +, Al Viro wrote: > > On Fri, Apr 16, 2021 at 05:13:10PM +0200, Christian Brauner wrote: > > > > > My point here was more that the _file_ has already been opened _before_ > > > that call to

Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-16 Thread Christian Brauner
On Fri, Apr 16, 2021 at 03:35:59PM +, Al Viro wrote: > On Fri, Apr 16, 2021 at 05:13:10PM +0200, Christian Brauner wrote: > > > My point here was more that the _file_ has already been opened _before_ > > that call to io_uring_add_task_file(). But any potential non-trivial > > side-effects of o

Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-16 Thread Al Viro
On Fri, Apr 16, 2021 at 05:13:10PM +0200, Christian Brauner wrote: > My point here was more that the _file_ has already been opened _before_ > that call to io_uring_add_task_file(). But any potential non-trivial > side-effects of opening that file that you correctly pointed out in an > earlier mai

Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-16 Thread Christian Brauner
On Fri, Apr 16, 2021 at 02:09:35PM +, Al Viro wrote: > On Fri, Apr 16, 2021 at 03:42:52PM +0200, Christian Brauner wrote: > > > > are drivers/dma-buf/sw_sync.c and drivers/dma-buf/sync_file.c, etc. > > > > > > FWIW, pretty much all ioctls that return descriptor as part of a structure > > > sto

Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-16 Thread Al Viro
On Fri, Apr 16, 2021 at 03:42:52PM +0200, Christian Brauner wrote: > > > are drivers/dma-buf/sw_sync.c and drivers/dma-buf/sync_file.c, etc. > > > > FWIW, pretty much all ioctls that return descriptor as part of a structure > > stored to user-supplied address tend to be that way; some don't have a

Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-16 Thread Christian Brauner
On Fri, Apr 16, 2021 at 05:55:16AM +, Al Viro wrote: > On Fri, Apr 16, 2021 at 05:19:50AM +, Al Viro wrote: > > On Thu, Apr 01, 2021 at 12:40:34PM +0200, Christian Brauner wrote: > > > > and see whether all of them can be switched to simply using > > > receive_fd(). I did a completely unte

Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-15 Thread Al Viro
On Fri, Apr 16, 2021 at 05:19:50AM +, Al Viro wrote: > On Thu, Apr 01, 2021 at 12:40:34PM +0200, Christian Brauner wrote: > > and see whether all of them can be switched to simply using > > receive_fd(). I did a completely untested rough sketch to illustrate > > what I meant by using binder an

Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-15 Thread Al Viro
On Thu, Apr 01, 2021 at 12:40:34PM +0200, Christian Brauner wrote: > My suggestion was to look at all the places were we currently open-code > this in drivers/: > > drivers/android/binder.c: int fd = > get_unused_fd_flags(O_CLOEXEC); > drivers/char/tpm/tpm_vtpm_proxy.c: fd = ge

Re: Re: Re: Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-02 Thread Kees Cook
On Thu, Apr 01, 2021 at 04:09:57PM +0200, Greg KH wrote: > On Thu, Apr 01, 2021 at 08:28:02PM +0800, Yongji Xie wrote: > > On Thu, Apr 1, 2021 at 7:33 PM Greg KH wrote: > > > > > > On Thu, Apr 01, 2021 at 07:29:45PM +0800, Yongji Xie wrote: > > > > On Thu, Apr 1, 2021 at 6:42 PM Greg KH > > > >

Re: Re: Re: Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-01 Thread Greg KH
On Thu, Apr 01, 2021 at 08:28:02PM +0800, Yongji Xie wrote: > On Thu, Apr 1, 2021 at 7:33 PM Greg KH wrote: > > > > On Thu, Apr 01, 2021 at 07:29:45PM +0800, Yongji Xie wrote: > > > On Thu, Apr 1, 2021 at 6:42 PM Greg KH wrote: > > > > > > > > On Thu, Apr 01, 2021 at 06:12:51PM +0800, Yongji Xie

Re: Re: Re: Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-01 Thread Yongji Xie
On Thu, Apr 1, 2021 at 7:33 PM Greg KH wrote: > > On Thu, Apr 01, 2021 at 07:29:45PM +0800, Yongji Xie wrote: > > On Thu, Apr 1, 2021 at 6:42 PM Greg KH wrote: > > > > > > On Thu, Apr 01, 2021 at 06:12:51PM +0800, Yongji Xie wrote: > > > > On Thu, Apr 1, 2021 at 5:54 PM Greg KH > > > > wrote: >

Re: Re: Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-01 Thread Greg KH
On Thu, Apr 01, 2021 at 07:29:45PM +0800, Yongji Xie wrote: > On Thu, Apr 1, 2021 at 6:42 PM Greg KH wrote: > > > > On Thu, Apr 01, 2021 at 06:12:51PM +0800, Yongji Xie wrote: > > > On Thu, Apr 1, 2021 at 5:54 PM Greg KH wrote: > > > > > > > > On Thu, Apr 01, 2021 at 05:09:32PM +0800, Xie Yongji

Re: Re: Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-01 Thread Yongji Xie
On Thu, Apr 1, 2021 at 6:42 PM Greg KH wrote: > > On Thu, Apr 01, 2021 at 06:12:51PM +0800, Yongji Xie wrote: > > On Thu, Apr 1, 2021 at 5:54 PM Greg KH wrote: > > > > > > On Thu, Apr 01, 2021 at 05:09:32PM +0800, Xie Yongji wrote: > > > > Use receive_fd() to receive file from another process ins

Re: Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-01 Thread Yongji Xie
On Thu, Apr 1, 2021 at 6:40 PM Christian Brauner wrote: > > On Thu, Apr 01, 2021 at 11:54:45AM +0200, Greg KH wrote: > > On Thu, Apr 01, 2021 at 05:09:32PM +0800, Xie Yongji wrote: > > > Use receive_fd() to receive file from another process instead of > > > combination of get_unused_fd_flags() and

Re: Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-01 Thread Greg KH
On Thu, Apr 01, 2021 at 06:12:51PM +0800, Yongji Xie wrote: > On Thu, Apr 1, 2021 at 5:54 PM Greg KH wrote: > > > > On Thu, Apr 01, 2021 at 05:09:32PM +0800, Xie Yongji wrote: > > > Use receive_fd() to receive file from another process instead of > > > combination of get_unused_fd_flags() and fd_i

Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-01 Thread Christian Brauner
On Thu, Apr 01, 2021 at 11:54:45AM +0200, Greg KH wrote: > On Thu, Apr 01, 2021 at 05:09:32PM +0800, Xie Yongji wrote: > > Use receive_fd() to receive file from another process instead of > > combination of get_unused_fd_flags() and fd_install(). This simplifies > > the logic and also makes sure we

Re: Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-01 Thread Yongji Xie
On Thu, Apr 1, 2021 at 5:54 PM Greg KH wrote: > > On Thu, Apr 01, 2021 at 05:09:32PM +0800, Xie Yongji wrote: > > Use receive_fd() to receive file from another process instead of > > combination of get_unused_fd_flags() and fd_install(). This simplifies > > the logic and also makes sure we don't m

Re: [PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-01 Thread Greg KH
On Thu, Apr 01, 2021 at 05:09:32PM +0800, Xie Yongji wrote: > Use receive_fd() to receive file from another process instead of > combination of get_unused_fd_flags() and fd_install(). This simplifies > the logic and also makes sure we don't miss any security stuff. But no logic is simplified here,

[PATCH 2/2] binder: Use receive_fd() to receive file from another process

2021-04-01 Thread Xie Yongji
Use receive_fd() to receive file from another process instead of combination of get_unused_fd_flags() and fd_install(). This simplifies the logic and also makes sure we don't miss any security stuff. Signed-off-by: Xie Yongji --- drivers/android/binder.c | 4 ++-- 1 file changed, 2 insertions(+)