lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 25 Jan 2020 14:26:15 +0100
From:   Greg KH <gregkh@...uxfoundation.org>
To:     Jeffrey Hugo <jhugo@...eaurora.org>
Cc:     Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>,
        arnd@...db.de, smohanad@...eaurora.org, kvalo@...eaurora.org,
        bjorn.andersson@...aro.org, hemantk@...eaurora.org,
        linux-arm-msm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 02/16] bus: mhi: core: Add support for registering MHI
 controllers

On Fri, Jan 24, 2020 at 11:12:57AM -0700, Jeffrey Hugo wrote:
> On 1/24/2020 10:47 AM, Greg KH wrote:
> > On Fri, Jan 24, 2020 at 07:24:43AM -0700, Jeffrey Hugo wrote:
> > > > > +/**
> > > > > + * struct mhi_result - Completed buffer information
> > > > > + * @buf_addr: Address of data buffer
> > > > > + * @dir: Channel direction
> > > > > + * @bytes_xfer: # of bytes transferred
> > > > > + * @transaction_status: Status of last transaction
> > > > > + */
> > > > > +struct mhi_result {
> > > > > +	void *buf_addr;
> > > > 
> > > > Why void *?
> > > 
> > > Because its not possible to resolve this more clearly.  The client provides
> > > the buffer and knows what the structure is.  The bus does not. Its just an
> > > opaque pointer (hence void *) to the bus, and the client needs to decode it.
> > > This is the struct that is handed to the client to allow them to decode the
> > > activity (either a received buf, or a confirmation that a transmitted buf
> > > has been consumed).
> > 
> > Then shouldn't this be a "u8 *" instead as you are saying how many bytes
> > are here?
> 
> I'm sorry, I don't see the benefit of that.  Can you elaborate on why you
> think that u8 * is a better type?
> 
> Sure, its an arbitrary byte stream from the perspective of the bus, but to
> the client, 99% of the time its going to have some structure.

So which side is in control here, the "bus" or the "client"?  For the
bus to care, it's a bytestream and should be represented as such (like
you have) with a number of bytes in the "packet".

If you already know the structure types, just make a union of all of the
valid ones and be done with it.  In other words, try to avoid using void
* as much as is ever possible please.

thanks,

greg k-h

Powered by blists - more mailing lists