1
2
3
4
5
6
7
8
9#include <linux/kernel.h>
10#include <linux/slab.h>
11#include <linux/mm_types.h>
12#include <linux/syscalls.h>
13#include <linux/sched/sysctl.h>
14
15#include <asm/insn.h>
16#include <asm/mman.h>
17#include <asm/mmu_context.h>
18#include <asm/mpx.h>
19#include <asm/processor.h>
20#include <asm/fpu/internal.h>
21
22#define CREATE_TRACE_POINTS
23#include <asm/trace/mpx.h>
24
25static inline unsigned long mpx_bd_size_bytes(struct mm_struct *mm)
26{
27 if (is_64bit_mm(mm))
28 return MPX_BD_SIZE_BYTES_64;
29 else
30 return MPX_BD_SIZE_BYTES_32;
31}
32
33static inline unsigned long mpx_bt_size_bytes(struct mm_struct *mm)
34{
35 if (is_64bit_mm(mm))
36 return MPX_BT_SIZE_BYTES_64;
37 else
38 return MPX_BT_SIZE_BYTES_32;
39}
40
41
42
43
44
45static unsigned long mpx_mmap(unsigned long len)
46{
47 struct mm_struct *mm = current->mm;
48 unsigned long addr, populate;
49
50
51 if (len != mpx_bt_size_bytes(mm))
52 return -EINVAL;
53
54 down_write(&mm->mmap_sem);
55 addr = do_mmap(NULL, 0, len, PROT_READ | PROT_WRITE,
56 MAP_ANONYMOUS | MAP_PRIVATE, VM_MPX, 0, &populate, NULL);
57 up_write(&mm->mmap_sem);
58 if (populate)
59 mm_populate(addr, populate);
60
61 return addr;
62}
63
64enum reg_type {
65 REG_TYPE_RM = 0,
66 REG_TYPE_INDEX,
67 REG_TYPE_BASE,
68};
69
70static int get_reg_offset(struct insn *insn, struct pt_regs *regs,
71 enum reg_type type)
72{
73 int regno = 0;
74
75 static const int regoff[] = {
76 offsetof(struct pt_regs, ax),
77 offsetof(struct pt_regs, cx),
78 offsetof(struct pt_regs, dx),
79 offsetof(struct pt_regs, bx),
80 offsetof(struct pt_regs, sp),
81 offsetof(struct pt_regs, bp),
82 offsetof(struct pt_regs, si),
83 offsetof(struct pt_regs, di),
84#ifdef CONFIG_X86_64
85 offsetof(struct pt_regs, r8),
86 offsetof(struct pt_regs, r9),
87 offsetof(struct pt_regs, r10),
88 offsetof(struct pt_regs, r11),
89 offsetof(struct pt_regs, r12),
90 offsetof(struct pt_regs, r13),
91 offsetof(struct pt_regs, r14),
92 offsetof(struct pt_regs, r15),
93#endif
94 };
95 int nr_registers = ARRAY_SIZE(regoff);
96
97
98
99
100 if (IS_ENABLED(CONFIG_X86_64) && !insn->x86_64)
101 nr_registers -= 8;
102
103 switch (type) {
104 case REG_TYPE_RM:
105 regno = X86_MODRM_RM(insn->modrm.value);
106 if (X86_REX_B(insn->rex_prefix.value))
107 regno += 8;
108 break;
109
110 case REG_TYPE_INDEX:
111 regno = X86_SIB_INDEX(insn->sib.value);
112 if (X86_REX_X(insn->rex_prefix.value))
113 regno += 8;
114 break;
115
116 case REG_TYPE_BASE:
117 regno = X86_SIB_BASE(insn->sib.value);
118 if (X86_REX_B(insn->rex_prefix.value))
119 regno += 8;
120 break;
121
122 default:
123 pr_err("invalid register type");
124 BUG();
125 break;
126 }
127
128 if (regno >= nr_registers) {
129 WARN_ONCE(1, "decoded an instruction with an invalid register");
130 return -EINVAL;
131 }
132 return regoff[regno];
133}
134
135
136
137
138
139
140static void __user *mpx_get_addr_ref(struct insn *insn, struct pt_regs *regs)
141{
142 unsigned long addr, base, indx;
143 int addr_offset, base_offset, indx_offset;
144 insn_byte_t sib;
145
146 insn_get_modrm(insn);
147 insn_get_sib(insn);
148 sib = insn->sib.value;
149
150 if (X86_MODRM_MOD(insn->modrm.value) == 3) {
151 addr_offset = get_reg_offset(insn, regs, REG_TYPE_RM);
152 if (addr_offset < 0)
153 goto out_err;
154 addr = regs_get_register(regs, addr_offset);
155 } else {
156 if (insn->sib.nbytes) {
157 base_offset = get_reg_offset(insn, regs, REG_TYPE_BASE);
158 if (base_offset < 0)
159 goto out_err;
160
161 indx_offset = get_reg_offset(insn, regs, REG_TYPE_INDEX);
162 if (indx_offset < 0)
163 goto out_err;
164
165 base = regs_get_register(regs, base_offset);
166 indx = regs_get_register(regs, indx_offset);
167 addr = base + indx * (1 << X86_SIB_SCALE(sib));
168 } else {
169 addr_offset = get_reg_offset(insn, regs, REG_TYPE_RM);
170 if (addr_offset < 0)
171 goto out_err;
172 addr = regs_get_register(regs, addr_offset);
173 }
174 addr += insn->displacement.value;
175 }
176 return (void __user *)addr;
177out_err:
178 return (void __user *)-1;
179}
180
181static int mpx_insn_decode(struct insn *insn,
182 struct pt_regs *regs)
183{
184 unsigned char buf[MAX_INSN_SIZE];
185 int x86_64 = !test_thread_flag(TIF_IA32);
186 int not_copied;
187 int nr_copied;
188
189 not_copied = copy_from_user(buf, (void __user *)regs->ip, sizeof(buf));
190 nr_copied = sizeof(buf) - not_copied;
191
192
193
194
195
196 if (!nr_copied)
197 return -EFAULT;
198 insn_init(insn, buf, nr_copied, x86_64);
199 insn_get_length(insn);
200
201
202
203
204
205
206
207
208 if (nr_copied < insn->length)
209 return -EFAULT;
210
211 insn_get_opcode(insn);
212
213
214
215
216 if (insn->opcode.bytes[0] != 0x0f)
217 goto bad_opcode;
218 if ((insn->opcode.bytes[1] != 0x1a) &&
219 (insn->opcode.bytes[1] != 0x1b))
220 goto bad_opcode;
221
222 return 0;
223bad_opcode:
224 return -EINVAL;
225}
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240siginfo_t *mpx_generate_siginfo(struct pt_regs *regs)
241{
242 const struct mpx_bndreg_state *bndregs;
243 const struct mpx_bndreg *bndreg;
244 siginfo_t *info = NULL;
245 struct insn insn;
246 uint8_t bndregno;
247 int err;
248
249 err = mpx_insn_decode(&insn, regs);
250 if (err)
251 goto err_out;
252
253
254
255
256
257 insn_get_modrm(&insn);
258 bndregno = X86_MODRM_REG(insn.modrm.value);
259 if (bndregno > 3) {
260 err = -EINVAL;
261 goto err_out;
262 }
263
264 bndregs = get_xsave_field_ptr(XFEATURE_MASK_BNDREGS);
265 if (!bndregs) {
266 err = -EINVAL;
267 goto err_out;
268 }
269
270 bndreg = &bndregs->bndreg[bndregno];
271
272 info = kzalloc(sizeof(*info), GFP_KERNEL);
273 if (!info) {
274 err = -ENOMEM;
275 goto err_out;
276 }
277
278
279
280
281
282
283
284
285
286
287 info->si_lower = (void __user *)(unsigned long)bndreg->lower_bound;
288 info->si_upper = (void __user *)(unsigned long)~bndreg->upper_bound;
289 info->si_addr_lsb = 0;
290 info->si_signo = SIGSEGV;
291 info->si_errno = 0;
292 info->si_code = SEGV_BNDERR;
293 info->si_addr = mpx_get_addr_ref(&insn, regs);
294
295
296
297
298 if (info->si_addr == (void __user *)-1) {
299 err = -EINVAL;
300 goto err_out;
301 }
302 trace_mpx_bounds_register_exception(info->si_addr, bndreg);
303 return info;
304err_out:
305
306 kfree(info);
307 return ERR_PTR(err);
308}
309
310static __user void *mpx_get_bounds_dir(void)
311{
312 const struct mpx_bndcsr *bndcsr;
313
314 if (!cpu_feature_enabled(X86_FEATURE_MPX))
315 return MPX_INVALID_BOUNDS_DIR;
316
317
318
319
320
321 bndcsr = get_xsave_field_ptr(XFEATURE_MASK_BNDCSR);
322 if (!bndcsr)
323 return MPX_INVALID_BOUNDS_DIR;
324
325
326
327
328
329 if (!(bndcsr->bndcfgu & MPX_BNDCFG_ENABLE_FLAG))
330 return MPX_INVALID_BOUNDS_DIR;
331
332
333
334
335
336 return (void __user *)(unsigned long)
337 (bndcsr->bndcfgu & MPX_BNDCFG_ADDR_MASK);
338}
339
340int mpx_enable_management(void)
341{
342 void __user *bd_base = MPX_INVALID_BOUNDS_DIR;
343 struct mm_struct *mm = current->mm;
344 int ret = 0;
345
346
347
348
349
350
351
352
353
354
355
356
357 bd_base = mpx_get_bounds_dir();
358 down_write(&mm->mmap_sem);
359
360
361 if (find_vma(mm, DEFAULT_MAP_WINDOW)) {
362 pr_warn_once("%s (%d): MPX cannot handle addresses "
363 "above 47-bits. Disabling.",
364 current->comm, current->pid);
365 ret = -ENXIO;
366 goto out;
367 }
368 mm->context.bd_addr = bd_base;
369 if (mm->context.bd_addr == MPX_INVALID_BOUNDS_DIR)
370 ret = -ENXIO;
371out:
372 up_write(&mm->mmap_sem);
373 return ret;
374}
375
376int mpx_disable_management(void)
377{
378 struct mm_struct *mm = current->mm;
379
380 if (!cpu_feature_enabled(X86_FEATURE_MPX))
381 return -ENXIO;
382
383 down_write(&mm->mmap_sem);
384 mm->context.bd_addr = MPX_INVALID_BOUNDS_DIR;
385 up_write(&mm->mmap_sem);
386 return 0;
387}
388
389static int mpx_cmpxchg_bd_entry(struct mm_struct *mm,
390 unsigned long *curval,
391 unsigned long __user *addr,
392 unsigned long old_val, unsigned long new_val)
393{
394 int ret;
395
396
397
398
399
400
401
402 if (is_64bit_mm(mm)) {
403 ret = user_atomic_cmpxchg_inatomic(curval,
404 addr, old_val, new_val);
405 } else {
406 u32 uninitialized_var(curval_32);
407 u32 old_val_32 = old_val;
408 u32 new_val_32 = new_val;
409 u32 __user *addr_32 = (u32 __user *)addr;
410
411 ret = user_atomic_cmpxchg_inatomic(&curval_32,
412 addr_32, old_val_32, new_val_32);
413 *curval = curval_32;
414 }
415 return ret;
416}
417
418
419
420
421
422
423static int allocate_bt(struct mm_struct *mm, long __user *bd_entry)
424{
425 unsigned long expected_old_val = 0;
426 unsigned long actual_old_val = 0;
427 unsigned long bt_addr;
428 unsigned long bd_new_entry;
429 int ret = 0;
430
431
432
433
434
435 bt_addr = mpx_mmap(mpx_bt_size_bytes(mm));
436 if (IS_ERR((void *)bt_addr))
437 return PTR_ERR((void *)bt_addr);
438
439
440
441 bd_new_entry = bt_addr | MPX_BD_ENTRY_VALID_FLAG;
442
443
444
445
446
447
448
449
450
451
452
453
454 ret = mpx_cmpxchg_bd_entry(mm, &actual_old_val, bd_entry,
455 expected_old_val, bd_new_entry);
456 if (ret)
457 goto out_unmap;
458
459
460
461
462
463
464
465
466
467
468
469 if (actual_old_val & MPX_BD_ENTRY_VALID_FLAG) {
470 ret = 0;
471 goto out_unmap;
472 }
473
474
475
476
477
478
479 if (expected_old_val != actual_old_val) {
480 ret = -EINVAL;
481 goto out_unmap;
482 }
483 trace_mpx_new_bounds_table(bt_addr);
484 return 0;
485out_unmap:
486 vm_munmap(bt_addr, mpx_bt_size_bytes(mm));
487 return ret;
488}
489
490
491
492
493
494
495
496
497
498
499
500
501static int do_mpx_bt_fault(void)
502{
503 unsigned long bd_entry, bd_base;
504 const struct mpx_bndcsr *bndcsr;
505 struct mm_struct *mm = current->mm;
506
507 bndcsr = get_xsave_field_ptr(XFEATURE_MASK_BNDCSR);
508 if (!bndcsr)
509 return -EINVAL;
510
511
512
513 bd_base = bndcsr->bndcfgu & MPX_BNDCFG_ADDR_MASK;
514
515
516
517
518 bd_entry = bndcsr->bndstatus & MPX_BNDSTA_ADDR_MASK;
519
520
521
522
523 if ((bd_entry < bd_base) ||
524 (bd_entry >= bd_base + mpx_bd_size_bytes(mm)))
525 return -EINVAL;
526
527 return allocate_bt(mm, (long __user *)bd_entry);
528}
529
530int mpx_handle_bd_fault(void)
531{
532
533
534
535
536 if (!kernel_managing_mpx_tables(current->mm))
537 return -EINVAL;
538
539 return do_mpx_bt_fault();
540}
541
542
543
544
545
546static int mpx_resolve_fault(long __user *addr, int write)
547{
548 long gup_ret;
549 int nr_pages = 1;
550
551 gup_ret = get_user_pages((unsigned long)addr, nr_pages,
552 write ? FOLL_WRITE : 0, NULL, NULL);
553
554
555
556
557
558 if (!gup_ret)
559 return -EFAULT;
560
561 if (gup_ret < 0)
562 return gup_ret;
563
564 return 0;
565}
566
567static unsigned long mpx_bd_entry_to_bt_addr(struct mm_struct *mm,
568 unsigned long bd_entry)
569{
570 unsigned long bt_addr = bd_entry;
571 int align_to_bytes;
572
573
574
575 bt_addr &= ~MPX_BD_ENTRY_VALID_FLAG;
576
577
578
579
580
581
582 if (is_64bit_mm(mm))
583 align_to_bytes = 8;
584 else
585 align_to_bytes = 4;
586 bt_addr &= ~(align_to_bytes-1);
587 return bt_addr;
588}
589
590
591
592
593
594
595static int get_user_bd_entry(struct mm_struct *mm, unsigned long *bd_entry_ret,
596 long __user *bd_entry_ptr)
597{
598 u32 bd_entry_32;
599 int ret;
600
601 if (is_64bit_mm(mm))
602 return get_user(*bd_entry_ret, bd_entry_ptr);
603
604
605
606
607
608 ret = get_user(bd_entry_32, (u32 __user *)bd_entry_ptr);
609 *bd_entry_ret = bd_entry_32;
610 return ret;
611}
612
613
614
615
616
617static int get_bt_addr(struct mm_struct *mm,
618 long __user *bd_entry_ptr,
619 unsigned long *bt_addr_result)
620{
621 int ret;
622 int valid_bit;
623 unsigned long bd_entry;
624 unsigned long bt_addr;
625
626 if (!access_ok(VERIFY_READ, (bd_entry_ptr), sizeof(*bd_entry_ptr)))
627 return -EFAULT;
628
629 while (1) {
630 int need_write = 0;
631
632 pagefault_disable();
633 ret = get_user_bd_entry(mm, &bd_entry, bd_entry_ptr);
634 pagefault_enable();
635 if (!ret)
636 break;
637 if (ret == -EFAULT)
638 ret = mpx_resolve_fault(bd_entry_ptr, need_write);
639
640
641
642
643 if (ret)
644 return ret;
645 }
646
647 valid_bit = bd_entry & MPX_BD_ENTRY_VALID_FLAG;
648 bt_addr = mpx_bd_entry_to_bt_addr(mm, bd_entry);
649
650
651
652
653
654
655
656
657 if (!valid_bit && bt_addr)
658 return -EINVAL;
659
660
661
662
663
664
665 if (!valid_bit)
666 return -ENOENT;
667
668 *bt_addr_result = bt_addr;
669 return 0;
670}
671
672static inline int bt_entry_size_bytes(struct mm_struct *mm)
673{
674 if (is_64bit_mm(mm))
675 return MPX_BT_ENTRY_BYTES_64;
676 else
677 return MPX_BT_ENTRY_BYTES_32;
678}
679
680
681
682
683
684
685static unsigned long mpx_get_bt_entry_offset_bytes(struct mm_struct *mm,
686 unsigned long addr)
687{
688 unsigned long bt_table_nr_entries;
689 unsigned long offset = addr;
690
691 if (is_64bit_mm(mm)) {
692
693 offset >>= 3;
694 bt_table_nr_entries = MPX_BT_NR_ENTRIES_64;
695 } else {
696
697 offset >>= 2;
698 bt_table_nr_entries = MPX_BT_NR_ENTRIES_32;
699 }
700
701
702
703
704
705
706
707
708
709
710 offset &= (bt_table_nr_entries-1);
711
712
713
714
715 offset *= bt_entry_size_bytes(mm);
716 return offset;
717}
718
719
720
721
722
723
724
725
726static inline unsigned long bd_entry_virt_space(struct mm_struct *mm)
727{
728 unsigned long long virt_space;
729 unsigned long long GB = (1ULL << 30);
730
731
732
733
734
735 if (!is_64bit_mm(mm))
736 return (4ULL * GB) / MPX_BD_NR_ENTRIES_32;
737
738
739
740
741
742
743 virt_space = (1ULL << boot_cpu_data.x86_virt_bits);
744 return virt_space / MPX_BD_NR_ENTRIES_64;
745}
746
747
748
749
750
751static noinline int zap_bt_entries_mapping(struct mm_struct *mm,
752 unsigned long bt_addr,
753 unsigned long start_mapping, unsigned long end_mapping)
754{
755 struct vm_area_struct *vma;
756 unsigned long addr, len;
757 unsigned long start;
758 unsigned long end;
759
760
761
762
763
764
765
766 start = bt_addr + mpx_get_bt_entry_offset_bytes(mm, start_mapping);
767 end = bt_addr + mpx_get_bt_entry_offset_bytes(mm, end_mapping - 1);
768
769
770
771
772
773 end += bt_entry_size_bytes(mm);
774
775
776
777
778
779
780 vma = find_vma(mm, start);
781 if (!vma || vma->vm_start > start)
782 return -EINVAL;
783
784
785
786
787
788
789
790 addr = start;
791 while (vma && vma->vm_start < end) {
792
793
794
795
796
797
798 if (!(vma->vm_flags & VM_MPX))
799 return -EINVAL;
800
801 len = min(vma->vm_end, end) - addr;
802 zap_page_range(vma, addr, len);
803 trace_mpx_unmap_zap(addr, addr+len);
804
805 vma = vma->vm_next;
806 addr = vma->vm_start;
807 }
808 return 0;
809}
810
811static unsigned long mpx_get_bd_entry_offset(struct mm_struct *mm,
812 unsigned long addr)
813{
814
815
816
817
818
819
820
821
822
823
824
825 if (is_64bit_mm(mm)) {
826 int bd_entry_size = 8;
827
828
829
830 addr &= ((1UL << boot_cpu_data.x86_virt_bits) - 1);
831 return (addr / bd_entry_virt_space(mm)) * bd_entry_size;
832 } else {
833 int bd_entry_size = 4;
834
835
836
837 return (addr / bd_entry_virt_space(mm)) * bd_entry_size;
838 }
839
840
841
842
843
844
845
846}
847
848static int unmap_entire_bt(struct mm_struct *mm,
849 long __user *bd_entry, unsigned long bt_addr)
850{
851 unsigned long expected_old_val = bt_addr | MPX_BD_ENTRY_VALID_FLAG;
852 unsigned long uninitialized_var(actual_old_val);
853 int ret;
854
855 while (1) {
856 int need_write = 1;
857 unsigned long cleared_bd_entry = 0;
858
859 pagefault_disable();
860 ret = mpx_cmpxchg_bd_entry(mm, &actual_old_val,
861 bd_entry, expected_old_val, cleared_bd_entry);
862 pagefault_enable();
863 if (!ret)
864 break;
865 if (ret == -EFAULT)
866 ret = mpx_resolve_fault(bd_entry, need_write);
867
868
869
870
871 if (ret)
872 return ret;
873 }
874
875
876
877 if (actual_old_val != expected_old_val) {
878
879
880
881
882
883 if (!actual_old_val)
884 return 0;
885
886
887
888
889
890
891
892 return -EINVAL;
893 }
894
895
896
897
898
899 return do_munmap(mm, bt_addr, mpx_bt_size_bytes(mm), NULL);
900}
901
902static int try_unmap_single_bt(struct mm_struct *mm,
903 unsigned long start, unsigned long end)
904{
905 struct vm_area_struct *next;
906 struct vm_area_struct *prev;
907
908
909
910
911 unsigned long bta_start_vaddr = start & ~(bd_entry_virt_space(mm)-1);
912 unsigned long bta_end_vaddr = bta_start_vaddr + bd_entry_virt_space(mm);
913 unsigned long uninitialized_var(bt_addr);
914 void __user *bde_vaddr;
915 int ret;
916
917
918
919
920
921
922 next = find_vma_prev(mm, start, &prev);
923
924
925
926
927
928
929
930
931 while (next && (next->vm_flags & VM_MPX))
932 next = next->vm_next;
933 while (prev && (prev->vm_flags & VM_MPX))
934 prev = prev->vm_prev;
935
936
937
938
939
940
941
942 next = find_vma_prev(mm, start, &prev);
943 if ((!prev || prev->vm_end <= bta_start_vaddr) &&
944 (!next || next->vm_start >= bta_end_vaddr)) {
945
946
947
948
949 start = bta_start_vaddr;
950 end = bta_end_vaddr;
951 }
952
953 bde_vaddr = mm->context.bd_addr + mpx_get_bd_entry_offset(mm, start);
954 ret = get_bt_addr(mm, bde_vaddr, &bt_addr);
955
956
957
958 if (ret == -ENOENT) {
959 ret = 0;
960 return 0;
961 }
962 if (ret)
963 return ret;
964
965
966
967
968
969
970 if ((start == bta_start_vaddr) &&
971 (end == bta_end_vaddr))
972 return unmap_entire_bt(mm, bde_vaddr, bt_addr);
973 return zap_bt_entries_mapping(mm, bt_addr, start, end);
974}
975
976static int mpx_unmap_tables(struct mm_struct *mm,
977 unsigned long start, unsigned long end)
978{
979 unsigned long one_unmap_start;
980 trace_mpx_unmap_search(start, end);
981
982 one_unmap_start = start;
983 while (one_unmap_start < end) {
984 int ret;
985 unsigned long next_unmap_start = ALIGN(one_unmap_start+1,
986 bd_entry_virt_space(mm));
987 unsigned long one_unmap_end = end;
988
989
990
991
992
993 if (one_unmap_end > next_unmap_start)
994 one_unmap_end = next_unmap_start;
995 ret = try_unmap_single_bt(mm, one_unmap_start, one_unmap_end);
996 if (ret)
997 return ret;
998
999 one_unmap_start = next_unmap_start;
1000 }
1001 return 0;
1002}
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012void mpx_notify_unmap(struct mm_struct *mm, struct vm_area_struct *vma,
1013 unsigned long start, unsigned long end)
1014{
1015 int ret;
1016
1017
1018
1019
1020
1021 if (!kernel_managing_mpx_tables(current->mm))
1022 return;
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033 do {
1034 if (vma->vm_flags & VM_MPX)
1035 return;
1036 vma = vma->vm_next;
1037 } while (vma && vma->vm_start < end);
1038
1039 ret = mpx_unmap_tables(mm, start, end);
1040 if (ret)
1041 force_sig(SIGSEGV, current);
1042}
1043
1044
1045unsigned long mpx_unmapped_area_check(unsigned long addr, unsigned long len,
1046 unsigned long flags)
1047{
1048 if (!kernel_managing_mpx_tables(current->mm))
1049 return addr;
1050 if (addr + len <= DEFAULT_MAP_WINDOW)
1051 return addr;
1052 if (flags & MAP_FIXED)
1053 return -ENOMEM;
1054
1055
1056
1057
1058
1059 if (len > DEFAULT_MAP_WINDOW)
1060 return -ENOMEM;
1061
1062
1063 return 0;
1064}
1065