Skip to content

Commit dc02747

Browse files
Matthew WilcoxMatthew Wilcox
authored andcommitted
[PARISC] Fix fs/binfmt_som.c
Fix compilation (missing include of a.out.h) Fix security hole (need to call unshare_files) Signed-off-by: Matthew Wilcox <matthew@wil.cx> Signed-off-by: Kyle McMartin <kyle@parisc-linux.org>
1 parent 8d0b7d1 commit dc02747

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

‎fs/binfmt_som.c‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <linux/personality.h>
3030
#include <linux/init.h>
3131

32+
#include <asm/a.out.h>
3233
#include <asm/uaccess.h>
3334
#include <asm/pgtable.h>
3435

@@ -194,6 +195,7 @@ load_som_binary(struct linux_binprm * bprm, struct pt_regs * regs)
194195
unsigned long som_entry;
195196
struct som_hdr *som_ex;
196197
struct som_exec_auxhdr *hpuxhdr;
198+
struct files_struct *files;
197199

198200
/* Get the exec-header */
199201
som_ex = (struct som_hdr *) bprm->buf;
@@ -208,15 +210,27 @@ load_som_binary(struct linux_binprm * bprm, struct pt_regs * regs)
208210
size = som_ex->aux_header_size;
209211
if (size > SOM_PAGESIZE)
210212
goto out;
211-
hpuxhdr = (struct som_exec_auxhdr *) kmalloc(size, GFP_KERNEL);
213+
hpuxhdr = kmalloc(size, GFP_KERNEL);
212214
if (!hpuxhdr)
213215
goto out;
214216

215217
retval = kernel_read(bprm->file, som_ex->aux_header_location,
216218
(char *) hpuxhdr, size);
219+
if (retval != size) {
220+
if (retval >= 0)
221+
retval = -EIO;
222+
goto out_free;
223+
}
224+
225+
files = current->files; /* Refcounted so ok */
226+
retval = unshare_files();
217227
if (retval < 0)
218228
goto out_free;
219-
#error "Fix security hole before enabling me"
229+
if (files == current->files) {
230+
put_files_struct(files);
231+
files = NULL;
232+
}
233+
220234
retval = get_unused_fd();
221235
if (retval < 0)
222236
goto out_free;

0 commit comments

Comments
 (0)