CC: [email protected]
TO: "Greg Kroah-Hartman" <[email protected]>
CC: Richard Weinberger <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 
pending-fixes
head:   b1263ee340f7bb07f084ecb6a5b669f4fb5ee81f
commit: 210bec567936d3c5d1f980d3f767e524fd891ea2 [294/327] mtd: properly check 
all write ioctls for permissions
:::::: branch date: 8 hours ago
:::::: commit date: 11 hours ago
config: sparc-randconfig-c022-20200724 (attached as .config)
compiler: sparc-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
Reported-by: Julia Lawall <[email protected]>


coccinelle warnings: (new ones prefixed by >>)

>> drivers/mtd/mtdchar.c:1068:3-9: preceding lock on line 1059

# 
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=210bec567936d3c5d1f980d3f767e524fd891ea2
git remote add linux-next 
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git remote update linux-next
git checkout 210bec567936d3c5d1f980d3f767e524fd891ea2
vim +1068 drivers/mtd/mtdchar.c

977185404046af Kevin Cernekee     2009-04-08  1050  
969e57adc2589a Artem Bityutskiy   2011-12-23  1051  static long 
mtdchar_compat_ioctl(struct file *file, unsigned int cmd,
977185404046af Kevin Cernekee     2009-04-08  1052      unsigned long arg)
977185404046af Kevin Cernekee     2009-04-08  1053  {
977185404046af Kevin Cernekee     2009-04-08  1054      struct mtd_file_info 
*mfi = file->private_data;
977185404046af Kevin Cernekee     2009-04-08  1055      struct mtd_info *mtd = 
mfi->mtd;
0b6585ce05f169 David Woodhouse    2009-05-29  1056      void __user *argp = 
compat_ptr(arg);
977185404046af Kevin Cernekee     2009-04-08  1057      int ret = 0;
977185404046af Kevin Cernekee     2009-04-08  1058  
5aa82940b23d0c Arnd Bergmann      2010-06-02 @1059      mutex_lock(&mtd_mutex);
977185404046af Kevin Cernekee     2009-04-08  1060  
977185404046af Kevin Cernekee     2009-04-08  1061      switch (cmd) {
977185404046af Kevin Cernekee     2009-04-08  1062      case MEMWRITEOOB32:
977185404046af Kevin Cernekee     2009-04-08  1063      {
977185404046af Kevin Cernekee     2009-04-08  1064              struct 
mtd_oob_buf32 buf;
977185404046af Kevin Cernekee     2009-04-08  1065              struct 
mtd_oob_buf32 __user *buf_user = argp;
977185404046af Kevin Cernekee     2009-04-08  1066  
210bec567936d3 Greg Kroah-Hartman 2020-07-16  1067              if 
(!(file->f_mode & FMODE_WRITE))
210bec567936d3 Greg Kroah-Hartman 2020-07-16 @1068                      return 
-EPERM;
210bec567936d3 Greg Kroah-Hartman 2020-07-16  1069  
977185404046af Kevin Cernekee     2009-04-08  1070              if 
(copy_from_user(&buf, argp, sizeof(buf)))
977185404046af Kevin Cernekee     2009-04-08  1071                      ret = 
-EFAULT;
977185404046af Kevin Cernekee     2009-04-08  1072              else
969e57adc2589a Artem Bityutskiy   2011-12-23  1073                      ret = 
mtdchar_writeoob(file, mtd, buf.start,
977185404046af Kevin Cernekee     2009-04-08  1074                              
buf.length, compat_ptr(buf.ptr),
977185404046af Kevin Cernekee     2009-04-08  1075                              
&buf_user->length);
977185404046af Kevin Cernekee     2009-04-08  1076              break;
977185404046af Kevin Cernekee     2009-04-08  1077      }
977185404046af Kevin Cernekee     2009-04-08  1078  
977185404046af Kevin Cernekee     2009-04-08  1079      case MEMREADOOB32:
977185404046af Kevin Cernekee     2009-04-08  1080      {
977185404046af Kevin Cernekee     2009-04-08  1081              struct 
mtd_oob_buf32 buf;
977185404046af Kevin Cernekee     2009-04-08  1082              struct 
mtd_oob_buf32 __user *buf_user = argp;
977185404046af Kevin Cernekee     2009-04-08  1083  
977185404046af Kevin Cernekee     2009-04-08  1084              /* NOTE: writes 
return length to buf->start */
977185404046af Kevin Cernekee     2009-04-08  1085              if 
(copy_from_user(&buf, argp, sizeof(buf)))
977185404046af Kevin Cernekee     2009-04-08  1086                      ret = 
-EFAULT;
977185404046af Kevin Cernekee     2009-04-08  1087              else
969e57adc2589a Artem Bityutskiy   2011-12-23  1088                      ret = 
mtdchar_readoob(file, mtd, buf.start,
977185404046af Kevin Cernekee     2009-04-08  1089                              
buf.length, compat_ptr(buf.ptr),
977185404046af Kevin Cernekee     2009-04-08  1090                              
&buf_user->start);
977185404046af Kevin Cernekee     2009-04-08  1091              break;
977185404046af Kevin Cernekee     2009-04-08  1092      }
53bb724f94f57b Brian Norris       2015-09-21  1093  
53bb724f94f57b Brian Norris       2015-09-21  1094      case BLKPG:
53bb724f94f57b Brian Norris       2015-09-21  1095      {
53bb724f94f57b Brian Norris       2015-09-21  1096              /* Convert from 
blkpg_compat_ioctl_arg to blkpg_ioctl_arg */
53bb724f94f57b Brian Norris       2015-09-21  1097              struct 
blkpg_compat_ioctl_arg __user *uarg = argp;
53bb724f94f57b Brian Norris       2015-09-21  1098              struct 
blkpg_compat_ioctl_arg compat_arg;
53bb724f94f57b Brian Norris       2015-09-21  1099              struct 
blkpg_ioctl_arg a;
53bb724f94f57b Brian Norris       2015-09-21  1100  
53bb724f94f57b Brian Norris       2015-09-21  1101              if 
(copy_from_user(&compat_arg, uarg, sizeof(compat_arg))) {
53bb724f94f57b Brian Norris       2015-09-21  1102                      ret = 
-EFAULT;
53bb724f94f57b Brian Norris       2015-09-21  1103                      break;
53bb724f94f57b Brian Norris       2015-09-21  1104              }
53bb724f94f57b Brian Norris       2015-09-21  1105  
53bb724f94f57b Brian Norris       2015-09-21  1106              memset(&a, 0, 
sizeof(a));
53bb724f94f57b Brian Norris       2015-09-21  1107              a.op = 
compat_arg.op;
53bb724f94f57b Brian Norris       2015-09-21  1108              a.flags = 
compat_arg.flags;
53bb724f94f57b Brian Norris       2015-09-21  1109              a.datalen = 
compat_arg.datalen;
53bb724f94f57b Brian Norris       2015-09-21  1110              a.data = 
compat_ptr(compat_arg.data);
53bb724f94f57b Brian Norris       2015-09-21  1111  
53bb724f94f57b Brian Norris       2015-09-21  1112              ret = 
mtdchar_blkpg_ioctl(mtd, &a);
53bb724f94f57b Brian Norris       2015-09-21  1113              break;
53bb724f94f57b Brian Norris       2015-09-21  1114      }
53bb724f94f57b Brian Norris       2015-09-21  1115  
977185404046af Kevin Cernekee     2009-04-08  1116      default:
969e57adc2589a Artem Bityutskiy   2011-12-23  1117              ret = 
mtdchar_ioctl(file, cmd, (unsigned long)argp);
977185404046af Kevin Cernekee     2009-04-08  1118      }
977185404046af Kevin Cernekee     2009-04-08  1119  
5aa82940b23d0c Arnd Bergmann      2010-06-02  1120      
mutex_unlock(&mtd_mutex);
977185404046af Kevin Cernekee     2009-04-08  1121  
977185404046af Kevin Cernekee     2009-04-08  1122      return ret;
977185404046af Kevin Cernekee     2009-04-08  1123  }
977185404046af Kevin Cernekee     2009-04-08  1124  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to