Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 61876395 authored by Jeff Layton's avatar Jeff Layton Committed by Steve French
Browse files

cifs: make cifs_ioctl handle NULL filp->private_data correctly



Commit 13cfb733 made cifs_ioctl use the tlink attached to the
cifsFileInfo for a filp. This ignores the case of an open directory
however, which in CIFS can have a NULL private_data until a readdir
is done on it.

This patch re-adds the NULL pointer checks that were removed in commit
50ae28f0 and moves the setting of tcon and "caps" variables lower.

Long term, a better fix would be to establish a f_op->open routine for
directories that populates that field at open time, but that requires
some other changes to how readdir calls are handled.

Reported-by: default avatarKjell Rune Skaaraas <kjella79@yahoo.no>
Reviewed-and-Tested-by: default avatarSuresh Jayaraman <sjayaraman@suse.de>
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent 151f52f0
Loading
Loading
Loading
Loading
+10 −2
Original line number Original line Diff line number Diff line
@@ -38,10 +38,10 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
	struct cifs_sb_info *cifs_sb;
	struct cifs_sb_info *cifs_sb;
#ifdef CONFIG_CIFS_POSIX
#ifdef CONFIG_CIFS_POSIX
	struct cifsFileInfo *pSMBFile = filep->private_data;
	struct cifsFileInfo *pSMBFile = filep->private_data;
	struct cifsTconInfo *tcon = tlink_tcon(pSMBFile->tlink);
	struct cifsTconInfo *tcon;
	__u64	ExtAttrBits = 0;
	__u64	ExtAttrBits = 0;
	__u64	ExtAttrMask = 0;
	__u64	ExtAttrMask = 0;
	__u64   caps = le64_to_cpu(tcon->fsUnixInfo.Capability);
	__u64   caps;
#endif /* CONFIG_CIFS_POSIX */
#endif /* CONFIG_CIFS_POSIX */


	xid = GetXid();
	xid = GetXid();
@@ -62,6 +62,10 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
			break;
			break;
#ifdef CONFIG_CIFS_POSIX
#ifdef CONFIG_CIFS_POSIX
		case FS_IOC_GETFLAGS:
		case FS_IOC_GETFLAGS:
			if (pSMBFile == NULL)
				break;
			tcon = tlink_tcon(pSMBFile->tlink);
			caps = le64_to_cpu(tcon->fsUnixInfo.Capability);
			if (CIFS_UNIX_EXTATTR_CAP & caps) {
			if (CIFS_UNIX_EXTATTR_CAP & caps) {
				rc = CIFSGetExtAttr(xid, tcon, pSMBFile->netfid,
				rc = CIFSGetExtAttr(xid, tcon, pSMBFile->netfid,
					&ExtAttrBits, &ExtAttrMask);
					&ExtAttrBits, &ExtAttrMask);
@@ -73,6 +77,10 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
			break;
			break;


		case FS_IOC_SETFLAGS:
		case FS_IOC_SETFLAGS:
			if (pSMBFile == NULL)
				break;
			tcon = tlink_tcon(pSMBFile->tlink);
			caps = le64_to_cpu(tcon->fsUnixInfo.Capability);
			if (CIFS_UNIX_EXTATTR_CAP & caps) {
			if (CIFS_UNIX_EXTATTR_CAP & caps) {
				if (get_user(ExtAttrBits, (int __user *)arg)) {
				if (get_user(ExtAttrBits, (int __user *)arg)) {
					rc = -EFAULT;
					rc = -EFAULT;