Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 54568
b: refs/heads/master
c: 4fc75ff
h: refs/heads/master
v: v3
  • Loading branch information
Nick Piggin authored and Linus Torvalds committed May 8, 2007
1 parent e4778cf commit f552414
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: af7c693f146069a1f44739acef9abf1bc27f7247
refs/heads/master: 4fc75ff4816c3483b4b772b2f6cb3d8fd88ca547
50 changes: 34 additions & 16 deletions trunk/fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -982,33 +982,51 @@ void compute_creds(struct linux_binprm *bprm)
task_unlock(current);
security_bprm_post_apply_creds(bprm);
}

EXPORT_SYMBOL(compute_creds);

/*
* Arguments are '\0' separated strings found at the location bprm->p
* points to; chop off the first by relocating brpm->p to right after
* the first '\0' encountered.
*/
void remove_arg_zero(struct linux_binprm *bprm)
{
if (bprm->argc) {
unsigned long offset;
char * kaddr;
struct page *page;
char ch;

offset = bprm->p % PAGE_SIZE;
goto inside;
do {
unsigned long offset;
unsigned long index;
char *kaddr;
struct page *page;

while (bprm->p++, *(kaddr+offset++)) {
if (offset != PAGE_SIZE)
continue;
offset = 0;
kunmap_atomic(kaddr, KM_USER0);
inside:
page = bprm->page[bprm->p/PAGE_SIZE];
offset = bprm->p & ~PAGE_MASK;
index = bprm->p >> PAGE_SHIFT;

page = bprm->page[index];
kaddr = kmap_atomic(page, KM_USER0);
}
kunmap_atomic(kaddr, KM_USER0);

/* run through page until we reach end or find NUL */
do {
ch = *(kaddr + offset);

/* discard that character... */
bprm->p++;
offset++;
} while (offset < PAGE_SIZE && ch != '\0');

kunmap_atomic(kaddr, KM_USER0);

/* free the old page */
if (offset == PAGE_SIZE) {
__free_page(page);
bprm->page[index] = NULL;
}
} while (ch != '\0');

bprm->argc--;
}
}

EXPORT_SYMBOL(remove_arg_zero);

/*
Expand Down

0 comments on commit f552414

Please sign in to comment.