netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next-2.6 1/7] caif: Ldisc add permission check and mem-alloc error check
@ 2010-04-28 18:54 sjur.brandeland
  2010-04-28 18:54 ` [PATCH net-next-2.6 2/7] caif: Rename functions in cfcnfg and caif_dev sjur.brandeland
  2010-04-28 20:02 ` [PATCH net-next-2.6 1/7] caif: Ldisc add permission check and mem-alloc error check David Miller
  0 siblings, 2 replies; 14+ messages in thread
From: sjur.brandeland @ 2010-04-28 18:54 UTC (permalink / raw)
  To: netdev, davem
  Cc: marcel, daniel.martensson, sjurbr, linus.walleij,
	Sjur Braendeland

From: Sjur Braendeland <sjur.brandeland@stericsson.com>

Changes:
   o Added permission checks for installing. CAP_SYS_ADMIN and
     CAP_SYS_TTY_CONFIG can install the ldisc.
   o Check if allocation of skb was successful.

Signed-off-by: Sjur Braendeland <sjur.brandeland@stericsson.com>
---
 drivers/net/caif/caif_serial.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c
index 38c0186..09257ca 100644
--- a/drivers/net/caif/caif_serial.c
+++ b/drivers/net/caif/caif_serial.c
@@ -197,7 +197,8 @@ static void ldisc_receive(struct tty_struct *tty, const u8 *data,
 
 	/* Get a suitable caif packet and copy in data. */
 	skb = netdev_alloc_skb(ser->dev, count+1);
-	BUG_ON(skb == NULL);
+	if (skb == NULL)
+		return;
 	p = skb_put(skb, count);
 	memcpy(p, data, count);
 
@@ -315,6 +316,8 @@ static int ldisc_open(struct tty_struct *tty)
 	/* No write no play */
 	if (tty->ops->write == NULL)
 		return -EOPNOTSUPP;
+	if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_TTY_CONFIG))
+		return -EPERM;
 
 	sprintf(name, "cf%s", tty->name);
 	dev = alloc_netdev(sizeof(*ser), name, caifdev_setup);
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2010-04-28 20:03 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-28 18:54 [PATCH net-next-2.6 1/7] caif: Ldisc add permission check and mem-alloc error check sjur.brandeland
2010-04-28 18:54 ` [PATCH net-next-2.6 2/7] caif: Rename functions in cfcnfg and caif_dev sjur.brandeland
2010-04-28 18:54   ` [PATCH net-next-2.6 3/7] caif: Add reference counting to service layer sjur.brandeland
2010-04-28 18:54     ` [PATCH net-next-2.6 4/7] caif: Disconnect without waiting for response sjur.brandeland
2010-04-28 18:54       ` [PATCH net-next-2.6 5/7] caif: Rewritten socket implementation sjur.brandeland
2010-04-28 18:54         ` [PATCH net-next-2.6 6/7] caif: Bugfixes in CAIF netdevice for close and flow control sjur.brandeland
2010-04-28 18:54           ` [PATCH net-next-2.6 7/7] Bugfix: Link selection was swapped in switch sjur.brandeland
2010-04-28 20:03             ` David Miller
2010-04-28 20:03           ` [PATCH net-next-2.6 6/7] caif: Bugfixes in CAIF netdevice for close and flow control David Miller
2010-04-28 20:03         ` [PATCH net-next-2.6 5/7] caif: Rewritten socket implementation David Miller
2010-04-28 20:03       ` [PATCH net-next-2.6 4/7] caif: Disconnect without waiting for response David Miller
2010-04-28 20:03     ` [PATCH net-next-2.6 3/7] caif: Add reference counting to service layer David Miller
2010-04-28 20:03   ` [PATCH net-next-2.6 2/7] caif: Rename functions in cfcnfg and caif_dev David Miller
2010-04-28 20:02 ` [PATCH net-next-2.6 1/7] caif: Ldisc add permission check and mem-alloc error check 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).