sctp: pass a kernel pointer to sctp_setsockopt_event
Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
a42624669e
commit
565059cb9b
|
@ -4252,45 +4252,40 @@ static int sctp_assoc_ulpevent_type_set(struct sctp_event *param,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sctp_setsockopt_event(struct sock *sk, char __user *optval,
|
static int sctp_setsockopt_event(struct sock *sk, struct sctp_event *param,
|
||||||
unsigned int optlen)
|
unsigned int optlen)
|
||||||
{
|
{
|
||||||
struct sctp_sock *sp = sctp_sk(sk);
|
struct sctp_sock *sp = sctp_sk(sk);
|
||||||
struct sctp_association *asoc;
|
struct sctp_association *asoc;
|
||||||
struct sctp_event param;
|
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
|
||||||
if (optlen < sizeof(param))
|
if (optlen < sizeof(*param))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
optlen = sizeof(param);
|
if (param->se_type < SCTP_SN_TYPE_BASE ||
|
||||||
if (copy_from_user(¶m, optval, optlen))
|
param->se_type > SCTP_SN_TYPE_MAX)
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
if (param.se_type < SCTP_SN_TYPE_BASE ||
|
|
||||||
param.se_type > SCTP_SN_TYPE_MAX)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
asoc = sctp_id2assoc(sk, param.se_assoc_id);
|
asoc = sctp_id2assoc(sk, param->se_assoc_id);
|
||||||
if (!asoc && param.se_assoc_id > SCTP_ALL_ASSOC &&
|
if (!asoc && param->se_assoc_id > SCTP_ALL_ASSOC &&
|
||||||
sctp_style(sk, UDP))
|
sctp_style(sk, UDP))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (asoc)
|
if (asoc)
|
||||||
return sctp_assoc_ulpevent_type_set(¶m, asoc);
|
return sctp_assoc_ulpevent_type_set(param, asoc);
|
||||||
|
|
||||||
if (sctp_style(sk, TCP))
|
if (sctp_style(sk, TCP))
|
||||||
param.se_assoc_id = SCTP_FUTURE_ASSOC;
|
param->se_assoc_id = SCTP_FUTURE_ASSOC;
|
||||||
|
|
||||||
if (param.se_assoc_id == SCTP_FUTURE_ASSOC ||
|
if (param->se_assoc_id == SCTP_FUTURE_ASSOC ||
|
||||||
param.se_assoc_id == SCTP_ALL_ASSOC)
|
param->se_assoc_id == SCTP_ALL_ASSOC)
|
||||||
sctp_ulpevent_type_set(&sp->subscribe,
|
sctp_ulpevent_type_set(&sp->subscribe,
|
||||||
param.se_type, param.se_on);
|
param->se_type, param->se_on);
|
||||||
|
|
||||||
if (param.se_assoc_id == SCTP_CURRENT_ASSOC ||
|
if (param->se_assoc_id == SCTP_CURRENT_ASSOC ||
|
||||||
param.se_assoc_id == SCTP_ALL_ASSOC) {
|
param->se_assoc_id == SCTP_ALL_ASSOC) {
|
||||||
list_for_each_entry(asoc, &sp->ep->asocs, asocs) {
|
list_for_each_entry(asoc, &sp->ep->asocs, asocs) {
|
||||||
int ret = sctp_assoc_ulpevent_type_set(¶m, asoc);
|
int ret = sctp_assoc_ulpevent_type_set(param, asoc);
|
||||||
|
|
||||||
if (ret && !retval)
|
if (ret && !retval)
|
||||||
retval = ret;
|
retval = ret;
|
||||||
|
@ -4643,7 +4638,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
|
||||||
retval = sctp_setsockopt_reuse_port(sk, kopt, optlen);
|
retval = sctp_setsockopt_reuse_port(sk, kopt, optlen);
|
||||||
break;
|
break;
|
||||||
case SCTP_EVENT:
|
case SCTP_EVENT:
|
||||||
retval = sctp_setsockopt_event(sk, optval, optlen);
|
retval = sctp_setsockopt_event(sk, kopt, optlen);
|
||||||
break;
|
break;
|
||||||
case SCTP_ASCONF_SUPPORTED:
|
case SCTP_ASCONF_SUPPORTED:
|
||||||
retval = sctp_setsockopt_asconf_supported(sk, optval, optlen);
|
retval = sctp_setsockopt_asconf_supported(sk, optval, optlen);
|
||||||
|
|
Loading…
Reference in New Issue