Re: [PATCH 5.4.y] Revert "ia64: kprobes: Use generic kretprobe trampoline handler"
by kernel test robot
Hi Masami,
I love your patch! Perhaps something to improve:
[auto build test WARNING on stable/linux-5.4.y]
url: https://github.com/0day-ci/linux/commits/Masami-Hiramatsu/Revert-ia64-kpr...
base: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-5.4.y
config: ia64-allmodconfig (https://download.01.org/0day-ci/archive/20220115/202201151231.g2sW8oWt-lk...)
compiler: ia64-linux-gcc (GCC) 11.2.0
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
# https://github.com/0day-ci/linux/commit/514059de80b018e0edcf434519ff6bf41...
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Masami-Hiramatsu/Revert-ia64-kprobes-Use-generic-kretprobe-trampoline-handler/20220114-182111
git checkout 514059de80b018e0edcf434519ff6bf41b4a519b
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=ia64 SHELL=/bin/bash
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 >>):
arch/ia64/kernel/kprobes.c: In function 'get_kprobe_inst':
arch/ia64/kernel/kprobes.c:325:22: warning: variable 'template' set but not used [-Wunused-but-set-variable]
325 | unsigned int template;
| ^~~~~~~~
arch/ia64/kernel/kprobes.c: At top level:
arch/ia64/kernel/kprobes.c:407:15: warning: no previous prototype for 'trampoline_probe_handler' [-Wmissing-prototypes]
407 | int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
| ^~~~~~~~~~~~~~~~~~~~~~~~
arch/ia64/kernel/kprobes.c: In function 'trampoline_probe_handler':
>> arch/ia64/kernel/kprobes.c:414:17: warning: initialization of 'long unsigned int' from 'void *' makes integer from pointer without a cast [-Wint-conversion]
414 | dereference_function_descriptor(kretprobe_trampoline);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for FRAME_POINTER
Depends on DEBUG_KERNEL && (M68K || UML || SUPERH) || ARCH_WANT_FRAME_POINTERS
Selected by
- FAULT_INJECTION_STACKTRACE_FILTER && FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT && !X86_64 && !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM && !ARC && !X86
vim +414 arch/ia64/kernel/kprobes.c
320
321 static void __kprobes get_kprobe_inst(bundle_t *bundle, uint slot,
322 unsigned long *kprobe_inst, uint *major_opcode)
323 {
324 unsigned long kprobe_inst_p0, kprobe_inst_p1;
> 325 unsigned int template;
326
327 template = bundle->quad0.template;
328
329 switch (slot) {
330 case 0:
331 *major_opcode = (bundle->quad0.slot0 >> SLOT0_OPCODE_SHIFT);
332 *kprobe_inst = bundle->quad0.slot0;
333 break;
334 case 1:
335 *major_opcode = (bundle->quad1.slot1_p1 >> SLOT1_p1_OPCODE_SHIFT);
336 kprobe_inst_p0 = bundle->quad0.slot1_p0;
337 kprobe_inst_p1 = bundle->quad1.slot1_p1;
338 *kprobe_inst = kprobe_inst_p0 | (kprobe_inst_p1 << (64-46));
339 break;
340 case 2:
341 *major_opcode = (bundle->quad1.slot2 >> SLOT2_OPCODE_SHIFT);
342 *kprobe_inst = bundle->quad1.slot2;
343 break;
344 }
345 }
346
347 /* Returns non-zero if the addr is in the Interrupt Vector Table */
348 static int __kprobes in_ivt_functions(unsigned long addr)
349 {
350 return (addr >= (unsigned long)__start_ivt_text
351 && addr < (unsigned long)__end_ivt_text);
352 }
353
354 static int __kprobes valid_kprobe_addr(int template, int slot,
355 unsigned long addr)
356 {
357 if ((slot > 2) || ((bundle_encoding[template][1] == L) && slot > 1)) {
358 printk(KERN_WARNING "Attempting to insert unaligned kprobe "
359 "at 0x%lx\n", addr);
360 return -EINVAL;
361 }
362
363 if (in_ivt_functions(addr)) {
364 printk(KERN_WARNING "Kprobes can't be inserted inside "
365 "IVT functions at 0x%lx\n", addr);
366 return -EINVAL;
367 }
368
369 return 0;
370 }
371
372 static void __kprobes save_previous_kprobe(struct kprobe_ctlblk *kcb)
373 {
374 unsigned int i;
375 i = atomic_add_return(1, &kcb->prev_kprobe_index);
376 kcb->prev_kprobe[i-1].kp = kprobe_running();
377 kcb->prev_kprobe[i-1].status = kcb->kprobe_status;
378 }
379
380 static void __kprobes restore_previous_kprobe(struct kprobe_ctlblk *kcb)
381 {
382 unsigned int i;
383 i = atomic_read(&kcb->prev_kprobe_index);
384 __this_cpu_write(current_kprobe, kcb->prev_kprobe[i-1].kp);
385 kcb->kprobe_status = kcb->prev_kprobe[i-1].status;
386 atomic_sub(1, &kcb->prev_kprobe_index);
387 }
388
389 static void __kprobes set_current_kprobe(struct kprobe *p,
390 struct kprobe_ctlblk *kcb)
391 {
392 __this_cpu_write(current_kprobe, p);
393 }
394
395 static void kretprobe_trampoline(void)
396 {
397 }
398
399 /*
400 * At this point the target function has been tricked into
401 * returning into our trampoline. Lookup the associated instance
402 * and then:
403 * - call the handler function
404 * - cleanup by marking the instance as unused
405 * - long jump back to the original return address
406 */
407 int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
408 {
409 struct kretprobe_instance *ri = NULL;
410 struct hlist_head *head, empty_rp;
411 struct hlist_node *tmp;
412 unsigned long flags, orig_ret_address = 0;
413 unsigned long trampoline_address =
> 414 dereference_function_descriptor(kretprobe_trampoline);
415
416 INIT_HLIST_HEAD(&empty_rp);
417 kretprobe_hash_lock(current, &head, &flags);
418
419 /*
420 * It is possible to have multiple instances associated with a given
421 * task either because an multiple functions in the call path
422 * have a return probe installed on them, and/or more than one return
423 * return probe was registered for a target function.
424 *
425 * We can handle this because:
426 * - instances are always inserted at the head of the list
427 * - when multiple return probes are registered for the same
428 * function, the first instance's ret_addr will point to the
429 * real return address, and all the rest will point to
430 * kretprobe_trampoline
431 */
432 hlist_for_each_entry_safe(ri, tmp, head, hlist) {
433 if (ri->task != current)
434 /* another task is sharing our hash bucket */
435 continue;
436
437 orig_ret_address = (unsigned long)ri->ret_addr;
438 if (orig_ret_address != trampoline_address)
439 /*
440 * This is the real return address. Any other
441 * instances associated with this task are for
442 * other calls deeper on the call stack
443 */
444 break;
445 }
446
447 regs->cr_iip = orig_ret_address;
448
449 hlist_for_each_entry_safe(ri, tmp, head, hlist) {
450 if (ri->task != current)
451 /* another task is sharing our hash bucket */
452 continue;
453
454 if (ri->rp && ri->rp->handler)
455 ri->rp->handler(ri, regs);
456
457 orig_ret_address = (unsigned long)ri->ret_addr;
458 recycle_rp_inst(ri, &empty_rp);
459
460 if (orig_ret_address != trampoline_address)
461 /*
462 * This is the real return address. Any other
463 * instances associated with this task are for
464 * other calls deeper on the call stack
465 */
466 break;
467 }
468 kretprobe_assert(ri, orig_ret_address, trampoline_address);
469
470 kretprobe_hash_unlock(current, &flags);
471
472 hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) {
473 hlist_del(&ri->hlist);
474 kfree(ri);
475 }
476 /*
477 * By returning a non-zero value, we are telling
478 * kprobe_handler() that we don't want the post_handler
479 * to run (and have re-enabled preemption)
480 */
481 return 1;
482 }
483
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
8 months, 1 week
[hch-block:bio_alloc-cleanup 37/41] fs/f2fs/segment.c:1864:6: warning: format specifies type 'long' but the argument has type 'int'
by kernel test robot
tree: git://git.infradead.org/users/hch/block.git bio_alloc-cleanup
head: f033ae7a0e5d8529000f3760d24650e8c468fb65
commit: 41af664fdb39fe3a5cc1e2d6639795ee98efe514 [37/41] f2fs: return a f2fs_dev_info from f2fs_target_device
config: hexagon-randconfig-r045-20220113 (https://download.01.org/0day-ci/archive/20220115/202201151829.6khiENhN-lk...)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 650fc40b6d8d9a5869b4fca525d5f237b0ee2803)
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
git remote add hch-block git://git.infradead.org/users/hch/block.git
git fetch --no-tags hch-block bio_alloc-cleanup
git checkout 41af664fdb39fe3a5cc1e2d6639795ee98efe514
# 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=hexagon SHELL=/bin/bash fs/f2fs/
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/f2fs/segment.c:1864:6: warning: format specifies type 'long' but the argument has type 'int' [-Wformat]
di - sbi->devs, sbi->s_ndevs ? di->path : "",
^~~~~~~~~~~~~~
fs/f2fs/f2fs.h:2241:35: note: expanded from macro 'f2fs_err'
f2fs_printk(sbi, KERN_ERR fmt, ##__VA_ARGS__)
~~~ ^~~~~~~~~~~
1 warning generated.
vim +1864 fs/f2fs/segment.c
1844
1845 #ifdef CONFIG_BLK_DEV_ZONED
1846 static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
1847 struct block_device *bdev, block_t blkstart, block_t blklen)
1848 {
1849 sector_t sector, nr_sects;
1850 block_t lblkstart = blkstart;
1851 struct f2fs_dev_info *di = f2fs_target_device(sbi, blkstart);
1852
1853 if (f2fs_is_multi_device(sbi))
1854 blkstart -= di->start_blk;
1855
1856 /* For sequential zones, reset the zone write pointer */
1857 if (f2fs_blkz_is_seq(sbi, di, blkstart)) {
1858 sector = SECTOR_FROM_BLOCK(blkstart);
1859 nr_sects = SECTOR_FROM_BLOCK(blklen);
1860
1861 if (sector & (bdev_zone_sectors(bdev) - 1) ||
1862 nr_sects != bdev_zone_sectors(bdev)) {
1863 f2fs_err(sbi, "(%ld) %s: Unaligned zone reset attempted (block %x + %x)",
> 1864 di - sbi->devs, sbi->s_ndevs ? di->path : "",
1865 blkstart, blklen);
1866 return -EIO;
1867 }
1868 trace_f2fs_issue_reset_zone(bdev, blkstart);
1869 return blkdev_zone_mgmt(bdev, REQ_OP_ZONE_RESET,
1870 sector, nr_sects, GFP_NOFS);
1871 }
1872
1873 /* For conventional zones, use regular discard if supported */
1874 return __queue_discard_cmd(sbi, bdev, lblkstart, blklen);
1875 }
1876 #endif
1877
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
8 months, 1 week
Re: [PATCH 2/3 v2] staging: rtl8723bs: Drop get_recvframe_data()
by kernel test robot
Hi Kees,
I love your patch! Yet something to improve:
[auto build test ERROR on staging/staging-testing]
url: https://github.com/0day-ci/linux/commits/Kees-Cook/staging-rtl-Check-for-...
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git fa783154524a71ab74e293cd8251155e5971952b
config: riscv-allyesconfig (https://download.01.org/0day-ci/archive/20220115/202201151724.U21w0KEg-lk...)
compiler: riscv64-linux-gcc (GCC) 11.2.0
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
# https://github.com/0day-ci/linux/commit/0ee2a9ea6309b9087293fe3b38a764219...
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Kees-Cook/staging-rtl-Check-for-NULL-header-value/20220115-122817
git checkout 0ee2a9ea6309b9087293fe3b38a76421998bff7d
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=riscv SHELL=/bin/bash drivers/staging/rtl8723bs/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All errors (new ones prefixed by >>):
drivers/staging/rtl8723bs/core/rtw_recv.c: In function 'portctrl':
>> drivers/staging/rtl8723bs/core/rtw_recv.c:468:15: error: 'precvframe' undeclared (first use in this function); did you mean 'precv_frame'?
468 | ptr = precvframe->u.hdr.rx_data;
| ^~~~~~~~~~
| precv_frame
drivers/staging/rtl8723bs/core/rtw_recv.c:468:15: note: each undeclared identifier is reported only once for each function it appears in
vim +468 drivers/staging/rtl8723bs/core/rtw_recv.c
449
450 /* set the security information in the recv_frame */
451 static union recv_frame *portctrl(struct adapter *adapter, union recv_frame *precv_frame)
452 {
453 u8 *psta_addr = NULL;
454 u8 *ptr;
455 uint auth_alg;
456 struct recv_frame_hdr *pfhdr;
457 struct sta_info *psta;
458 struct sta_priv *pstapriv;
459 union recv_frame *prtnframe;
460 u16 ether_type = 0;
461 u16 eapol_type = 0x888e;/* for Funia BD's WPA issue */
462 struct rx_pkt_attrib *pattrib;
463
464 pstapriv = &adapter->stapriv;
465
466 auth_alg = adapter->securitypriv.dot11AuthAlgrthm;
467
> 468 ptr = precvframe->u.hdr.rx_data;
469 pfhdr = &precv_frame->u.hdr;
470 pattrib = &pfhdr->attrib;
471 psta_addr = pattrib->ta;
472
473 prtnframe = NULL;
474
475 psta = rtw_get_stainfo(pstapriv, psta_addr);
476
477 if (auth_alg == 2) {
478 if ((psta) && (psta->ieee8021x_blocked)) {
479 __be16 be_tmp;
480
481 /* blocked */
482 /* only accept EAPOL frame */
483
484 prtnframe = precv_frame;
485
486 /* get ether_type */
487 ptr = ptr + pfhdr->attrib.hdrlen + pfhdr->attrib.iv_len + LLC_HEADER_LENGTH;
488 memcpy(&be_tmp, ptr, 2);
489 ether_type = ntohs(be_tmp);
490
491 if (ether_type == eapol_type)
492 prtnframe = precv_frame;
493 else {
494 /* free this frame */
495 rtw_free_recvframe(precv_frame, &adapter->recvpriv.free_recv_queue);
496 prtnframe = NULL;
497 }
498 } else {
499 /* allowed */
500 /* check decryption status, and decrypt the frame if needed */
501
502 prtnframe = precv_frame;
503 /* check is the EAPOL frame or not (Rekey) */
504 /* if (ether_type == eapol_type) { */
505 /* check Rekey */
506
507 /* prtnframe =precv_frame; */
508 /* */
509 /* else { */
510 /* */
511 }
512 } else
513 prtnframe = precv_frame;
514
515 return prtnframe;
516 }
517
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
8 months, 1 week
[mingo-tip:sched/headers 2353/2384] drivers/media/rc/mtk-cir.c:163:15: error: implicit declaration of function 'DIV_ROUND_CLOSEST'
by kernel test robot
tree: git://git.kernel.org/pub/scm/linux/kernel/git/mingo/tip.git sched/headers
head: 4c707c1c0de83967079b4e385012fa5b00e2cd11
commit: 6bdaa08124f2198c510118e5ae8816748e9816df [2353/2384] headers/deps: time: Optimize <linux/time64.h> dependencies, remove <linux/time64_api.h> inclusion
config: mips-randconfig-r036-20220113 (https://download.01.org/0day-ci/archive/20220115/202201151534.1iCJKuH9-lk...)
compiler: mips-linux-gcc (GCC) 11.2.0
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
# https://git.kernel.org/pub/scm/linux/kernel/git/mingo/tip.git/commit/?id=...
git remote add mingo-tip git://git.kernel.org/pub/scm/linux/kernel/git/mingo/tip.git
git fetch --no-tags mingo-tip sched/headers
git checkout 6bdaa08124f2198c510118e5ae8816748e9816df
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=mips SHELL=/bin/bash drivers/media/rc/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All errors (new ones prefixed by >>):
drivers/media/rc/mtk-cir.c: In function 'mtk_chk_period':
>> drivers/media/rc/mtk-cir.c:163:15: error: implicit declaration of function 'DIV_ROUND_CLOSEST' [-Werror=implicit-function-declaration]
163 | val = DIV_ROUND_CLOSEST(clk_get_rate(ir->bus),
| ^~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/DIV_ROUND_CLOSEST +163 drivers/media/rc/mtk-cir.c
50c3c1ba171f3f Sean Wang 2017-06-30 154
50c3c1ba171f3f Sean Wang 2017-06-30 155 static inline u32 mtk_chk_period(struct mtk_ir *ir)
50c3c1ba171f3f Sean Wang 2017-06-30 156 {
50c3c1ba171f3f Sean Wang 2017-06-30 157 u32 val;
50c3c1ba171f3f Sean Wang 2017-06-30 158
50c3c1ba171f3f Sean Wang 2017-06-30 159 /*
50c3c1ba171f3f Sean Wang 2017-06-30 160 * Period for software decoder used in the
50c3c1ba171f3f Sean Wang 2017-06-30 161 * unit of raw software sampling
50c3c1ba171f3f Sean Wang 2017-06-30 162 */
d904eb0b351fe5 Sean Young 2020-11-29 @163 val = DIV_ROUND_CLOSEST(clk_get_rate(ir->bus),
d904eb0b351fe5 Sean Young 2020-11-29 164 USEC_PER_SEC * ir->data->div / MTK_IR_SAMPLE);
50c3c1ba171f3f Sean Wang 2017-06-30 165
50c3c1ba171f3f Sean Wang 2017-06-30 166 dev_dbg(ir->dev, "@pwm clk = \t%lu\n",
50c3c1ba171f3f Sean Wang 2017-06-30 167 clk_get_rate(ir->bus) / ir->data->div);
50c3c1ba171f3f Sean Wang 2017-06-30 168 dev_dbg(ir->dev, "@chkperiod = %08x\n", val);
50c3c1ba171f3f Sean Wang 2017-06-30 169
50c3c1ba171f3f Sean Wang 2017-06-30 170 return val;
50c3c1ba171f3f Sean Wang 2017-06-30 171 }
50c3c1ba171f3f Sean Wang 2017-06-30 172
:::::: The code at line 163 was first introduced by commit
:::::: d904eb0b351fe5545d9ba5b85844342f49025923 media: mtk-cir: fix calculation of chk period
:::::: TO: Sean Young <sean(a)mess.org>
:::::: CC: Mauro Carvalho Chehab <mchehab+huawei(a)kernel.org>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
8 months, 1 week
[cel:topic-rpc-with-tls-upcall 15/18] net/tls/af_tlsh.c:506: undefined reference to `inet6_recvmsg'
by kernel test robot
tree: git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux topic-rpc-with-tls-upcall
head: efd60be1122b3ae06572c5cfbe440970ea1fbb3d
commit: dc7c282f13f7d10eb5343d5d9fd2fcaa647ce216 [15/18] net/tls: Add support for PF_TLSH (a TLS handshake listener)
config: i386-randconfig-a005 (https://download.01.org/0day-ci/archive/20220115/202201151407.neTGwaOK-lk...)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# https://git.kernel.org/pub/scm/linux/kernel/git/cel/linux.git/commit/?id=...
git remote add cel git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux
git fetch --no-tags cel topic-rpc-with-tls-upcall
git checkout dc7c282f13f7d10eb5343d5d9fd2fcaa647ce216
# save the config file to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All errors (new ones prefixed by >>):
ld: net/tls/af_tlsh.o: in function `tlsh_recvmsg':
>> net/tls/af_tlsh.c:506: undefined reference to `inet6_recvmsg'
ld: net/tls/af_tlsh.o: in function `tlsh_sendmsg':
>> net/tls/af_tlsh.c:476: undefined reference to `inet6_sendmsg'
ld: net/tls/af_tlsh.o: in function `tlsh_getname':
>> net/tls/af_tlsh.c:316: undefined reference to `inet6_getname'
vim +506 net/tls/af_tlsh.c
296
297 /**
298 * tlsh_getname - retrieve src/dst address information
299 * @sock: socket to query
300 * @uaddr: buffer to fill in
301 * @peer: value indicates which address to retrieve
302 *
303 * Return values:
304 * On success, a positive length of the address in @uaddr
305 * On error, a negative errno
306 */
307 static int tlsh_getname(struct socket *sock, struct sockaddr *uaddr, int peer)
308 {
309 struct sock *sk = sock->sk;
310
311 switch (sk->sk_family) {
312 case AF_INET:
313 return inet_getname(sock, uaddr, peer);
314 #if IS_ENABLED(CONFIG_IPV6)
315 case AF_INET6:
> 316 return inet6_getname(sock, uaddr, peer);
317 #endif
318 default:
319 return -EOPNOTSUPP;
320 }
321 }
322
323 /**
324 * tlsh_poll - check for data ready on an AF_TLSH socket
325 * @file: file to check for work
326 * @sock: socket associated with @file
327 * @wait: poll table
328 *
329 * Return values:
330 * A mask of flags indicating what type of I/O is ready
331 */
332 static __poll_t tlsh_poll(struct file *file, struct socket *sock,
333 poll_table *wait)
334 {
335 struct sock *sk = sock->sk;
336 __poll_t revents;
337
338 sock_poll_wait(file, sock, wait);
339
340 revents = 0;
341
342 if (sk->sk_err)
343 revents |= EPOLLERR;
344
345 if (sk->sk_shutdown == SHUTDOWN_MASK)
346 revents |= EPOLLHUP;
347 if (sk->sk_type == SOCK_STREAM && sk->sk_state == TCP_CLOSE)
348 revents |= EPOLLHUP;
349
350 if (sk->sk_shutdown & RCV_SHUTDOWN)
351 revents |= EPOLLRDHUP | EPOLLIN | EPOLLRDNORM;
352 if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
353 revents |= EPOLLIN | EPOLLRDNORM;
354 if (sk_is_readable(sk))
355 revents |= EPOLLIN | EPOLLRDNORM;
356
357 return revents;
358 }
359
360 /**
361 * tlsh_listen - move a PF_TLSH socket into a listening state
362 * @sock: socket to transition to listening state
363 * @backlog: size of backlog queue
364 *
365 * Return values:
366 * %0: @sock is now in a listening state
367 * %-EPERM: caller is not privileged
368 * %-EINVAL: invalid parameters
369 */
370 static int tlsh_listen(struct socket *sock, int backlog)
371 {
372 struct sock *sk = sock->sk;
373 unsigned char old_state;
374 int rc;
375
376 if (!capable(CAP_NET_BIND_SERVICE))
377 return -EPERM;
378
379 lock_sock(sk);
380
381 rc = -EINVAL;
382 if (sock->state != SS_UNCONNECTED || sock->type != SOCK_STREAM)
383 goto out;
384 old_state = sk->sk_state;
385 if (!((1 << old_state) & (TCPF_CLOSE | TCPF_LISTEN)))
386 goto out;
387
388 sk->sk_max_ack_backlog = backlog;
389 sk->sk_state = TCP_LISTEN;
390 tlsh_register_listener(sk);
391
392 rc = 0;
393
394 out:
395 release_sock(sk);
396 return rc;
397 }
398
399 /**
400 * tlsh_setsockopt - Set a socket option
401 * @sock: socket to act upon
402 * @level: which network layer to act upon
403 * @optname: which option to set
404 * @optval: new value to set
405 * @optlen: the size of the new value, in bytes
406 *
407 * Return values:
408 * %0: Success
409 */
410 static int tlsh_setsockopt(struct socket *sock, int level, int optname,
411 sockptr_t optval, unsigned int optlen)
412 {
413 struct sock *sk = sock->sk;
414
415 switch (sk->sk_family) {
416 case AF_INET:
417 #if IS_ENABLED(CONFIG_IPV6)
418 case AF_INET6:
419 #endif
420 return sock_common_setsockopt(sock, level,
421 optname, optval, optlen);
422 default:
423 return -EINVAL;
424 }
425 }
426
427 /**
428 * tlsh_getsockopt - Retrieve a socket option
429 * @sock: socket to act upon
430 * @level: which network layer to act upon
431 * @optname: which option to retrieve
432 * @optval: a buffer into which to receive the option's value
433 * @optlen: the size of the receive buffer, in bytes
434 *
435 * Return values:
436 * %0: Success
437 */
438 static int tlsh_getsockopt(struct socket *sock, int level, int optname,
439 char __user *optval, int __user *optlen)
440 {
441 struct sock *sk = sock->sk;
442
443 switch (sk->sk_family) {
444 case AF_INET:
445 #if IS_ENABLED(CONFIG_IPV6)
446 case AF_INET6:
447 #endif
448 return sock_common_getsockopt(sock, level,
449 optname, optval, optlen);
450 default:
451 return -EINVAL;
452 }
453 }
454
455 /**
456 * tlsh_sendmsg - Send a message on a socket
457 * @sock: socket to send on
458 * @msg: message to send
459 * @size: size of message, in bytes
460 *
461 * Return values:
462 * %0: Success
463 * %-EOPNOTSUPP: Address family does not support this operation
464 */
465 static int tlsh_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
466 {
467 struct sock *sk = sock->sk;
468
469 trace_printk("sk=%p family=%u\n", sk, sk->sk_family);
470
471 switch (sk->sk_family) {
472 case AF_INET:
473 return inet_sendmsg(sock, msg, size);
474 #if IS_ENABLED(CONFIG_IPV6)
475 case AF_INET6:
> 476 return inet6_sendmsg(sock, msg, size);
477 #endif
478 default:
479 return -EOPNOTSUPP;
480 }
481 }
482
483 /**
484 * tlsh_recvmsg - Receive a message from a socket
485 * @sock: socket to receive from
486 * @msg: buffer into which to receive
487 * @size: size of buffer, in bytes
488 * @flags: control settings
489 *
490 * Return values:
491 * %0: Success
492 * %-EOPNOTSUPP: Address family does not support this operation
493 */
494 static int tlsh_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
495 int flags)
496 {
497 struct sock *sk = sock->sk;
498
499 trace_printk("sk=%p family=%u\n", sk, sk->sk_family);
500
501 switch (sk->sk_family) {
502 case AF_INET:
503 return inet_recvmsg(sock, msg, size, flags);
504 #if IS_ENABLED(CONFIG_IPV6)
505 case AF_INET6:
> 506 return inet6_recvmsg(sock, msg, size, flags);
507 #endif
508 default:
509 return -EOPNOTSUPP;
510 }
511 }
512
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
8 months, 1 week