summaryrefslogtreecommitdiffstats
path: root/apps/s_server.c
AgeCommit message (Expand)Author
2002-02-13ECDSA supportBodo Möller
2001-10-20New functions SSL[_CTX]_set_msg_callback().Bodo Möller
2001-09-12Reduce the header dependencies on engine.h in apps/.Geoff Thorpe
2001-08-03Oops, one SSL_OP_NON_EXPORT_FIRST was left.Lutz Jänicke
2001-07-09Patches from Vern Staats <staatsvr@asc.hpc.mil> to get Kerberos 5 inRichard Levitte
2001-06-23Use apps_shutdown() in all applications, in case someone decides notRichard Levitte
2001-06-18Provide an application-common setup function for engines and use itRichard Levitte
2001-05-09Allow various X509_STORE_CTX properties to beDr. Stephen Henson
2001-03-31avoid buffer overflowBodo Möller
2001-03-30this time *really* fix the /../ check ...Bodo Möller
2001-03-30For -WWW, fix test for ".." directory references (and avoid warning forBodo Möller
2001-03-10For some experiments, it is sometimes nice to serve files with completeRichard Levitte
2001-02-23I missed one.Geoff Thorpe
2001-02-21This adds command-line support to s_server for controlling the generationGeoff Thorpe
2001-02-20Get e_os2.h to get all the system definitions correctly.Richard Levitte
2001-02-20Include opensslconf.h or the like early to make sure system macros getRichard Levitte
2001-02-20honour '-no_tmp_rsa'Bodo Möller
2001-02-20Use new-style system-id macros everywhere possible. I hope I haven'tRichard Levitte
2001-02-19Make all configuration macros available for application by makingRichard Levitte
2001-02-15Add "-rand" option to s_client and s_server.Lutz Jänicke
2001-02-09New Option SSL_OP_CIPHER_SERVER_PREFERENCE allows TLS/SSLv3 server to overrideLutz Jänicke
2000-11-30First tentative impementation of Kerberos 5 cryptos and keys for SSL/TLS. Im...Richard Levitte
2000-11-02Never call load_dh_param(NULL) because this leads to an illegalBodo Möller
2000-10-26Merge the engine branch into the main trunk. All conflicts resolved.Richard Levitte
2000-06-01There have been a number of complaints from a number of sources that namesRichard Levitte
2000-02-21Fix some bugs and document othersBodo Möller
2000-02-11Make gcc 2.95.2 happy again, even under ``-Wall -Wshadow -Wpointer-arith -Wca...Ralf S. Engelschall
2000-02-04Rename SSLeay_add_all_algorithms() et al toDr. Stephen Henson
2000-02-03ispell (and minor modifications)Ulf Möller
2000-02-03Add new -notext option to 'ca', -pubkey option to spkac.Dr. Stephen Henson
2000-01-30Seek out and destroy another evil cast.Ulf Möller
2000-01-23Make s_server, s_client check cipher list return codes.Dr. Stephen Henson
2000-01-16Add missing #ifndefs that caused missing symbols when building libsslUlf Möller
1999-12-02Change the trust and purpose code so it doesn't need initDr. Stephen Henson
1999-11-29Remainder of SSL purpose and trust code: trust and purpose setting inDr. Stephen Henson
1999-10-26Various randomness handling bugfixes and improvements --Bodo Möller
1999-10-04New option -dhparam to s_server to allow the DH parameter file to be setDr. Stephen Henson
1999-09-25Honor BUFSIZZ definition in s_server, don't use tiny 32 byteBodo Möller
1999-09-24Bugfix: avoid opening CAfile when it's NULL.Bodo Möller
1999-09-20Fix to make s_client and s_server work under Windows. A bit of a hack butDr. Stephen Henson
1999-09-03Reinitialize global variables when necessary (for monolith application).Bodo Möller
1999-08-09-crlf option.Bodo Möller
1999-08-08Comments.Bodo Möller
1999-08-07New option "-crlf" to s_client and s_server which tells them to convertBodo Möller
1999-07-28VMS updates.Ulf Möller
1999-07-21Additional user data argument to pem_password_cb function typeBodo Möller
1999-07-12fix memory leak in s3_clnt.cBodo Möller
1999-06-10Avoid warnings.Bodo Möller
1999-06-09"extern" is a C++ reserved word.Ulf Möller
1999-06-07More general definition for S_ISDIR (needed not only for VMS butBodo Möller
ckground-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * arch/sh64/kernel/ptrace.c
 *
 * Copyright (C) 2000, 2001  Paolo Alberelli
 * Copyright (C) 2003  Paul Mundt
 *
 * Started from SH3/4 version:
 *   SuperH version:   Copyright (C) 1999, 2000  Kaz Kojima & Niibe Yutaka
 *
 *   Original x86 implementation:
 *	By Ross Biro 1/23/92
 *	edited by Linus Torvalds
 *
 */

#include <linux/kernel.h>
#include <linux/rwsem.h>
#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/smp.h>
#include <linux/smp_lock.h>
#include <linux/errno.h>
#include <linux/ptrace.h>
#include <linux/user.h>
#include <linux/signal.h>
#include <linux/syscalls.h>

#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/pgtable.h>
#include <asm/system.h>
#include <asm/processor.h>
#include <asm/mmu_context.h>

/* This mask defines the bits of the SR which the user is not allowed to
   change, which are everything except S, Q, M, PR, SZ, FR. */
#define SR_MASK      (0xffff8cfd)

/*
 * does not yet catch signals sent when the child dies.
 * in exit.c or in signal.c.
 */

/*
 * This routine will get a word from the user area in the process kernel stack.
 */
static inline int get_stack_long(struct task_struct *task, int offset)
{
	unsigned char *stack;

	stack = (unsigned char *)(task->thread.uregs);
	stack += offset;
	return (*((int *)stack));
}

static inline unsigned long
get_fpu_long(struct task_struct *task, unsigned long addr)
{
	unsigned long tmp;
	struct pt_regs *regs;
	regs = (struct pt_regs*)((unsigned char *)task + THREAD_SIZE) - 1;

	if (!tsk_used_math(task)) {
		if (addr == offsetof(struct user_fpu_struct, fpscr)) {
			tmp = FPSCR_INIT;
		} else {
			tmp = 0xffffffffUL; /* matches initial value in fpu.c */
		}
		return tmp;
	}

	if (last_task_used_math == task) {
		grab_fpu();
		fpsave(&task->thread.fpu.hard);
		release_fpu();
		last_task_used_math = 0;
		regs->sr |= SR_FD;
	}

	tmp = ((long *)&task->thread.fpu)[addr / sizeof(unsigned long)];
	return tmp;
}

/*
 * This routine will put a word into the user area in the process kernel stack.
 */
static inline int put_stack_long(struct task_struct *task, int offset,
				 unsigned long data)
{
	unsigned char *stack;

	stack = (unsigned char *)(task->thread.uregs);
	stack += offset;
	*(unsigned long *) stack = data;
	return 0;
}

static inline int
put_fpu_long(struct task_struct *task, unsigned long addr, unsigned long data)
{
	struct pt_regs *regs;

	regs = (struct pt_regs*)((unsigned char *)task + THREAD_SIZE) - 1;

	if (!tsk_used_math(task)) {
		fpinit(&task->thread.fpu.hard);
		set_stopped_child_used_math(task);
	} else if (last_task_used_math == task) {
		grab_fpu();
		fpsave(&task->thread.fpu.hard);
		release_fpu();
		last_task_used_math = 0;
		regs->sr |= SR_FD;
	}

	((long *)&task->thread.fpu)[addr / sizeof(unsigned long)] = data;
	return 0;
}


long arch_ptrace(struct task_struct *child, long request, long addr, long data)
{
	int ret;

	switch (request) {
	/* when I and D space are separate, these will need to be fixed. */
	case PTRACE_PEEKTEXT: /* read word at location addr. */
	case PTRACE_PEEKDATA: {
		unsigned long tmp;
		int copied;

		copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 0);
		ret = -EIO;
		if (copied != sizeof(tmp))
			break;
		ret = put_user(tmp,(unsigned long *) data);
		break;
	}

	/* read the word at location addr in the USER area. */
	case PTRACE_PEEKUSR: {
		unsigned long tmp;

		ret = -EIO;
		if ((addr & 3) || addr < 0)
			break;

		if (addr < sizeof(struct pt_regs))
			tmp = get_stack_long(child, addr);
		else if ((addr >= offsetof(struct user, fpu)) &&
			 (addr <  offsetof(struct user, u_fpvalid))) {
			tmp = get_fpu_long(child, addr - offsetof(struct user, fpu));
		} else if (addr == offsetof(struct user, u_fpvalid)) {
			tmp = !!tsk_used_math(child);
		} else {
			break;
		}
		ret = put_user(tmp, (unsigned long *)data);
		break;
	}

	/* when I and D space are separate, this will have to be fixed. */
	case PTRACE_POKETEXT: /* write the word at location addr. */
	case PTRACE_POKEDATA:
		ret = 0;
		if (access_process_vm(child, addr, &data, sizeof(data), 1) == sizeof(data))
			break;
		ret = -EIO;
		break;

	case PTRACE_POKEUSR:
                /* write the word at location addr in the USER area. We must
                   disallow any changes to certain SR bits or u_fpvalid, since
                   this could crash the kernel or result in a security
                   loophole. */
		ret = -EIO;
		if ((addr & 3) || addr < 0)
			break;

		if (addr < sizeof(struct pt_regs)) {
			/* Ignore change of top 32 bits of SR */
			if (addr == offsetof (struct pt_regs, sr)+4)
			{
				ret = 0;
				break;
			}
			/* If lower 32 bits of SR, ignore non-user bits */
			if (addr == offsetof (struct pt_regs, sr))
			{
				long cursr = get_stack_long(child, addr);
				data &= ~(SR_MASK);
				data |= (cursr & SR_MASK);
			}
			ret = put_stack_long(child, addr, data);
		}
		else if ((addr >= offsetof(struct user, fpu)) &&
			 (addr <  offsetof(struct user, u_fpvalid))) {
			ret = put_fpu_long(child, addr - offsetof(struct user, fpu), data);
		}
		break;

	case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
	case PTRACE_CONT: { /* restart after signal. */
		ret = -EIO;
		if (!valid_signal(data))
			break;
		if (request == PTRACE_SYSCALL)
			set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
		else
			clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
		child->exit_code = data;
		wake_up_process(child);
		ret = 0;
		break;
	}

/*
 * make the child exit.  Best I can do is send it a sigkill.
 * perhaps it should be put in the status that it wants to
 * exit.
 */
	case PTRACE_KILL: {
		ret = 0;
		if (child->exit_state == EXIT_ZOMBIE)	/* already dead */
			break;
		child->exit_code = SIGKILL;
		wake_up_process(child);
		break;
	}

	case PTRACE_SINGLESTEP: {  /* set the trap flag. */
		struct pt_regs *regs;

		ret = -EIO;
		if (!valid_signal(data))
			break;
		clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
		if ((child->ptrace & PT_DTRACE) == 0) {
			/* Spurious delayed TF traps may occur */
			child->ptrace |= PT_DTRACE;
		}

		regs = child->thread.uregs;

		regs->sr |= SR_SSTEP;	/* auto-resetting upon exception */

		child->exit_code = data;
		/* give it a chance to run. */
		wake_up_process(child);
		ret = 0;
		break;
	}

	case PTRACE_DETACH: /* detach a process that was attached. */
		ret = ptrace_detach(child, data);
		break;

	default:
		ret = ptrace_request(child, request, addr, data);
		break;
	}
	return ret;
}

asmlinkage int sh64_ptrace(long request, long pid, long addr, long data)
{
	extern void poke_real_address_q(unsigned long long addr, unsigned long long data);
#define WPC_DBRMODE 0x0d104008
	static int