* [PATCH net-next] ppp: clarify parsing of user supplied data in ppp_set_compress()
@ 2016-02-23 12:59 Guillaume Nault
2016-02-25 4:53 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Guillaume Nault @ 2016-02-23 12:59 UTC (permalink / raw)
To: netdev; +Cc: Paul Mackerras, David Miller
* Split big conditional statement.
* Check (data.length <= CCP_MAX_OPTION_LENGTH) only once.
* Don't read ccp_option[1] if not initialised.
Reading uninitialised ccp_option[1] was harmless, because this could
only happen when data.length was 0 or 1. So even then, we couldn't pass
the (ccp_option[1] < 2 || ccp_option[1] > data.length) test anyway.
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
---
drivers/net/ppp/ppp_generic.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index fc8ad00..04f4eb3 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -2429,13 +2429,15 @@ ppp_set_compress(struct ppp *ppp, unsigned long arg)
unsigned char ccp_option[CCP_MAX_OPTION_LENGTH];
err = -EFAULT;
- if (copy_from_user(&data, (void __user *) arg, sizeof(data)) ||
- (data.length <= CCP_MAX_OPTION_LENGTH &&
- copy_from_user(ccp_option, (void __user *) data.ptr, data.length)))
+ if (copy_from_user(&data, (void __user *) arg, sizeof(data)))
goto out;
+ if (data.length > CCP_MAX_OPTION_LENGTH)
+ goto out;
+ if (copy_from_user(ccp_option, (void __user *) data.ptr, data.length))
+ goto out;
+
err = -EINVAL;
- if (data.length > CCP_MAX_OPTION_LENGTH ||
- ccp_option[1] < 2 || ccp_option[1] > data.length)
+ if (data.length < 2 || ccp_option[1] < 2 || ccp_option[1] > data.length)
goto out;
cp = try_then_request_module(
--
2.7.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] ppp: clarify parsing of user supplied data in ppp_set_compress()
2016-02-23 12:59 [PATCH net-next] ppp: clarify parsing of user supplied data in ppp_set_compress() Guillaume Nault
@ 2016-02-25 4:53 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-02-25 4:53 UTC (permalink / raw)
To: g.nault; +Cc: netdev, paulus
From: Guillaume Nault <g.nault@alphalink.fr>
Date: Tue, 23 Feb 2016 13:59:43 +0100
> * Split big conditional statement.
> * Check (data.length <= CCP_MAX_OPTION_LENGTH) only once.
> * Don't read ccp_option[1] if not initialised.
>
> Reading uninitialised ccp_option[1] was harmless, because this could
> only happen when data.length was 0 or 1. So even then, we couldn't pass
> the (ccp_option[1] < 2 || ccp_option[1] > data.length) test anyway.
>
> Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-02-25 4:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-23 12:59 [PATCH net-next] ppp: clarify parsing of user supplied data in ppp_set_compress() Guillaume Nault
2016-02-25 4:53 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).