lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <202206180617.UzO7ymnD-lkp@intel.com>
Date:   Sat, 18 Jun 2022 07:04:40 +0800
From:   kernel test robot <lkp@...el.com>
To:     Charan Teja Kalla <quic_charante@...cinc.com>
Cc:     kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        Linux Memory Management List <linux-mm@...ck.org>
Subject: mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to
 itself. [selfAssignment]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   4b35035bcf80ddb47c0112c4fbd84a63a2836a18
commit: 5bd009c7c9a9e888077c07535dc0c70aeab242c3 mm: madvise: return correct bytes advised with process_madvise
date:   3 months ago
compiler: mips-linux-gcc (GCC) 11.3.0
reproduce (cppcheck warning):
        # apt-get install cppcheck
        git checkout 5bd009c7c9a9e888077c07535dc0c70aeab242c3
        cppcheck --quiet --enable=style,performance,portability --template=gcc FILE

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@...el.com>


cppcheck warnings: (new ones prefixed by >>)
>> mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
    ret = (total_len - iov_iter_count(&iter)) ? : ret;
        ^

cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

   mm/madvise.c:123:28: warning: Parameter 'anon_name' can be declared with const [constParameter]
        struct anon_vma_name *anon_name)
                              ^

vim +/ret +1438 mm/madvise.c

  1378	
  1379	SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec,
  1380			size_t, vlen, int, behavior, unsigned int, flags)
  1381	{
  1382		ssize_t ret;
  1383		struct iovec iovstack[UIO_FASTIOV], iovec;
  1384		struct iovec *iov = iovstack;
  1385		struct iov_iter iter;
  1386		struct task_struct *task;
  1387		struct mm_struct *mm;
  1388		size_t total_len;
  1389		unsigned int f_flags;
  1390	
  1391		if (flags != 0) {
  1392			ret = -EINVAL;
  1393			goto out;
  1394		}
  1395	
  1396		ret = import_iovec(READ, vec, vlen, ARRAY_SIZE(iovstack), &iov, &iter);
  1397		if (ret < 0)
  1398			goto out;
  1399	
  1400		task = pidfd_get_task(pidfd, &f_flags);
  1401		if (IS_ERR(task)) {
  1402			ret = PTR_ERR(task);
  1403			goto free_iov;
  1404		}
  1405	
  1406		if (!process_madvise_behavior_valid(behavior)) {
  1407			ret = -EINVAL;
  1408			goto release_task;
  1409		}
  1410	
  1411		/* Require PTRACE_MODE_READ to avoid leaking ASLR metadata. */
  1412		mm = mm_access(task, PTRACE_MODE_READ_FSCREDS);
  1413		if (IS_ERR_OR_NULL(mm)) {
  1414			ret = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
  1415			goto release_task;
  1416		}
  1417	
  1418		/*
  1419		 * Require CAP_SYS_NICE for influencing process performance. Note that
  1420		 * only non-destructive hints are currently supported.
  1421		 */
  1422		if (!capable(CAP_SYS_NICE)) {
  1423			ret = -EPERM;
  1424			goto release_mm;
  1425		}
  1426	
  1427		total_len = iov_iter_count(&iter);
  1428	
  1429		while (iov_iter_count(&iter)) {
  1430			iovec = iov_iter_iovec(&iter);
  1431			ret = do_madvise(mm, (unsigned long)iovec.iov_base,
  1432						iovec.iov_len, behavior);
  1433			if (ret < 0)
  1434				break;
  1435			iov_iter_advance(&iter, iovec.iov_len);
  1436		}
  1437	
> 1438		ret = (total_len - iov_iter_count(&iter)) ? : ret;

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ