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  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:   Thu, 6 Jun 2019 18:22:07 +0000
From:   Dragan Cvetic <draganc@...inx.com>
To:     Greg KH <gregkh@...uxfoundation.org>
CC:     "arnd@...db.de" <arnd@...db.de>, Michal Simek <michals@...inx.com>,
        "linux-arm-kernel@...ts.infradead.org" 
        <linux-arm-kernel@...ts.infradead.org>,
        "robh+dt@...nel.org" <robh+dt@...nel.org>,
        "mark.rutland@....com" <mark.rutland@....com>,
        "devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Derek Kiernan <dkiernan@...inx.com>
Subject: RE: [PATCH V4 04/12] misc: xilinx_sdfec: Add open, close and ioctl



> -----Original Message-----
> From: Greg KH [mailto:gregkh@...uxfoundation.org]
> Sent: Thursday 6 June 2019 14:29
> To: Dragan Cvetic <draganc@...inx.com>
> Cc: arnd@...db.de; Michal Simek <michals@...inx.com>; linux-arm-kernel@...ts.infradead.org; robh+dt@...nel.org;
> mark.rutland@....com; devicetree@...r.kernel.org; linux-kernel@...r.kernel.org; Derek Kiernan <dkiernan@...inx.com>
> Subject: Re: [PATCH V4 04/12] misc: xilinx_sdfec: Add open, close and ioctl
> 
> On Sat, May 25, 2019 at 12:37:17PM +0100, Dragan Cvetic wrote:
> > +static int xsdfec_dev_open(struct inode *iptr, struct file *fptr)
> > +{
> > +	return 0;
> > +}
> > +
> > +static int xsdfec_dev_release(struct inode *iptr, struct file *fptr)
> > +{
> > +	return 0;
> > +}
> 
> empty open/close functions are never needed, just drop them.

Accepted.
Will remove them.

> 
> > +
> > +static long xsdfec_dev_ioctl(struct file *fptr, unsigned int cmd,
> > +			     unsigned long data)
> > +{
> > +	struct xsdfec_dev *xsdfec;
> > +	void __user *arg = NULL;
> > +	int rval = -EINVAL;
> > +
> > +	xsdfec = container_of(fptr->private_data, struct xsdfec_dev, miscdev);
> > +	if (!xsdfec)
> > +		return rval;
> 
> It is impossible for container_of() to return NULL, unless something
> very magical and rare just happened.  It's just doing pointer math, you
> can never check the return value of it.

Accepted.
Will remove if statement.

> 
> > +
> > +	if (_IOC_TYPE(cmd) != XSDFEC_MAGIC)
> > +		return -ENOTTY;
> 
> How can this happen?

Accepted.
Will be removed.

> 
> > +
> > +	/* check if ioctl argument is present and valid */
> > +	if (_IOC_DIR(cmd) != _IOC_NONE) {
> > +		arg = (void __user *)data;
> > +		if (!arg)
> > +			return rval;
> > +	}
> > +
> > +	switch (cmd) {
> > +	default:
> > +		/* Should not get here */
> > +		dev_warn(xsdfec->dev, "Undefined SDFEC IOCTL");
> 
> Nice that userspace has a way to fill up the kernel log :(
> 
> Just return the correct error here, don't log it.

Accepted.
Will remove log.

> 
> thanks,
> 
> greg k-h

Powered by blists - more mailing lists