Deleted Added
full compact
linux_misc.c (69539) linux_misc.c (70061)
1/*-
2 * Copyright (c) 1994-1995 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
1/*-
2 * Copyright (c) 1994-1995 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $FreeBSD: head/sys/compat/linux/linux_misc.c 69539 2000-12-03 01:30:31Z marcel $
28 * $FreeBSD: head/sys/compat/linux/linux_misc.c 70061 2000-12-15 19:41:27Z jhb $
29 */
30
31#include "opt_compat.h"
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/sysproto.h>
36#include <sys/kernel.h>

--- 143 unchanged lines hidden (view full) ---

180
181int
182linux_uselib(struct proc *p, struct linux_uselib_args *args)
183{
184 struct nameidata ni;
185 struct vnode *vp;
186 struct exec *a_out;
187 struct vattr attr;
29 */
30
31#include "opt_compat.h"
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/sysproto.h>
36#include <sys/kernel.h>

--- 143 unchanged lines hidden (view full) ---

180
181int
182linux_uselib(struct proc *p, struct linux_uselib_args *args)
183{
184 struct nameidata ni;
185 struct vnode *vp;
186 struct exec *a_out;
187 struct vattr attr;
188 struct ucred *uc;
188 vm_offset_t vmaddr;
189 unsigned long file_offset;
190 vm_offset_t buffer;
191 unsigned long bss_size;
192 int error;
193 caddr_t sg;
194 int locked;
195

--- 35 unchanged lines hidden (view full) ---

231 if (vp->v_writecount) {
232 error = ETXTBSY;
233 goto cleanup;
234 }
235
236 /*
237 * Executable?
238 */
189 vm_offset_t vmaddr;
190 unsigned long file_offset;
191 vm_offset_t buffer;
192 unsigned long bss_size;
193 int error;
194 caddr_t sg;
195 int locked;
196

--- 35 unchanged lines hidden (view full) ---

232 if (vp->v_writecount) {
233 error = ETXTBSY;
234 goto cleanup;
235 }
236
237 /*
238 * Executable?
239 */
239 error = VOP_GETATTR(vp, &attr, p->p_ucred, p);
240 if (error)
240 PROC_LOCK(p);
241 uc = p->p_ucred;
242 crhold(uc);
243 PROC_UNLOCK(p);
244 error = VOP_GETATTR(vp, &attr, uc, p);
245 if (error) {
246 crfree(uc);
241 goto cleanup;
247 goto cleanup;
248 }
242
243 if ((vp->v_mount->mnt_flag & MNT_NOEXEC) ||
244 ((attr.va_mode & 0111) == 0) ||
245 (attr.va_type != VREG)) {
246 error = ENOEXEC;
249
250 if ((vp->v_mount->mnt_flag & MNT_NOEXEC) ||
251 ((attr.va_mode & 0111) == 0) ||
252 (attr.va_type != VREG)) {
253 error = ENOEXEC;
254 crfree(uc);
247 goto cleanup;
248 }
249
250 /*
251 * Sensible size?
252 */
253 if (attr.va_size == 0) {
254 error = ENOEXEC;
255 goto cleanup;
256 }
257
258 /*
259 * Sensible size?
260 */
261 if (attr.va_size == 0) {
262 error = ENOEXEC;
263 crfree(uc);
255 goto cleanup;
256 }
257
258 /*
259 * Can we access it?
260 */
264 goto cleanup;
265 }
266
267 /*
268 * Can we access it?
269 */
261 error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
262 if (error)
270 error = VOP_ACCESS(vp, VEXEC, uc, p);
271 if (error) {
272 crfree(uc);
263 goto cleanup;
273 goto cleanup;
274 }
264
275
265 error = VOP_OPEN(vp, FREAD, p->p_ucred, p);
276 error = VOP_OPEN(vp, FREAD, uc, p);
277 crfree(uc);
266 if (error)
267 goto cleanup;
268
269 /*
270 * Lock no longer needed
271 */
272 VOP_UNLOCK(vp, 0, p);
273 locked = 0;

--- 42 unchanged lines hidden (view full) ---

316 }
317
318 /* text + data can't exceed file size */
319 if (a_out->a_data + a_out->a_text > attr.va_size) {
320 error = EFAULT;
321 goto cleanup;
322 }
323
278 if (error)
279 goto cleanup;
280
281 /*
282 * Lock no longer needed
283 */
284 VOP_UNLOCK(vp, 0, p);
285 locked = 0;

--- 42 unchanged lines hidden (view full) ---

328 }
329
330 /* text + data can't exceed file size */
331 if (a_out->a_data + a_out->a_text > attr.va_size) {
332 error = EFAULT;
333 goto cleanup;
334 }
335
336 /* To protect p->p_rlimit in the if condition. */
337 mtx_assert(&Giant, MA_OWNED);
338
324 /*
325 * text/data/bss must not exceed limits
326 * XXX: this is not complete. it should check current usage PLUS
327 * the resources needed by this library.
328 */
329 if (a_out->a_text > MAXTSIZ ||
330 a_out->a_data + bss_size > p->p_rlimit[RLIMIT_DATA].rlim_cur) {
331 error = ENOMEM;

--- 811 unchanged lines hidden ---
339 /*
340 * text/data/bss must not exceed limits
341 * XXX: this is not complete. it should check current usage PLUS
342 * the resources needed by this library.
343 */
344 if (a_out->a_text > MAXTSIZ ||
345 a_out->a_data + bss_size > p->p_rlimit[RLIMIT_DATA].rlim_cur) {
346 error = ENOMEM;

--- 811 unchanged lines hidden ---