tree:
git://github.com/smfrench/smb3-kernel.git ksmbd-for-next-next
head: f460c65a2585c6b3d8222c67a59bbfb1fc2bd161
commit: f460c65a2585c6b3d8222c67a59bbfb1fc2bd161 [11/11] ksmbd: smbd: fix missing
client's memory region invalidation
config: arm-randconfig-r033-20220112
(
https://download.01.org/0day-ci/archive/20220113/202201130745.9ifbjMig-lk...)
compiler: clang version 14.0.0 (
https://github.com/llvm/llvm-project
244dd2913a43a200f5a6544d424cdc37b771028b)
reproduce (this is a W=1 build):
wget
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O
~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
#
https://github.com/smfrench/smb3-kernel/commit/f460c65a2585c6b3d8222c67a5...
git remote add smfrench-smb3
git://github.com/smfrench/smb3-kernel.git
git fetch --no-tags smfrench-smb3 ksmbd-for-next-next
git checkout f460c65a2585c6b3d8222c67a59bbfb1fc2bd161
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir
ARCH=arm SHELL=/bin/bash fs/ksmbd/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
> fs/ksmbd/smb2pdu.c:6198:7: warning: variable 'fp' is used
uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (err)
^~~
fs/ksmbd/smb2pdu.c:6301:21: note: uninitialized use occurs here
ksmbd_fd_put(work, fp);
^~
fs/ksmbd/smb2pdu.c:6198:3: note: remove the 'if' if its condition is always
false
if (err)
^~~~~~~~
fs/ksmbd/smb2pdu.c:6176:23: note: initialize the variable 'fp' to silence this
warning
struct ksmbd_file *fp;
^
= NULL
1 warning generated.
vim +6198 fs/ksmbd/smb2pdu.c
6164
6165 /**
6166 * smb2_read() - handler for smb2 read from file
6167 * @work: smb work containing read command buffer
6168 *
6169 * Return: 0 on success, otherwise error
6170 */
6171 int smb2_read(struct ksmbd_work *work)
6172 {
6173 struct ksmbd_conn *conn = work->conn;
6174 struct smb2_read_req *req;
6175 struct smb2_read_rsp *rsp;
6176 struct ksmbd_file *fp;
6177 loff_t offset;
6178 size_t length, mincount;
6179 ssize_t nbytes = 0, remain_bytes = 0;
6180 int err = 0;
6181
6182 WORK_BUFFERS(work, req, rsp);
6183
6184 if (test_share_config_flag(work->tcon->share_conf,
6185 KSMBD_SHARE_FLAG_PIPE)) {
6186 ksmbd_debug(SMB, "IPC pipe read request\n");
6187 return smb2_read_pipe(work);
6188 }
6189
6190 if (req->Channel == SMB2_CHANNEL_RDMA_V1_INVALIDATE ||
6191 req->Channel == SMB2_CHANNEL_RDMA_V1) {
6192 err = smb2_set_remote_key_for_rdma(work,
6193 (struct smb2_buffer_desc_v1 *)
6194 &req->Buffer[0],
6195 req->Channel,
6196 req->ReadChannelInfoOffset,
6197 req->ReadChannelInfoLength);
6198 if (err)
6199 goto out;
6200 }
6201
6202 fp = ksmbd_lookup_fd_slow(work, le64_to_cpu(req->VolatileFileId),
6203 le64_to_cpu(req->PersistentFileId));
6204 if (!fp) {
6205 err = -ENOENT;
6206 goto out;
6207 }
6208
6209 if (!(fp->daccess & (FILE_READ_DATA_LE | FILE_READ_ATTRIBUTES_LE))) {
6210 pr_err("Not permitted to read : 0x%x\n", fp->daccess);
6211 err = -EACCES;
6212 goto out;
6213 }
6214
6215 offset = le64_to_cpu(req->Offset);
6216 length = le32_to_cpu(req->Length);
6217 mincount = le32_to_cpu(req->MinimumCount);
6218
6219 if (length > conn->vals->max_read_size) {
6220 ksmbd_debug(SMB, "limiting read size to max size(%u)\n",
6221 conn->vals->max_read_size);
6222 err = -EINVAL;
6223 goto out;
6224 }
6225
6226 ksmbd_debug(SMB, "filename %pd, offset %lld, len %zu\n",
6227 fp->filp->f_path.dentry, offset, length);
6228
6229 work->aux_payload_buf = kvmalloc(length, GFP_KERNEL | __GFP_ZERO);
6230 if (!work->aux_payload_buf) {
6231 err = -ENOMEM;
6232 goto out;
6233 }
6234
6235 nbytes = ksmbd_vfs_read(work, fp, length, &offset);
6236 if (nbytes < 0) {
6237 err = nbytes;
6238 goto out;
6239 }
6240
6241 if ((nbytes == 0 && length != 0) || nbytes < mincount) {
6242 kvfree(work->aux_payload_buf);
6243 work->aux_payload_buf = NULL;
6244 rsp->hdr.Status = STATUS_END_OF_FILE;
6245 smb2_set_err_rsp(work);
6246 ksmbd_fd_put(work, fp);
6247 return 0;
6248 }
6249
6250 ksmbd_debug(SMB, "nbytes %zu, offset %lld mincount %zu\n",
6251 nbytes, offset, mincount);
6252
6253 if (req->Channel == SMB2_CHANNEL_RDMA_V1_INVALIDATE ||
6254 req->Channel == SMB2_CHANNEL_RDMA_V1) {
6255 /* write data to the client using rdma channel */
6256 remain_bytes = smb2_read_rdma_channel(work, req,
6257 work->aux_payload_buf,
6258 nbytes);
6259 kvfree(work->aux_payload_buf);
6260 work->aux_payload_buf = NULL;
6261
6262 nbytes = 0;
6263 if (remain_bytes < 0) {
6264 err = (int)remain_bytes;
6265 goto out;
6266 }
6267 }
6268
6269 rsp->StructureSize = cpu_to_le16(17);
6270 rsp->DataOffset = 80;
6271 rsp->Reserved = 0;
6272 rsp->DataLength = cpu_to_le32(nbytes);
6273 rsp->DataRemaining = cpu_to_le32(remain_bytes);
6274 rsp->Flags = 0;
6275 inc_rfc1001_len(work->response_buf, 16);
6276 work->resp_hdr_sz = get_rfc1002_len(work->response_buf) + 4;
6277 work->aux_payload_sz = nbytes;
6278 inc_rfc1001_len(work->response_buf, nbytes);
6279 ksmbd_fd_put(work, fp);
6280 return 0;
6281
6282 out:
6283 if (err) {
6284 if (err == -EISDIR)
6285 rsp->hdr.Status = STATUS_INVALID_DEVICE_REQUEST;
6286 else if (err == -EAGAIN)
6287 rsp->hdr.Status = STATUS_FILE_LOCK_CONFLICT;
6288 else if (err == -ENOENT)
6289 rsp->hdr.Status = STATUS_FILE_CLOSED;
6290 else if (err == -EACCES)
6291 rsp->hdr.Status = STATUS_ACCESS_DENIED;
6292 else if (err == -ESHARE)
6293 rsp->hdr.Status = STATUS_SHARING_VIOLATION;
6294 else if (err == -EINVAL)
6295 rsp->hdr.Status = STATUS_INVALID_PARAMETER;
6296 else
6297 rsp->hdr.Status = STATUS_INVALID_HANDLE;
6298
6299 smb2_set_err_rsp(work);
6300 }
6301 ksmbd_fd_put(work, fp);
6302 return err;
6303 }
6304
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org