1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2014, Red Hat Inc. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
522 }
523 if (sp() == 0 || (intptr_t(sp()) & (wordSize-1)) != 0) {
524 return false;
525 }
526 if (fp() + interpreter_frame_initial_sp_offset < sp()) {
527 return false;
528 }
529 // These are hacks to keep us out of trouble.
530 // The problem with these is that they mask other problems
531 if (fp() <= sp()) { // this attempts to deal with unsigned comparison above
532 return false;
533 }
534
535 // do some validation of frame elements
536
537 // first the method
538
539 Method* m = *interpreter_frame_method_addr();
540
541 // validate the method we'd find in this potential sender
542 if (!m->is_valid_method()) return false;
543
544 // stack frames shouldn't be much larger than max_stack elements
545 // this test requires the use of unextended_sp which is the sp as seen by
546 // the current frame, and not sp which is the "raw" pc which could point
547 // further because of local variables of the callee method inserted after
548 // method arguments
549 if (fp() - unextended_sp() > 1024 + m->max_stack()*Interpreter::stackElementSize) {
550 return false;
551 }
552
553 // validate bci/bcx
554
555 address bcp = interpreter_frame_bcp();
556 if (m->validate_bci_from_bcp(bcp) < 0) {
557 return false;
558 }
559
560 // validate constantPoolCache*
561 ConstantPoolCache* cp = *interpreter_frame_cache_addr();
562 if (cp == NULL || !cp->is_metaspace_object()) return false;
|
1 /*
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2014, Red Hat Inc. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
522 }
523 if (sp() == 0 || (intptr_t(sp()) & (wordSize-1)) != 0) {
524 return false;
525 }
526 if (fp() + interpreter_frame_initial_sp_offset < sp()) {
527 return false;
528 }
529 // These are hacks to keep us out of trouble.
530 // The problem with these is that they mask other problems
531 if (fp() <= sp()) { // this attempts to deal with unsigned comparison above
532 return false;
533 }
534
535 // do some validation of frame elements
536
537 // first the method
538
539 Method* m = *interpreter_frame_method_addr();
540
541 // validate the method we'd find in this potential sender
542 if (!Method::is_valid_method(m)) return false;
543
544 // stack frames shouldn't be much larger than max_stack elements
545 // this test requires the use of unextended_sp which is the sp as seen by
546 // the current frame, and not sp which is the "raw" pc which could point
547 // further because of local variables of the callee method inserted after
548 // method arguments
549 if (fp() - unextended_sp() > 1024 + m->max_stack()*Interpreter::stackElementSize) {
550 return false;
551 }
552
553 // validate bci/bcx
554
555 address bcp = interpreter_frame_bcp();
556 if (m->validate_bci_from_bcp(bcp) < 0) {
557 return false;
558 }
559
560 // validate constantPoolCache*
561 ConstantPoolCache* cp = *interpreter_frame_cache_addr();
562 if (cp == NULL || !cp->is_metaspace_object()) return false;
|