From: Ralf Baechle <ralf@linux-mips.org>
To: "David S. Miller" <davem@davemloft.net>, netdev@vger.kernel.org
Cc: Thomas Osterried <thomas@osterried.de>, linux-hams@vger.kernel.org
Subject: [PATCH] NET: mkiss/6pack: Fix SIOCSIFENCAP ioctl
Date: Sat, 11 Feb 2017 00:01:21 +0100 [thread overview]
Message-ID: <20170210230121.GA27466@linux-mips.org> (raw)
In-Reply-To: <20170209131211.GA16072@linux-mips.org>
When looking at Thomas' mkiss fix 7ba1b6890387 ("NET: mkiss: Fix panic")
I noticed that the mkiss SIOCSIFENCAPS ioctl was also doing a slightly
strange assignment
dev->hard_header_len = AX25_KISS_HEADER_LEN +
AX25_MAX_HEADER_LEN + 3;
AX25_MAX_HEADER_LEN already accounts for the KISS byte so adding
AX25_KISS_HEADER_LEN is a double allocation nor does the "+ 3" seem to
be necessary. So this can be simplified to
dev->hard_header_len = AX25_MAX_HEADER_LEN
which after the preceeding fix is a redundant assignment of what
ax_setup has already assigned so delete the line. The assignments
to dev->addr_len and dev->type are similarly redundant.
The SIOCSIFENCAP argument was never checked for validity. Check that
it is 4 and return -EINVAL if not. The magic constant 4 dates back to
the days when KISS was handled by the SLIP driver where it had the
symbol name SL_MODE_AX25.
Since however mkiss.c only supports a single encapsulation mode there
is no point in storing it in struct mkiss so delete all that.
Note that while useless we can't delete the SIOCSIFENCAP ioctl as
kissattach(8) is still using it and without mkiss issuing a
SIOCSIFENCAP ioctl an older kernel that does not have Thomas' mkiss fix
would still panic on attempt to transmit via mkiss.
6pack was suffering from the same issue except there SIOCGIFENCAP was
return 0 for the encapsulation while the spattach utility was passing 4
for the mode, so the mode check added for 6pack is a bit more lenient
allow the values 0 and 4 to be set. That way we retain the option
to set different encapsulation modes for future extensions.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
drivers/net/hamradio/6pack.c | 10 ++++------
drivers/net/hamradio/mkiss.c | 10 ++++------
2 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 470b3dc..d949b9f 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -104,7 +104,6 @@ struct sixpack {
int buffsize; /* Max buffers sizes */
unsigned long flags; /* Flag values/ mode etc */
- unsigned char mode; /* 6pack mode */
/* 6pack stuff */
unsigned char tx_delay;
@@ -723,11 +722,10 @@ static int sixpack_ioctl(struct tty_struct *tty, struct file *file,
break;
}
- sp->mode = tmp;
- dev->addr_len = AX25_ADDR_LEN;
- dev->hard_header_len = AX25_KISS_HEADER_LEN +
- AX25_MAX_HEADER_LEN + 3;
- dev->type = ARPHRD_AX25;
+ if (tmp != 0 && tmp != 4) {
+ err = -EINVAL;
+ break;
+ }
err = 0;
break;
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index 1dfe230..cdaf819 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -71,7 +71,6 @@ struct mkiss {
#define AXF_KEEPTEST 3 /* Keepalive test flag */
#define AXF_OUTWAIT 4 /* is outpacket was flag */
- int mode;
int crcmode; /* MW: for FlexNet, SMACK etc. */
int crcauto; /* CRC auto mode */
@@ -841,11 +840,10 @@ static int mkiss_ioctl(struct tty_struct *tty, struct file *file,
break;
}
- ax->mode = tmp;
- dev->addr_len = AX25_ADDR_LEN;
- dev->hard_header_len = AX25_KISS_HEADER_LEN +
- AX25_MAX_HEADER_LEN + 3;
- dev->type = ARPHRD_AX25;
+ if (tmp != 4) {
+ err = -EINVAL;
+ break;
+ }
err = 0;
break;
next prev parent reply other threads:[~2017-02-10 23:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-09 9:27 linux mkiss.c panic: fix Thomas Osterried
2017-02-09 13:12 ` [PATCH] NET: mkiss: Fix panic Ralf Baechle
2017-02-10 18:42 ` David Miller
2017-02-10 23:01 ` Ralf Baechle [this message]
2017-02-11 10:53 ` [PATCH] NET: mkiss/6pack: Fix SIOCSIFENCAP ioctl walter harms
2017-02-12 2:30 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170210230121.GA27466@linux-mips.org \
--to=ralf@linux-mips.org \
--cc=davem@davemloft.net \
--cc=linux-hams@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=thomas@osterried.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).