Skip to content

Commit b3edef6

Browse files
sprasad-microsoftSteve French
authored andcommitted
cifs: allow dumping keys for directories too
Dumping the enc/dec keys is a session wide operation. And it should not matter if the ioctl was run on a regular file or a directory. Currently, we obtain the tcon pointer from the cifs file handle. But since there's no dir open call in cifs, this is not populated for dirs. This change allows dumping of session keys using ioctl even for directories. To do this, we'll now get the tcon pointer from the superblock, and not from the file handle. Signed-off-by: Shyam Prasad N <sprasad@microsoft.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent fdf0eaf commit b3edef6

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

fs/smb/client/ioctl.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,16 +433,21 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
433433
* Dump encryption keys. This is an old ioctl that only
434434
* handles AES-128-{CCM,GCM}.
435435
*/
436-
if (pSMBFile == NULL)
437-
break;
438436
if (!capable(CAP_SYS_ADMIN)) {
439437
rc = -EACCES;
440438
break;
441439
}
442440

443-
tcon = tlink_tcon(pSMBFile->tlink);
441+
cifs_sb = CIFS_SB(inode->i_sb);
442+
tlink = cifs_sb_tlink(cifs_sb);
443+
if (IS_ERR(tlink)) {
444+
rc = PTR_ERR(tlink);
445+
break;
446+
}
447+
tcon = tlink_tcon(tlink);
444448
if (!smb3_encryption_required(tcon)) {
445449
rc = -EOPNOTSUPP;
450+
cifs_put_tlink(tlink);
446451
break;
447452
}
448453
pkey_inf.cipher_type =
@@ -459,6 +464,7 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
459464
rc = -EFAULT;
460465
else
461466
rc = 0;
467+
cifs_put_tlink(tlink);
462468
break;
463469
case CIFS_DUMP_FULL_KEY:
464470
/*
@@ -470,8 +476,11 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
470476
rc = -EACCES;
471477
break;
472478
}
473-
tcon = tlink_tcon(pSMBFile->tlink);
479+
cifs_sb = CIFS_SB(inode->i_sb);
480+
tlink = cifs_sb_tlink(cifs_sb);
481+
tcon = tlink_tcon(tlink);
474482
rc = cifs_dump_full_key(tcon, (void __user *)arg);
483+
cifs_put_tlink(tlink);
475484
break;
476485
case CIFS_IOC_NOTIFY:
477486
if (!S_ISDIR(inode->i_mode)) {

0 commit comments

Comments
 (0)