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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <521574A5.30308@asianux.com>
Date:	Thu, 22 Aug 2013 10:17:09 +0800
From:	Chen Gang <gang.chen@...anux.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
CC:	bsingharora@...il.com,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] kernel/delayacct.c: check NULL for member variable 'delays'
 in all extern functions.

On 08/22/2013 06:10 AM, Andrew Morton wrote:
> On Tue, 20 Aug 2013 10:40:03 +0800 Chen Gang <gang.chen@...anux.com> wrote:
> 
>> The member variable 'delays' may be NULL, so need check NULL before use
>> it for all extern functions, just like __delayacct_tsk_init() and
>> __delayacct_add_tsk() have already done.
> 
> If task.delays is NULL, the kernel will oops.  I don't recall seeing
> such oops reports hence I suspect that you missed some check somewhere.
> 
> For example, delayacct_blkio_start() checks current->delays before
> calling __delayacct_blkio_start(), so why retest current->delays in
> __delayacct_blkio_start()?
> 
> 

Hmm... Can we assume "__*" extern function is treated as "should not be
used by outside" ?

If so, the original implementation have done (check NULL before use it
for all extern functions), just like your valuable example, thanks.


Hmm... and better to remove the useless code in __delayacct_add_tsk(),
which the related wrapper function has done, the diff is below:

------------------------------diff begin--------------------------------

diff --git a/kernel/delayacct.c b/kernel/delayacct.c
index d473988..da8b153 100644
--- a/kernel/delayacct.c
+++ b/kernel/delayacct.c
@@ -108,12 +108,6 @@ int __delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
 	struct timespec ts;
 	cputime_t utime, stime, stimescaled, utimescaled;
 
-	/* Though tsk->delays accessed later, early exit avoids
-	 * unnecessary returning of other data
-	 */
-	if (!tsk->delays)
-		goto done;
-
 	tmp = (s64)d->cpu_run_real_total;
 	task_cputime(tsk, &utime, &stime);
 	cputime_to_timespec(utime + stime, &ts);

------------------------------diff end----------------------------------

If this diff is OK, I will send related patch for it.


Thanks.
-- 
Chen Gang
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ