* Re: [1/3] net: rtlwifi: constify rate_control_ops
From: Kalle Valo @ 2017-08-24 9:57 UTC (permalink / raw)
To: Arvind Yadav
Cc: davem, Larry.Finger, chaoming_li, jon.maloy, ying.xue,
linux-kernel, linux-wireless, netdev
In-Reply-To: <1503482375-19983-2-git-send-email-arvind.yadav.cs@gmail.com>
Arvind Yadav <arvind.yadav.cs@gmail.com> wrote:
> rate_control_ops are not supposed to change at runtime. All functions
> working with rate_control_ops provided by <net/mac80211.h> work with
> const rate_control_ops. So mark the non-const structs as const.
>
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
2 patches applied to wireless-drivers-next.git, thanks.
28b75415ad19 wireless: ipw2200: Replace PCI pool old API
9ea792a48cdd net: rsi: mac80211: constify ieee80211_ops
--
https://patchwork.kernel.org/patch/9917001/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply
* Hello
From: Mr. Mehdi Afrendo @ 2017-08-24 9:57 UTC (permalink / raw)
Greetings dear Friend,
I have a proposal for you, this however is not mandatory nor will I in
any manner compel you to honor against your will, Please read
carefully. I am Mr Mehdi A. Al-Shamali, A former executive director
with Arab Tunisian Bank here in Tunis; I retired 1 year 7 months ago
after putting in 28 years of meticulous service. During my days with
Arab Tunisian Bank, I was the personal account officer and one of the
financial advisers to Zine Al-Abidine Ben Ali the past Tunisian
President in self exile at Saudi Arabia.
During his trying period, he instructed me to move all his investment
in my care which consists of US$115M and 767KG of gold out of the Gulf
States for safe keeping; and that I successfully did by moving US$50
Million to Madrid Spain, US$50 Million to Dubai United Arab Emirate,
US$15 Million to Burkina Faso and the 767KG of gold to Burkina Faso in
West Africa as an anonymous deposits, so that the funds will in no way
be traced to him. He has instructed me to find an investor who would
stand as the anonymous depositor of the fund and gold; and claim it
for further investment.
Consequent upon the above, my proposal is that I would like you as a
foreigner to stand in as the anonymous depositor of this fund and gold
that I have successfully moved outside the country and provide an
account overseas where this said fund will be transferred into. It is
a careful network and my voluntary retirement from the Arab Tunisian
Bank is to ensure a hitch-free operation as all modalities for you to
stand as beneficiary and owner of the deposits has been perfected by
me. Mr. Zine al-Abidine Ben Ali will be offering you 20% of the total
investment if you can be the investor and claim this deposits in Spain
and Burkina Faso as the anonymous depositor.
Now my questions are:-
1. Can you handle this transaction?
2. Can I give you this trust?
Consider this and get back to me as soon as possible so that I can
give you more details regarding this transaction. Finally, it is my
humble request that the information as contained herein be accorded
the necessary attention, urgency as well as the secrecy it deserves.
I expect your urgent response if you can handle this project.
Respectfully yours,
Mr Mehdi A. Al-Shamali.
^ permalink raw reply
* Re: [RESEND,v12,7/8] wireless: ipw2200: Replace PCI pool old API
From: Kalle Valo @ 2017-08-24 9:57 UTC (permalink / raw)
To: Romain Perier
Cc: Stanislav Yakovlev, linux-wireless, netdev, linux-kernel,
Romain Perier
In-Reply-To: <20170823071651.7865-1-romain.perier@collabora.com>
Romain Perier <romain.perier@collabora.com> wrote:
> The PCI pool API is deprecated. This commit replaces the PCI pool old
> API by the appropriate function with the DMA pool API.
>
> Signed-off-by: Romain Perier <romain.perier@collabora.com>
> Reviewed-by: Peter Senna Tschudin <peter.senna@collabora.com>
> Acked-by: Stanislav Yakovlev <stas.yakovlev@gmail.com>
Patch applied to wireless-drivers-next.git, thanks.
28b75415ad19 wireless: ipw2200: Replace PCI pool old API
--
https://patchwork.kernel.org/patch/9916775/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply
* Re: rtlwifi: rtl8821ae: fix spelling mistake: "faill" -> "failed"
From: Kalle Valo @ 2017-08-24 9:56 UTC (permalink / raw)
To: Colin Ian King
Cc: Chaoming Li, Ping-Ke Shih, Joe Perches, yuan linyu,
linux-wireless, netdev, linux-kernel
In-Reply-To: <20170822125904.13292-1-colin.king@canonical.com>
Colin Ian King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Trivial fix to spelling mistake in RT_TRACE message
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Patch applied to wireless-drivers-next.git, thanks.
2cc8918eb987 rtlwifi: rtl8821ae: fix spelling mistake: "faill" -> "failed"
--
https://patchwork.kernel.org/patch/9915123/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply
* Re: [v2] mt7601u: check memory allocation failure
From: Kalle Valo @ 2017-08-24 9:55 UTC (permalink / raw)
To: Christophe Jaillet
Cc: kernel-janitors, kubakici, netdev, linux-wireless, linux-kernel,
linux-mediatek, matthias.bgg, Christophe JAILLET,
linux-arm-kernel
In-Reply-To: <20170821220617.21513-1-christophe.jaillet@wanadoo.fr>
Christophe Jaillet <christophe.jaillet@wanadoo.fr> wrote:
> Check memory allocation failure and return -ENOMEM in such a case, as
> already done a few lines below.
>
> As 'dev->tx_q' can be NULL, we also need to check for that in
> 'mt7601u_free_tx()', and return early.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> Acked-by: Jakub Kicinski <kubakici@wp.pl>
Patch applied to wireless-drivers-next.git, thanks.
b3b2f62c6238 mt7601u: check memory allocation failure
--
https://patchwork.kernel.org/patch/9913855/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply
* Re: [v2] mt7601u: check memory allocation failure
From: Kalle Valo @ 2017-08-24 9:55 UTC (permalink / raw)
To: Christophe Jaillet
Cc: kubakici, matthias.bgg, linux-wireless, netdev, linux-arm-kernel,
linux-mediatek, linux-kernel, kernel-janitors, Christophe JAILLET
In-Reply-To: <20170821220617.21513-1-christophe.jaillet@wanadoo.fr>
Christophe Jaillet <christophe.jaillet@wanadoo.fr> wrote:
> Check memory allocation failure and return -ENOMEM in such a case, as
> already done a few lines below.
>
> As 'dev->tx_q' can be NULL, we also need to check for that in
> 'mt7601u_free_tx()', and return early.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> Acked-by: Jakub Kicinski <kubakici@wp.pl>
Patch applied to wireless-drivers-next.git, thanks.
b3b2f62c6238 mt7601u: check memory allocation failure
--
https://patchwork.kernel.org/patch/9913855/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply
* Re: rtlwifi: btcoex: 23b 1ant: fix duplicated code for different branches
From: Kalle Valo @ 2017-08-24 9:52 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Larry Finger, Chaoming Li, linux-wireless, netdev, linux-kernel,
Gustavo A. R. Silva
In-Reply-To: <20170818002219.GA9475@embeddedgus>
"Gustavo A. R. Silva" <gustavo@embeddedor.com> wrote:
> Refactor code in order to avoid identical code for different branches.
>
> This issue was detected with the help of Coccinelle.
>
> Addresses-Coverity-ID: 1415177
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Patch applied to wireless-drivers-next.git, thanks.
14cc696c0a4a rtlwifi: btcoex: 23b 1ant: fix duplicated code for different branches
--
https://patchwork.kernel.org/patch/9907397/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply
* [iproute PATCH v4 2/6] lib/fs: Fix format string in find_fs_mount()
From: Phil Sutter @ 2017-08-24 9:51 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20170824095150.5469-1-phil@nwl.cc>
A field width of 4096 allows fscanf() to store that amount of characters
into the given buffer, though that doesn't include the terminating NULL
byte. Decrease the value by one to leave space for it.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
lib/fs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/fs.c b/lib/fs.c
index c59ac564581d0..1ff881ecfcd8c 100644
--- a/lib/fs.c
+++ b/lib/fs.c
@@ -45,7 +45,7 @@ static char *find_fs_mount(const char *fs_to_find)
return NULL;
}
- while (fscanf(fp, "%*s %4096s %127s %*s %*d %*d\n",
+ while (fscanf(fp, "%*s %4095s %127s %*s %*d %*d\n",
path, fstype) == 2) {
if (strcmp(fstype, fs_to_find) == 0) {
mnt = strdup(path);
--
2.13.1
^ permalink raw reply related
* [iproute PATCH v4 6/6] lib/ll_map: Choose size of new cache items at run-time
From: Phil Sutter @ 2017-08-24 9:51 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20170824095150.5469-1-phil@nwl.cc>
Instead of having a fixed buffer of 16 bytes for the interface name,
tailor size of new ll_cache entry using the interface name's actual
length. This also makes sure the following call to strcpy() is safe.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
lib/ll_map.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/ll_map.c b/lib/ll_map.c
index 4e4556c9ac80b..70684b02042b6 100644
--- a/lib/ll_map.c
+++ b/lib/ll_map.c
@@ -30,7 +30,7 @@ struct ll_cache {
unsigned flags;
unsigned index;
unsigned short type;
- char name[IFNAMSIZ];
+ char name[];
};
#define IDXMAP_SIZE 1024
@@ -120,7 +120,7 @@ int ll_remember_index(const struct sockaddr_nl *who,
return 0;
}
- im = malloc(sizeof(*im));
+ im = malloc(sizeof(*im) + strlen(ifname) + 1);
if (im == NULL)
return 0;
im->index = ifi->ifi_index;
--
2.13.1
^ permalink raw reply related
* [iproute PATCH v4 3/6] lib/inet_proto: Review inet_proto_{a2n,n2a}()
From: Phil Sutter @ 2017-08-24 9:51 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20170824095150.5469-1-phil@nwl.cc>
The original intent was to make sure strings written by those functions
are NUL-terminated at all times, though it was suggested to get rid of
the 15 char protocol name limit as well which this patch accomplishes.
In addition to that, simplify inet_proto_a2n() a bit: Use the error
checking in get_u8() to find out whether passed 'buf' contains a valid
decimal number instead of checking the first character's value manually.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
lib/inet_proto.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/lib/inet_proto.c b/lib/inet_proto.c
index ceda082b12a2e..53c029039b6d5 100644
--- a/lib/inet_proto.c
+++ b/lib/inet_proto.c
@@ -25,7 +25,7 @@
const char *inet_proto_n2a(int proto, char *buf, int len)
{
- static char ncache[16];
+ static char *ncache;
static int icache = -1;
struct protoent *pe;
@@ -34,9 +34,12 @@ const char *inet_proto_n2a(int proto, char *buf, int len)
pe = getprotobynumber(proto);
if (pe) {
+ if (icache != -1)
+ free(ncache);
icache = proto;
- strncpy(ncache, pe->p_name, 16);
- strncpy(buf, pe->p_name, len);
+ ncache = strdup(pe->p_name);
+ strncpy(buf, pe->p_name, len - 1);
+ buf[len - 1] = '\0';
return buf;
}
snprintf(buf, len, "ipproto-%d", proto);
@@ -45,24 +48,23 @@ const char *inet_proto_n2a(int proto, char *buf, int len)
int inet_proto_a2n(const char *buf)
{
- static char ncache[16];
+ static char *ncache;
static int icache = -1;
struct protoent *pe;
+ __u8 ret;
- if (icache>=0 && strcmp(ncache, buf) == 0)
+ if (icache != -1 && strcmp(ncache, buf) == 0)
return icache;
- if (buf[0] >= '0' && buf[0] <= '9') {
- __u8 ret;
- if (get_u8(&ret, buf, 10))
- return -1;
+ if (!get_u8(&ret, buf, 10))
return ret;
- }
pe = getprotobyname(buf);
if (pe) {
+ if (icache != -1)
+ free(ncache);
icache = pe->p_proto;
- strncpy(ncache, pe->p_name, 16);
+ ncache = strdup(pe->p_name);
return pe->p_proto;
}
return -1;
--
2.13.1
^ permalink raw reply related
* [iproute PATCH v4 4/6] lnstat_util: Simplify alloc_and_open() a bit
From: Phil Sutter @ 2017-08-24 9:51 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20170824095150.5469-1-phil@nwl.cc>
Relying upon callers and using unsafe strcpy() is probably not the best
idea. Aside from that, using snprintf() allows to format the string for
lf->path in one go.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/lnstat_util.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/misc/lnstat_util.c b/misc/lnstat_util.c
index cc54598fe1bef..ec19238c24b94 100644
--- a/misc/lnstat_util.c
+++ b/misc/lnstat_util.c
@@ -180,11 +180,8 @@ static struct lnstat_file *alloc_and_open(const char *path, const char *file)
}
/* initialize */
- /* de->d_name is guaranteed to be <= NAME_MAX */
- strcpy(lf->basename, file);
- strcpy(lf->path, path);
- strcat(lf->path, "/");
- strcat(lf->path, lf->basename);
+ snprintf(lf->basename, sizeof(lf->basename), "%s", file);
+ snprintf(lf->path, sizeof(lf->path), "%s/%s", path, file);
/* initialize to default */
lf->interval.tv_sec = 1;
--
2.13.1
^ permalink raw reply related
* [iproute PATCH v4 5/6] tc/m_xt: Fix for potential string buffer overflows
From: Phil Sutter @ 2017-08-24 9:51 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20170824095150.5469-1-phil@nwl.cc>
- Use strncpy() when writing to target->t->u.user.name and make sure the
final byte remains untouched (xtables_calloc() set it to zero).
- 'tname' length sanitization was completely wrong: If it's length
exceeded the 16 bytes available in 'k', passing a length value of 16
to strncpy() would overwrite the previously NULL'ed 'k[15]'. Also, the
sanitization has to happen if 'tname' is exactly 16 bytes long as
well.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
tc/m_xt.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tc/m_xt.c b/tc/m_xt.c
index ad52d239caf61..9218b14594403 100644
--- a/tc/m_xt.c
+++ b/tc/m_xt.c
@@ -95,7 +95,8 @@ build_st(struct xtables_target *target, struct xt_entry_target *t)
if (t == NULL) {
target->t = xtables_calloc(1, size);
target->t->u.target_size = size;
- strcpy(target->t->u.user.name, target->name);
+ strncpy(target->t->u.user.name, target->name,
+ sizeof(target->t->u.user.name) - 1);
target->t->u.user.revision = target->revision;
if (target->init != NULL)
@@ -277,8 +278,8 @@ static int parse_ipt(struct action_util *a, int *argc_p,
}
fprintf(stdout, " index %d\n", index);
- if (strlen(tname) > 16) {
- size = 16;
+ if (strlen(tname) >= 16) {
+ size = 15;
k[15] = 0;
} else {
size = 1 + strlen(tname);
--
2.13.1
^ permalink raw reply related
* [iproute PATCH v4 0/6] Covscan: Fixes for string termination
From: Phil Sutter @ 2017-08-24 9:51 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
This series collects patches from v1 dealing with code potentially
leaving string buffers unterminated. This does not include situations
where it happens for parsed interface names since an overall solution
was attempted for that and it's state is still unclear due to lack of
feedback from upstream.
Changes since v3:
- Dropped patch 2 since upstream discussion in v3 is not conclusive yet.
Phil Sutter (6):
ipntable: Avoid memory allocation for filter.name
lib/fs: Fix format string in find_fs_mount()
lib/inet_proto: Review inet_proto_{a2n,n2a}()
lnstat_util: Simplify alloc_and_open() a bit
tc/m_xt: Fix for potential string buffer overflows
lib/ll_map: Choose size of new cache items at run-time
ip/ipntable.c | 6 +++---
lib/fs.c | 2 +-
lib/inet_proto.c | 24 +++++++++++++-----------
lib/ll_map.c | 4 ++--
misc/lnstat_util.c | 7 ++-----
tc/m_xt.c | 7 ++++---
6 files changed, 25 insertions(+), 25 deletions(-)
--
2.13.1
^ permalink raw reply
* [iproute PATCH v4 1/6] ipntable: Avoid memory allocation for filter.name
From: Phil Sutter @ 2017-08-24 9:51 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20170824095150.5469-1-phil@nwl.cc>
The original issue was that filter.name might end up unterminated if
user provided string was too long. But in fact it is not necessary to
copy the commandline parameter at all: just make filter.name point to it
instead.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
ip/ipntable.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/ip/ipntable.c b/ip/ipntable.c
index 1837909fa42e7..88236ce0ec1e1 100644
--- a/ip/ipntable.c
+++ b/ip/ipntable.c
@@ -37,7 +37,7 @@ static struct
int family;
int index;
#define NONE_DEV (-1)
- char name[1024];
+ const char *name;
} filter;
static void usage(void) __attribute__((noreturn));
@@ -367,7 +367,7 @@ static int print_ntable(const struct sockaddr_nl *who, struct nlmsghdr *n, void
if (tb[NDTA_NAME]) {
const char *name = rta_getattr_str(tb[NDTA_NAME]);
- if (strlen(filter.name) > 0 && strcmp(filter.name, name))
+ if (filter.name && strcmp(filter.name, name))
return 0;
}
if (tb[NDTA_PARMS]) {
@@ -631,7 +631,7 @@ static int ipntable_show(int argc, char **argv)
} else if (strcmp(*argv, "name") == 0) {
NEXT_ARG();
- strncpy(filter.name, *argv, sizeof(filter.name));
+ filter.name = *argv;
} else
invarg("unknown", *argv);
--
2.13.1
^ permalink raw reply related
* [iproute PATCH v4 1/4] ifstat, nstat: Check fdopen() return value
From: Phil Sutter @ 2017-08-24 9:46 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20170824094634.4093-1-phil@nwl.cc>
Prevent passing NULL FILE pointer to fgets() later.
Fix both tools in a single patch since the code changes are basically
identical.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ifstat.c | 16 +++++++++++-----
misc/nstat.c | 16 +++++++++++-----
2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/misc/ifstat.c b/misc/ifstat.c
index 1be21703bf14c..ac3eff6b870a9 100644
--- a/misc/ifstat.c
+++ b/misc/ifstat.c
@@ -992,12 +992,18 @@ int main(int argc, char *argv[])
&& verify_forging(fd) == 0) {
FILE *sfp = fdopen(fd, "r");
- load_raw_table(sfp);
- if (hist_db && source_mismatch) {
- fprintf(stderr, "ifstat: history is stale, ignoring it.\n");
- hist_db = NULL;
+ if (!sfp) {
+ fprintf(stderr, "ifstat: fdopen failed: %s\n",
+ strerror(errno));
+ close(fd);
+ } else {
+ load_raw_table(sfp);
+ if (hist_db && source_mismatch) {
+ fprintf(stderr, "ifstat: history is stale, ignoring it.\n");
+ hist_db = NULL;
+ }
+ fclose(sfp);
}
- fclose(sfp);
} else {
if (fd >= 0)
close(fd);
diff --git a/misc/nstat.c b/misc/nstat.c
index 1212b1f2c8128..a4dd405d43a93 100644
--- a/misc/nstat.c
+++ b/misc/nstat.c
@@ -706,12 +706,18 @@ int main(int argc, char *argv[])
&& verify_forging(fd) == 0) {
FILE *sfp = fdopen(fd, "r");
- load_good_table(sfp);
- if (hist_db && source_mismatch) {
- fprintf(stderr, "nstat: history is stale, ignoring it.\n");
- hist_db = NULL;
+ if (!sfp) {
+ fprintf(stderr, "nstat: fdopen failed: %s\n",
+ strerror(errno));
+ close(fd);
+ } else {
+ load_good_table(sfp);
+ if (hist_db && source_mismatch) {
+ fprintf(stderr, "nstat: history is stale, ignoring it.\n");
+ hist_db = NULL;
+ }
+ fclose(sfp);
}
- fclose(sfp);
} else {
if (fd >= 0)
close(fd);
--
2.13.1
^ permalink raw reply related
* [iproute PATCH v4 4/4] tipc/bearer: Prevent NULL pointer dereference
From: Phil Sutter @ 2017-08-24 9:46 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20170824094634.4093-1-phil@nwl.cc>
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
Changes since v2:
- Keep assignment and check in separate statements.
---
tipc/bearer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tipc/bearer.c b/tipc/bearer.c
index c3d4491f8f6ef..0d84570150624 100644
--- a/tipc/bearer.c
+++ b/tipc/bearer.c
@@ -439,7 +439,7 @@ static int cmd_bearer_enable(struct nlmsghdr *nlh, const struct cmd *cmd,
return err;
opt = get_opt(opts, "media");
- if (strcmp(opt->val, "udp") == 0) {
+ if (opt && strcmp(opt->val, "udp") == 0) {
err = nl_add_udp_enable_opts(nlh, opts, cmdl);
if (err)
return err;
--
2.13.1
^ permalink raw reply related
* [iproute PATCH v4 3/4] tc/tc_filter: Make sure filter name is not empty
From: Phil Sutter @ 2017-08-24 9:46 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20170824094634.4093-1-phil@nwl.cc>
The later check for 'k[0] != 0' requires a non-empty filter name,
otherwise NULL pointer dereference in 'q' might happen.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
Changes since v2:
- Instead of calling strlen(), just make sure **argv is not 0.
---
tc/tc_filter.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tc/tc_filter.c b/tc/tc_filter.c
index b13fb9185d4fd..cf290ae8e252c 100644
--- a/tc/tc_filter.c
+++ b/tc/tc_filter.c
@@ -412,6 +412,9 @@ static int tc_filter_get(int cmd, unsigned int flags, int argc, char **argv)
usage();
return 0;
} else {
+ if (!**argv)
+ invarg("invalid filter name", *argv);
+
strncpy(k, *argv, sizeof(k)-1);
q = get_filter_kind(k);
--
2.13.1
^ permalink raw reply related
* [PATCH net-next 4/4] net: mvpp2: fallback using h/w and random mac if the dt one isn't valid
From: Antoine Tenart @ 2017-08-24 9:46 UTC (permalink / raw)
To: davem, thomas.petazzoni
Cc: Antoine Tenart, andrew, gregory.clement, nadavh, linux,
linux-kernel, mw, stefanc, netdev
In-Reply-To: <20170824094658.1296-1-antoine.tenart@free-electrons.com>
When using a mac address described in the device tree, a check is made
to see if it is valid. When it's not, no fallback is defined. This
patches tries to get the mac address from h/w (or use a random one if
the h/w one isn't valid) when the dt mac address isn't valid.
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
drivers/net/ethernet/marvell/mvpp2.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index fe8309124a09..b53254ef7cae 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -7465,19 +7465,20 @@ static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv,
if (dt_mac_addr && is_valid_ether_addr(dt_mac_addr)) {
*mac_from = "device tree";
ether_addr_copy(dev->dev_addr, dt_mac_addr);
- } else {
- if (priv->hw_version == MVPP21) {
- mvpp21_get_mac_address(port, hw_mac_addr);
- if (is_valid_ether_addr(hw_mac_addr)) {
- *mac_from = "hardware";
- ether_addr_copy(dev->dev_addr, hw_mac_addr);
- return;
- }
- }
+ return;
+ }
- *mac_from = "random";
- eth_hw_addr_random(dev);
+ if (priv->hw_version == MVPP21) {
+ mvpp21_get_mac_address(port, hw_mac_addr);
+ if (is_valid_ether_addr(hw_mac_addr)) {
+ *mac_from = "hardware";
+ ether_addr_copy(dev->dev_addr, hw_mac_addr);
+ return;
+ }
}
+
+ *mac_from = "random";
+ eth_hw_addr_random(dev);
}
/* Ports initialization */
--
2.13.5
^ permalink raw reply related
* [PATCH net-next 3/4] net: mvpp2: fix use of the random mac address for PPv2.2
From: Antoine Tenart @ 2017-08-24 9:46 UTC (permalink / raw)
To: davem, thomas.petazzoni
Cc: Antoine Tenart, andrew, gregory.clement, nadavh, linux,
linux-kernel, mw, stefanc, netdev
In-Reply-To: <20170824094658.1296-1-antoine.tenart@free-electrons.com>
The MAC retrieval logic is using a variable to store an h/w stored mac
address and checks this mac against invalid ones before using it. But
the mac address is only read from h/w when using PPv2.1. So when using
PPv2.2 it defaults to its init state.
This patches fixes the logic to only check if the h/w mac is valid when
actually retrieving a mac from h/w.
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
drivers/net/ethernet/marvell/mvpp2.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 908e5b148fd7..fe8309124a09 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -7466,15 +7466,17 @@ static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv,
*mac_from = "device tree";
ether_addr_copy(dev->dev_addr, dt_mac_addr);
} else {
- if (priv->hw_version == MVPP21)
+ if (priv->hw_version == MVPP21) {
mvpp21_get_mac_address(port, hw_mac_addr);
- if (is_valid_ether_addr(hw_mac_addr)) {
- *mac_from = "hardware";
- ether_addr_copy(dev->dev_addr, hw_mac_addr);
- } else {
- *mac_from = "random";
- eth_hw_addr_random(dev);
+ if (is_valid_ether_addr(hw_mac_addr)) {
+ *mac_from = "hardware";
+ ether_addr_copy(dev->dev_addr, hw_mac_addr);
+ return;
+ }
}
+
+ *mac_from = "random";
+ eth_hw_addr_random(dev);
}
}
--
2.13.5
^ permalink raw reply related
* [PATCH net-next 2/4] net: mvpp2: move the mac retrieval/copy logic into its own function
From: Antoine Tenart @ 2017-08-24 9:46 UTC (permalink / raw)
To: davem, thomas.petazzoni
Cc: Antoine Tenart, andrew, gregory.clement, nadavh, linux,
linux-kernel, mw, stefanc, netdev
In-Reply-To: <20170824094658.1296-1-antoine.tenart@free-electrons.com>
The MAC retrieval has a quite complicated logic (which is broken). Moves
it to its own function to prepare for patches fixing its logic, so that
reviews are easier.
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
drivers/net/ethernet/marvell/mvpp2.c | 45 +++++++++++++++++++++---------------
1 file changed, 27 insertions(+), 18 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 50a0920d3282..908e5b148fd7 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -7453,6 +7453,31 @@ static bool mvpp2_port_has_tx_irqs(struct mvpp2 *priv,
return true;
}
+static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv,
+ struct device_node *port_node,
+ char **mac_from)
+{
+ struct mvpp2_port *port = netdev_priv(dev);
+ char hw_mac_addr[ETH_ALEN] = {0};
+ const char *dt_mac_addr;
+
+ dt_mac_addr = of_get_mac_address(port_node);
+ if (dt_mac_addr && is_valid_ether_addr(dt_mac_addr)) {
+ *mac_from = "device tree";
+ ether_addr_copy(dev->dev_addr, dt_mac_addr);
+ } else {
+ if (priv->hw_version == MVPP21)
+ mvpp21_get_mac_address(port, hw_mac_addr);
+ if (is_valid_ether_addr(hw_mac_addr)) {
+ *mac_from = "hardware";
+ ether_addr_copy(dev->dev_addr, hw_mac_addr);
+ } else {
+ *mac_from = "random";
+ eth_hw_addr_random(dev);
+ }
+ }
+}
+
/* Ports initialization */
static int mvpp2_port_probe(struct platform_device *pdev,
struct device_node *port_node,
@@ -7464,9 +7489,7 @@ static int mvpp2_port_probe(struct platform_device *pdev,
struct mvpp2_port_pcpu *port_pcpu;
struct net_device *dev;
struct resource *res;
- const char *dt_mac_addr;
- const char *mac_from;
- char hw_mac_addr[ETH_ALEN] = {0};
+ char *mac_from = "";
unsigned int ntxqs, nrxqs;
bool has_tx_irqs;
u32 id;
@@ -7575,21 +7598,7 @@ static int mvpp2_port_probe(struct platform_device *pdev,
goto err_free_irq;
}
- dt_mac_addr = of_get_mac_address(port_node);
- if (dt_mac_addr && is_valid_ether_addr(dt_mac_addr)) {
- mac_from = "device tree";
- ether_addr_copy(dev->dev_addr, dt_mac_addr);
- } else {
- if (priv->hw_version == MVPP21)
- mvpp21_get_mac_address(port, hw_mac_addr);
- if (is_valid_ether_addr(hw_mac_addr)) {
- mac_from = "hardware";
- ether_addr_copy(dev->dev_addr, hw_mac_addr);
- } else {
- mac_from = "random";
- eth_hw_addr_random(dev);
- }
- }
+ mvpp2_port_copy_mac_addr(dev, priv, port_node, &mac_from);
port->tx_ring_size = MVPP2_MAX_TXD;
port->rx_ring_size = MVPP2_MAX_RXD;
--
2.13.5
^ permalink raw reply related
* [PATCH net-next 1/4] net: mvpp2: fix the mac address used when using PPv2.2
From: Antoine Tenart @ 2017-08-24 9:46 UTC (permalink / raw)
To: davem, thomas.petazzoni
Cc: Antoine Tenart, andrew, gregory.clement, nadavh, linux,
linux-kernel, mw, stefanc, netdev
In-Reply-To: <20170824094658.1296-1-antoine.tenart@free-electrons.com>
The mac address is only retrieved from h/w when using PPv2.1. Otherwise
the variable holding it is still checked and used if it contains a valid
value. As the variable isn't initialized to an invalid mac address
value, we end up with random mac addresses which can be the same for all
the ports handled by this PPv2 driver.
Fixes this by initializing the h/w mac address variable to {0}, which is
an invalid mac address value. This way the random assignation fallback
is called and all ports end up with their own addresses.
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Fixes: 2697582144dd ("net: mvpp2: handle misc PPv2.1/PPv2.2 differences")
---
drivers/net/ethernet/marvell/mvpp2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 3f8cbc070dc4..50a0920d3282 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -7466,7 +7466,7 @@ static int mvpp2_port_probe(struct platform_device *pdev,
struct resource *res;
const char *dt_mac_addr;
const char *mac_from;
- char hw_mac_addr[ETH_ALEN];
+ char hw_mac_addr[ETH_ALEN] = {0};
unsigned int ntxqs, nrxqs;
bool has_tx_irqs;
u32 id;
--
2.13.5
^ permalink raw reply related
* [PATCH net-next 0/4] net: mvpp2: fix the mac address retrieval logic
From: Antoine Tenart @ 2017-08-24 9:46 UTC (permalink / raw)
To: davem, thomas.petazzoni
Cc: Antoine Tenart, andrew, gregory.clement, nadavh, linux,
linux-kernel, mw, stefanc, netdev
Hi all,
The MAC address retrieval logic was broken and when using the PPv2
driver on PPv2.2 engines I ended up using the same mac address on all
ports. This series of patches fixes this, and also tackle a possible bug
when defining the mac address in the device tree.
To fix this in a nice way I ended up using a dedicated function to
handle the mac retrieval logic. This can be hard to backport into stable
kernels. This is why I also made a quick fix which is easy to backport
(patch 1/14), to tackle down the PPv2.2 mac retrieval bug. Let me know
if this approach is the proper way to handle this or if I should do
something else.
Thanks!
Antoine
Fixes: 2697582144dd ("net: mvpp2: handle misc PPv2.1/PPv2.2 differences")
Antoine Tenart (4):
net: mvpp2: fix the mac address used when using PPv2.2
net: mvpp2: move the mac retrieval/copy logic into its own function
net: mvpp2: fix use of the random mac address for PPv2.2
net: mvpp2: fallback using h/w and random mac if the dt one isn't
valid
drivers/net/ethernet/marvell/mvpp2.c | 48 ++++++++++++++++++++++--------------
1 file changed, 30 insertions(+), 18 deletions(-)
--
2.13.5
^ permalink raw reply
* [iproute PATCH v4 0/4] Covscan: Fix potential NULL pointer dereferences
From: Phil Sutter @ 2017-08-24 9:46 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
This series collects patches from v1 which eliminate possible cases of
NULL pointer dereferences.
Changes since v3:
- Dropped upstream rejected patch 2.
Phil Sutter (4):
ifstat, nstat: Check fdopen() return value
tc/q_netem: Don't dereference possibly NULL pointer
tc/tc_filter: Make sure filter name is not empty
tipc/bearer: Prevent NULL pointer dereference
misc/ifstat.c | 16 +++++++++++-----
misc/nstat.c | 16 +++++++++++-----
tc/q_netem.c | 3 ++-
tc/tc_filter.c | 3 +++
tipc/bearer.c | 2 +-
5 files changed, 28 insertions(+), 12 deletions(-)
--
2.13.1
^ permalink raw reply
* [iproute PATCH v4 2/4] tc/q_netem: Don't dereference possibly NULL pointer
From: Phil Sutter @ 2017-08-24 9:46 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20170824094634.4093-1-phil@nwl.cc>
Assuming 'opt' might be NULL, move the call to RTA_PAYLOAD to after the
check since it dereferences its parameter.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
Changes since v2:
- Dropped empty line between assignment and check.
---
tc/q_netem.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tc/q_netem.c b/tc/q_netem.c
index 0975ae111de97..5a9e747411e85 100644
--- a/tc/q_netem.c
+++ b/tc/q_netem.c
@@ -538,7 +538,7 @@ static int netem_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
int *ecn = NULL;
struct tc_netem_qopt qopt;
const struct tc_netem_rate *rate = NULL;
- int len = RTA_PAYLOAD(opt) - sizeof(qopt);
+ int len;
__u64 rate64 = 0;
SPRINT_BUF(b1);
@@ -546,6 +546,7 @@ static int netem_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
if (opt == NULL)
return 0;
+ len = RTA_PAYLOAD(opt) - sizeof(qopt);
if (len < 0) {
fprintf(stderr, "options size error\n");
return -1;
--
2.13.1
^ permalink raw reply related
* [iproute PATCH v3 4/6] lib/bpf: Check return value of write()
From: Phil Sutter @ 2017-08-24 9:41 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20170824094131.2963-1-phil@nwl.cc>
This is merely to silence the compiler warning. If write to stderr
failed, assume that printing an error message will fail as well so don't
even try.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
lib/bpf.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/bpf.c b/lib/bpf.c
index 1dcb261dc915f..825e071cea572 100644
--- a/lib/bpf.c
+++ b/lib/bpf.c
@@ -591,7 +591,8 @@ int bpf_trace_pipe(void)
ret = read(fd, buff, sizeof(buff) - 1);
if (ret > 0) {
- write(2, buff, ret);
+ if (write(STDERR_FILENO, buff, ret) != ret)
+ return -1;
fflush(stderr);
}
}
--
2.13.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox