Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8d4d9c7

Browse files
Colin Ian KingPeter Zijlstra
Colin Ian King
authored and
Peter Zijlstra
committed
sched/debug: Fix memory corruption caused by multiple small reads of flags
Reading /proc/sys/kernel/sched_domain/cpu*/domain0/flags mutliple timeswith small reads causes oopses with slub corruption issues because the kfree isfree'ing an offset from a previous allocation. Fix this by adding in a newpointer 'buf' for the allocation and kfree and use the temporary pointer tmpto handle memory copies of the buf offsets.Fixes:5b9f8ff ("sched/debug: Output SD flag names rather than their values")Reported-by: Jeff Bastian <jbastian@redhat.com>Signed-off-by: Colin Ian King <colin.king@canonical.com>Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>Reviewed-by: Valentin Schneider <valentin.schneider@arm.com>Link:https://lkml.kernel.org/r/20201029151103.373410-1-colin.king@canonical.com
1 parentb4c9c9f commit8d4d9c7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

‎kernel/sched/debug.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ static int sd_ctl_doflags(struct ctl_table *table, int write,
251251
unsigned longflags=*(unsigned long*)table->data;
252252
size_tdata_size=0;
253253
size_tlen=0;
254-
char*tmp;
254+
char*tmp,*buf;
255255
intidx;
256256

257257
if (write)
@@ -269,17 +269,17 @@ static int sd_ctl_doflags(struct ctl_table *table, int write,
269269
return0;
270270
}
271271

272-
tmp=kcalloc(data_size+1,sizeof(*tmp),GFP_KERNEL);
273-
if (!tmp)
272+
buf=kcalloc(data_size+1,sizeof(*buf),GFP_KERNEL);
273+
if (!buf)
274274
return-ENOMEM;
275275

276276
for_each_set_bit(idx,&flags,__SD_FLAG_CNT) {
277277
char*name=sd_flag_debug[idx].name;
278278

279-
len+=snprintf(tmp+len,strlen(name)+2,"%s ",name);
279+
len+=snprintf(buf+len,strlen(name)+2,"%s ",name);
280280
}
281281

282-
tmp+=*ppos;
282+
tmp=buf+*ppos;
283283
len-=*ppos;
284284

285285
if (len>*lenp)
@@ -294,7 +294,7 @@ static int sd_ctl_doflags(struct ctl_table *table, int write,
294294
*lenp=len;
295295
*ppos+=len;
296296

297-
kfree(tmp);
297+
kfree(buf);
298298

299299
return0;
300300
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp