CC: [email protected]
CC: [email protected]
TO: Tetsuo Handa <[email protected]>
CC: 0day robot <[email protected]>

tree:   
https://github.com/0day-ci/linux/commits/UPDATE-20210731-104259/Tetsuo-Handa/Bluetooth-reorganize-ioctls-from-hci_sock_bound_ioctl/20210720-185831
head:   e66f8c795ca2e66d4b1e630f074f0020edbc361d
commit: e66f8c795ca2e66d4b1e630f074f0020edbc361d Bluetooth: reorganize ioctls 
from hci_sock_bound_ioctl()
date:   5 hours ago
:::::: branch date: 5 hours ago
:::::: commit date: 5 hours ago
config: i386-randconfig-m021-20210730 (attached as .config)
compiler: gcc-10 (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0

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

New smatch warnings:
net/bluetooth/hci_sock.c:918 hci_set_raw() warn: passing a valid pointer to 
'PTR_ERR'
net/bluetooth/hci_sock.c:942 hci_get_conn_info() warn: passing a valid pointer 
to 'PTR_ERR'
net/bluetooth/hci_sock.c:979 hci_get_auth_info() warn: passing a valid pointer 
to 'PTR_ERR'
net/bluetooth/hci_sock.c:1009 hci_sock_reject_list_add() warn: passing a valid 
pointer to 'PTR_ERR'
net/bluetooth/hci_sock.c:1035 hci_sock_reject_list_del() warn: passing a valid 
pointer to 'PTR_ERR'

Old smatch warnings:
net/bluetooth/hci_sock.c:1611 hci_mgmt_cmd() warn: is 'buf' large enough for 
'struct mgmt_hdr'? s32min

vim +/PTR_ERR +918 net/bluetooth/hci_sock.c

e66f8c795ca2e6 Tetsuo Handa    2021-07-31   909  
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   910  static int hci_set_raw(struct 
sock *sk)
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   911  {
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   912         struct hci_dev *hdev;
5e762444b0d3e5 Antti Julku     2011-08-25   913         int err;
f03585689fdff4 Johan Hedberg   2010-05-18   914  
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   915         lock_sock(sk);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   916         hdev = 
validate_hdev_from_sock(sk);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   917         if (IS_ERR(hdev))
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  @918                 err = 
PTR_ERR(hdev);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   919         else if 
(!capable(CAP_NET_ADMIN))
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   920                 err = -EPERM;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   921         else
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   922                 err = 
-EOPNOTSUPP;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   923         release_sock(sk);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   924         return err;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   925  }
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   926  
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   927  static int 
hci_get_conn_info(struct sock *sk, void __user *arg)
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   928  {
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   929         struct hci_dev *hdev;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   930         struct 
hci_conn_info_req req;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   931         struct hci_conn_info ci;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   932         struct hci_conn *conn;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   933         int err = 0;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   934         char __user *ptr = arg 
+ sizeof(req);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   935  
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   936         if 
(copy_from_user(&req, arg, sizeof(req)))
f03585689fdff4 Johan Hedberg   2010-05-18   937                 return -EFAULT;
f03585689fdff4 Johan Hedberg   2010-05-18   938  
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   939         lock_sock(sk);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   940         hdev = 
validate_hdev_from_sock(sk);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   941         if (IS_ERR(hdev)) {
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  @942                 err = 
PTR_ERR(hdev);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   943                 goto out;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   944         }
09fd0de5bd8f8e Gustavo Padovan 2011-06-17   945         hci_dev_lock(hdev);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   946         conn = 
hci_conn_hash_lookup_ba(hdev, req.type, &req.bdaddr);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   947         if (conn) {
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   948                 
bacpy(&ci.bdaddr, &conn->dst);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   949                 ci.handle = 
conn->handle;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   950                 ci.type  = 
conn->type;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   951                 ci.out   = 
conn->out;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   952                 ci.state = 
conn->state;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   953                 ci.link_mode = 
hci_get_link_mode(conn);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   954         } else {
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   955                 err = -ENOENT;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   956         }
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   957         hci_dev_unlock(hdev);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   958   out:
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   959         release_sock(sk);
5e762444b0d3e5 Antti Julku     2011-08-25   960  
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   961         if (!err)
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   962                 err = 
copy_to_user(ptr, &ci, sizeof(ci)) ? -EFAULT : 0;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   963         return err;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   964  }
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   965  
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   966  static int 
hci_get_auth_info(struct sock *sk, void __user *arg)
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   967  {
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   968         struct hci_dev *hdev;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   969         struct 
hci_auth_info_req req;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   970         struct hci_conn *conn;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   971         int err = 0;
5e762444b0d3e5 Antti Julku     2011-08-25   972  
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   973         if 
(copy_from_user(&req, arg, sizeof(req)))
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   974                 return -EFAULT;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   975  
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   976         lock_sock(sk);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   977         hdev = 
validate_hdev_from_sock(sk);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   978         if (IS_ERR(hdev)) {
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  @979                 err = 
PTR_ERR(hdev);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   980                 goto out;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   981         }
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   982         hci_dev_lock(hdev);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   983         conn = 
hci_conn_hash_lookup_ba(hdev, ACL_LINK, &req.bdaddr);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   984         if (conn)
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   985                 req.type = 
conn->auth_type;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   986         else
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   987                 err = -ENOENT;
09fd0de5bd8f8e Gustavo Padovan 2011-06-17   988         hci_dev_unlock(hdev);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   989   out:
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   990         release_sock(sk);
5e762444b0d3e5 Antti Julku     2011-08-25   991  
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   992         if (!err)
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   993                 err = 
copy_to_user(arg, &req, sizeof(req)) ? -EFAULT : 0;
5e762444b0d3e5 Antti Julku     2011-08-25   994         return err;
f03585689fdff4 Johan Hedberg   2010-05-18   995  }
f03585689fdff4 Johan Hedberg   2010-05-18   996  
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   997  static int 
hci_sock_reject_list_add(struct sock *sk, void __user *arg)
f03585689fdff4 Johan Hedberg   2010-05-18   998  {
e66f8c795ca2e6 Tetsuo Handa    2021-07-31   999         struct hci_dev *hdev;
f03585689fdff4 Johan Hedberg   2010-05-18  1000         bdaddr_t bdaddr;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1001         int err = 0;
f03585689fdff4 Johan Hedberg   2010-05-18  1002  
f03585689fdff4 Johan Hedberg   2010-05-18  1003         if 
(copy_from_user(&bdaddr, arg, sizeof(bdaddr)))
f03585689fdff4 Johan Hedberg   2010-05-18  1004                 return -EFAULT;
f03585689fdff4 Johan Hedberg   2010-05-18  1005  
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1006         lock_sock(sk);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1007         hdev = 
validate_hdev_from_sock(sk);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1008         if (IS_ERR(hdev)) {
e66f8c795ca2e6 Tetsuo Handa    2021-07-31 @1009                 err = 
PTR_ERR(hdev);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1010                 goto out;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1011         } else if 
(!capable(CAP_NET_ADMIN)) {
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1012                 err = -EPERM;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1013                 goto out;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1014         }
09fd0de5bd8f8e Gustavo Padovan 2011-06-17  1015         hci_dev_lock(hdev);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1016         err = 
hci_bdaddr_list_add(&hdev->reject_list, &bdaddr, BDADDR_BREDR);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1017         hci_dev_unlock(hdev);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1018   out:
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1019         release_sock(sk);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1020         return err;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1021  }
5e762444b0d3e5 Antti Julku     2011-08-25  1022  
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1023  static int 
hci_sock_reject_list_del(struct sock *sk, void __user *arg)
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1024  {
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1025         struct hci_dev *hdev;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1026         bdaddr_t bdaddr;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1027         int err = 0;
5e762444b0d3e5 Antti Julku     2011-08-25  1028  
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1029         if 
(copy_from_user(&bdaddr, arg, sizeof(bdaddr)))
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1030                 return -EFAULT;
5e762444b0d3e5 Antti Julku     2011-08-25  1031  
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1032         lock_sock(sk);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1033         hdev = 
validate_hdev_from_sock(sk);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1034         if (IS_ERR(hdev)) {
e66f8c795ca2e6 Tetsuo Handa    2021-07-31 @1035                 err = 
PTR_ERR(hdev);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1036                 goto out;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1037         } else if 
(!capable(CAP_NET_ADMIN)) {
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1038                 err = -EPERM;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1039                 goto out;
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1040         }
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1041         hci_dev_lock(hdev);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1042         err = 
hci_bdaddr_list_del(&hdev->reject_list, &bdaddr, BDADDR_BREDR);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1043         hci_dev_unlock(hdev);
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1044   out:
e66f8c795ca2e6 Tetsuo Handa    2021-07-31  1045         release_sock(sk);
5e762444b0d3e5 Antti Julku     2011-08-25  1046         return err;
f03585689fdff4 Johan Hedberg   2010-05-18  1047  }
f03585689fdff4 Johan Hedberg   2010-05-18  1048  

---
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