Re: [OpenWrt-Devel] [PATCH procd 3/4] system: sysupgrade: rework firmware validation

2020-01-04 Thread Hauke Mehrtens
On 1/3/20 1:46 AM, Petr Štetiar wrote:
> Fixes following deficiencies:
> 
>  * unhandled read() errors
>  * everything bundled in one long function, which is hard to follow and
>reason about
>  * JSON parser errors are being ignored, anything else then
>json_tokener_continue is fatal error
>  * JSON parser errors are being output to stderr, thus invisible via SSH
>  * validate_firmware_image_call can fail at a lot of places, but we just
>get one generic "Firmware image couldn't be validated" so it's hard
>to debug
> 
> Cc: Rafał Miłecki 
> Signed-off-by: Petr Štetiar 
> ---
>  system.c | 170 ---
>  1 file changed, 123 insertions(+), 47 deletions(-)
> 
> diff --git a/system.c b/system.c
> index 5cd88e0d8227..f0198a5b20b8 100644
> --- a/system.c
> +++ b/system.c
> @@ -37,6 +37,12 @@ static struct blob_buf b;
>  static int notify;
>  static struct ubus_context *_ctx;
>  
> +enum vjson_state {
> + VJSON_ERROR,
> + VJSON_CONTINUE,
> + VJSON_SUCCESS,
> +};
> +
>  static int system_board(struct ubus_context *ctx, struct ubus_object *obj,
>   struct ubus_request_data *req, const char *method,
>   struct blob_attr *msg)
> @@ -413,30 +419,127 @@ static int proc_signal(struct ubus_context *ctx, 
> struct ubus_object *obj,
>   return 0;
>  }
>  
> +static enum vjson_state vjson_error(char **b, const char *fmt, ...)

Please annotate the function with:
__attribute__ ((format (printf, 2, 3)));

> +{
> + static char buf[256] = { 0 };
> + const char *pfx = "Firmware image couldn't be validated: ";
> + va_list va;
> + int r;
> +
> + r = snprintf(buf, sizeof(buf), "%s", pfx);
> + if (r < 0) {
> + *b = "vjson_error() snprintf failed";
> + return VJSON_ERROR;
> + }
> +
> + va_start(va, fmt);
> + r = vsnprintf(buf+r, sizeof(buf)-r, fmt, va);
Please check here for truncation:
rv = vsnprintf(buf+r, sizeof(buf)-r, fmt, va);
if (rv < 0 || rv >=  sizeof(buf)-r ) {


> + if (r < 0) {
> + *b = "vjson_error() vsnprintf failed";
> + return VJSON_ERROR;
> + }
> + va_end(va);
> +
> + *b = buf;
> + return VJSON_ERROR;
> +}
> +
> +static enum vjson_state vjson_parse_token(json_tokener *tok, char *buf, 
> ssize_t len, char **err)
> +{
> + json_object *jsobj = NULL;
> +
> + jsobj = json_tokener_parse_ex(tok, buf, len);
> + if (json_tokener_get_error(tok) == json_tokener_continue)
> + return VJSON_CONTINUE;
> +
> + if (json_tokener_get_error(tok) == json_tokener_success) {
> + if (json_object_get_type(jsobj) != json_type_object) {
> + json_object_put(jsobj);
> + return vjson_error(err, "result is not an JSON object");
> + }
> +
> + blobmsg_add_object(, jsobj);
> + json_object_put(jsobj);
> + return VJSON_SUCCESS;
> + }
> +
> + return vjson_error(err, "failed to parse JSON: %s (%d)",
> +json_tokener_error_desc(json_tokener_get_error(tok)),
> +json_tokener_get_error(tok));

Why don't you free it here too json_object_put()?

> +}
> +
> +static enum vjson_state vjson_parse(int fd, char **err)
> +{
> + enum vjson_state r = VJSON_ERROR;
> + size_t read_count = 0;
> + char buf[64] = { 0 };
> + json_tokener *tok;
> + ssize_t len;
> + int _errno;
> +
> + tok = json_tokener_new();
> + if (!tok)
> + return vjson_error(err, "json_tokener_new() failed");
> +
> + vjson_error(err, "incomplete JSON input");
> +
> + while ((len = read(fd, buf, sizeof(buf {
> + if (len < 0 && errno == EINTR)
> + continue;
> +
> + if (len < 0) {
> + _errno = errno;
> + json_tokener_free(tok);
> + return vjson_error(err, "read() failed: %s (%d)",
> +strerror(_errno), _errno);
> + }
> +
> + read_count += len;
> + r = vjson_parse_token(tok, buf, len, err);
> + if (r != VJSON_CONTINUE)
> + break;
> +
> + memset(buf, 0, sizeof(buf));
> + }
> +
> + if (read_count == 0)
> + vjson_error(err, "no JSON input");
> +
> + json_tokener_free(tok);
> + return r;
> +}
> +
>  /**
>   * validate_firmware_image_call - perform validation & store result in 
> global b
>   *
>   * @file: firmware image path
>   */
> -static int validate_firmware_image_call(const char *file)
> +static enum vjson_state validate_firmware_image_call(const char *file, char 
> **err)
>  {
>   const char *path = "/usr/libexec/validate_firmware_image";
> - json_object *jsobj = NULL;
> - json_tokener *tok;
> - char buf[64];
> - ssize_t len;
> + enum vjson_state ret = VJSON_ERROR;
> + int _errno;
>

Re: [OpenWrt-Devel] [PATCH procd 2/4] system: fix failing image validation due to EINTR

2020-01-04 Thread Hauke Mehrtens
On 1/3/20 1:46 AM, Petr Štetiar wrote:
> It was quite common to see following error during sysupgrade on serial
> console:
> 
>  Failed to parse JSON: 4
> 
> This is happening due to the fact, that validate_firmware_image_call
> fork()s then waits in blocking read() for the input from the child
> process, but child finishes its tasks and exits, thus emitting SIGCHLD
> signal which then leads to the interruption of the blocking read() in
> the parent process with EINTR error.
> 
> It seems like the recent fixes in the libubox library, particulary in
> the jshn sub-component (which empowers json_dump used in the shell
> script executed by the child process) made the execution somehow faster,
> thus exposing this racy behaviour in the validate_firmware_image_call at
> least on RPi-4 (Cortex-A72) target.
> 
> So this patch fixes this issue by checking the read() return value and
> retrying the read() if interrupted due to the EINTR error.
> 
> Ref: 
> http://lists.infradead.org/pipermail/openwrt-devel/2020-January/020994.html
> Fixes: e990e215e8a3 ("system: add "validate_firmware_image" ubus method")
> Cc: Rafał Miłecki 
> Reported-by: Petr Novák 
> Signed-off-by: Petr Štetiar 
> ---

Reviewed-by: Hauke Mehrtens 

>  system.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/system.c b/system.c
> index 65d3f09b7fb6..5cd88e0d8227 100644
> --- a/system.c
> +++ b/system.c
> @@ -466,6 +466,9 @@ static int validate_firmware_image_call(const char *file)
>  
>   blob_buf_init(, 0);
>   while ((len = read(fds[0], buf, sizeof(buf {
> + if (len < 0 && errno == EINTR)
> + continue;
> +
>   jsobj = json_tokener_parse_ex(tok, buf, len);
>  
>   if (json_tokener_get_error(tok) == json_tokener_success)
> 
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
> 




signature.asc
Description: OpenPGP digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Kernel version for OpenWrt 20.X

2020-01-04 Thread Hauke Mehrtens
On 1/3/20 1:53 PM, m...@adrianschmutzler.de wrote:
> Hi Hauke,
> 
>> -Original Message-
>> From: openwrt-devel [mailto:openwrt-devel-boun...@lists.openwrt.org]
>> On Behalf Of Hauke Mehrtens
>> Sent: Donnerstag, 28. November 2019 19:42
>> To: Adrian Schmutzler ; 'OpenWrt Development
>> List' 
>> Cc: 'Koen Vandeputte' 
>> Subject: Re: [OpenWrt-Devel] Kernel version for OpenWrt 20.X
>>
>> On 11/28/19 7:11 PM, Adrian Schmutzler wrote:
>>> Hi Hauke,
>>>
 The following are still on kernel 4.9:
  * ar7
  * ixp4xx
  * orion
>>>
>>> There are patches (actually from you, May 2019) on the list which
>>> claim to bump ar7 and orion to 4.14:
>>>
>>> https://patchwork.ozlabs.org/project/openwrt/list/?series=107337
>>> https://patchwork.ozlabs.org/project/openwrt/list/?series=107339
>>>
>>> I haven't looked closer, just in case you forgot about them ;-)
>>
>> Nobody reported that they are working so I never applied them. I do not
>> have the hardware, I just made them compile.
> 
> Since there was no response of any kind from a third party, I've just marked 
> the two patchsets as "Deferred" in the patchwork, so we get a little more 
> overview there. I hope that's okay for you.

Yes fine with me, we should probably drop these targets soon.

Hauke



signature.asc
Description: OpenPGP digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH procd] instance: strdup string attributes

2020-01-04 Thread Daniel Golle
Previously string attributes were set to pointers returned by
blobmsg_get_string() which caused use-after-free problems.
Use strdup() to have copies of all stored strings and free them
during cleanup.

Signed-off-by: Daniel Golle 
---
 service/instance.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/service/instance.c b/service/instance.c
index abd1f34..b0c9807 100644
--- a/service/instance.c
+++ b/service/instance.c
@@ -805,11 +805,11 @@ instance_jail_parse(struct service_instance *in, struct 
blob_attr *attr)
jail->argc = 2;
 
if (tb[JAIL_ATTR_NAME]) {
-   jail->name = blobmsg_get_string(tb[JAIL_ATTR_NAME]);
+   jail->name = strdup(blobmsg_get_string(tb[JAIL_ATTR_NAME]));
jail->argc += 2;
}
if (tb[JAIL_ATTR_HOSTNAME]) {
-   jail->hostname = blobmsg_get_string(tb[JAIL_ATTR_HOSTNAME]);
+   jail->hostname = 
strdup(blobmsg_get_string(tb[JAIL_ATTR_HOSTNAME]));
jail->argc += 2;
}
if (tb[JAIL_ATTR_PROCFS]) {
@@ -957,12 +957,12 @@ instance_config_parse(struct service_instance *in)
in->no_new_privs = 
blobmsg_get_bool(tb[INSTANCE_ATTR_NO_NEW_PRIVS]);
 
if (!in->trace && tb[INSTANCE_ATTR_SECCOMP])
-   in->seccomp = blobmsg_get_string(tb[INSTANCE_ATTR_SECCOMP]);
+   in->seccomp = 
strdup(blobmsg_get_string(tb[INSTANCE_ATTR_SECCOMP]));
 
if (tb[INSTANCE_ATTR_PIDFILE]) {
char *pidfile = blobmsg_get_string(tb[INSTANCE_ATTR_PIDFILE]);
if (pidfile)
-   in->pidfile = pidfile;
+   in->pidfile = strdup(pidfile);
}
 
if (tb[INSTANCE_ATTR_RELOADSIG])
@@ -1077,6 +1077,10 @@ instance_free(struct service_instance *in)
free(in->config);
free(in->user);
free(in->group);
+   free(in->jail.name);
+   free(in->jail.hostname);
+   free(in->seccomp);
+   free(in->pidfile);
free(in);
 }
 
-- 
2.24.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 1/7] package/utils/busybox: add optional selinux support

2020-01-04 Thread Daniel Golle
Hi Thomas,

On Sat, Jan 04, 2020 at 02:15:38PM +0100, Thomas Petazzoni wrote:
> Hello,
> 
> On Sat, 4 Jan 2020 15:06:38 +0200
> Daniel Golle  wrote:
> 
> > > @@ -76,6 +76,9 @@ LDLIBS += $(call BUSYBOX_IF_ENABLED,PAM,pam pam_misc 
> > > pthread)
> > >  ifeq ($(CONFIG_USE_GLIBC),y)
> > >LDLIBS += $(call BUSYBOX_IF_ENABLED,NSLOOKUP_OPENWRT,resolv)
> > >  endif
> > > +ifeq ($(CONFIG_BUSYBOX_CONFIG_SELINUX),y)
> > > +  LDLIBS += selinux sepol
> > > +endif  
> > 
> > also here, it would be better to have a build-variant of busybox with
> > has selinux enabled instead of a buildroot compile option.
> 
> Thanks for your feedback. Could you give some initial hints on what you
> mean by "build-variant", or at least point at some existing examples ?

See package/utils/px5g/Makefile, in that case px5g is build two times,
once with built-in crypto and once with libmbedtls linked. The result
are two binary packages 'px5g'(-standalone) and 'px5g-mbedtls'.
Doing the same for SELinux-enabled busybox and procd will potentially
allow building SELinux-enabled images using the ImageBuilder (as
opposed to building them entirely from source).
And similar to how we do for seccomp-policies (see
package/network/services/umdns/Makefile) we could ship SELinux policies
with packages or as add-on packages like in other distributions (given
we will add support for that in the build system as well as in opkg).


Cheers


Daniel

> 
> Thanks a lot,
> 
> Thomas
> -- 
> Thomas Petazzoni, CTO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 1/7] package/utils/busybox: add optional selinux support

2020-01-04 Thread Thomas Petazzoni
Hello,

On Sat, 4 Jan 2020 15:06:38 +0200
Daniel Golle  wrote:

> > @@ -76,6 +76,9 @@ LDLIBS += $(call BUSYBOX_IF_ENABLED,PAM,pam pam_misc 
> > pthread)
> >  ifeq ($(CONFIG_USE_GLIBC),y)
> >LDLIBS += $(call BUSYBOX_IF_ENABLED,NSLOOKUP_OPENWRT,resolv)
> >  endif
> > +ifeq ($(CONFIG_BUSYBOX_CONFIG_SELINUX),y)
> > +  LDLIBS += selinux sepol
> > +endif  
> 
> also here, it would be better to have a build-variant of busybox with
> has selinux enabled instead of a buildroot compile option.

Thanks for your feedback. Could you give some initial hints on what you
mean by "build-variant", or at least point at some existing examples ?

Thanks a lot,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 1/7] package/utils/busybox: add optional selinux support

2020-01-04 Thread Daniel Golle
Hi Thomas,

On Fri, Nov 22, 2019 at 10:55:35AM +0100, Thomas Petazzoni wrote:
> Signed-off-by: Thomas Petazzoni 
> ---
>  package/utils/busybox/Makefile | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/package/utils/busybox/Makefile b/package/utils/busybox/Makefile
> index c0f3007e5d..bad4598525 100644
> --- a/package/utils/busybox/Makefile
> +++ b/package/utils/busybox/Makefile
> @@ -17,7 +17,7 @@ PKG_SOURCE_URL:=https://www.busybox.net/downloads \
>   http://sources.buildroot.net
>  PKG_HASH:=d0f940a72f648943c1f2211e0e3117387c31d765137d92bd8284a3fb9752a998
>  
> -PKG_BUILD_DEPENDS:=BUSYBOX_CONFIG_PAM:libpam
> +PKG_BUILD_DEPENDS:=BUSYBOX_CONFIG_PAM:libpam 
> BUSYBOX_CONFIG_SELINUX:libselinux
>  PKG_BUILD_PARALLEL:=1
>  PKG_CHECK_FORMAT_SECURITY:=0
>  
> @@ -45,7 +45,7 @@ define Package/busybox
>MAINTAINER:=Felix Fietkau 
>TITLE:=Core utilities for embedded Linux
>URL:=http://busybox.net/
> -  DEPENDS:=+BUSYBOX_CONFIG_PAM:libpam +BUSYBOX_CONFIG_NTPD:jsonfilter
> +  DEPENDS:=+BUSYBOX_CONFIG_PAM:libpam +BUSYBOX_CONFIG_NTPD:jsonfilter 
> +BUSYBOX_CONFIG_SELINUX:libselinux
>MENU:=1
>  endef
>  
> @@ -76,6 +76,9 @@ LDLIBS += $(call BUSYBOX_IF_ENABLED,PAM,pam pam_misc 
> pthread)
>  ifeq ($(CONFIG_USE_GLIBC),y)
>LDLIBS += $(call BUSYBOX_IF_ENABLED,NSLOOKUP_OPENWRT,resolv)
>  endif
> +ifeq ($(CONFIG_BUSYBOX_CONFIG_SELINUX),y)
> +  LDLIBS += selinux sepol
> +endif

also here, it would be better to have a build-variant of busybox with
has selinux enabled instead of a buildroot compile option.


Cheers


Daniel

>  
>  TARGET_CFLAGS += -flto
>  TARGET_LDFLAGS += -flto=jobserver -fuse-linker-plugin
> -- 
> 2.23.0
> 
> 
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 2/7] package/system/procd: add SELinux support

2020-01-04 Thread Daniel Golle
Hi Thomas,

On Fri, Nov 22, 2019 at 10:55:36AM +0100, Thomas Petazzoni wrote:
> This commit adds a patch to procd to support loading the SELinux
> policy early at boot time, and adjusts the procd package to use this
> SELinux support when libselinux is enabled.
> 
> The procd patch has been submitted separately [1]: obviously the
> intent is to have it merged in the procd Git repository rather than
> have it in OpenWrt itself.
> 
> [1] 
> http://lists.infradead.org/pipermail/openwrt-devel/2019-November/020070.html
> 
> Signed-off-by: Thomas Petazzoni 
> ---
>  package/system/procd/Makefile |   5 +-
>  ...inimal-SELinux-policy-loading-suppor.patch | 110 ++
>  2 files changed, 113 insertions(+), 2 deletions(-)
>  create mode 100644 
> package/system/procd/patches/0001-initd-init-add-minimal-SELinux-policy-loading-suppor.patch
> 
> diff --git a/package/system/procd/Makefile b/package/system/procd/Makefile
> index c4b86ba746..53d9e1120f 100644
> --- a/package/system/procd/Makefile
> +++ b/package/system/procd/Makefile
> @@ -43,7 +43,7 @@ TARGET_LDFLAGS += -flto
>  define Package/procd
>SECTION:=base
>CATEGORY:=Base system
> -  DEPENDS:=+ubusd +ubus +libjson-script +ubox +USE_GLIBC:librt +libubox 
> +libubus +libblobmsg-json +libjson-c
> +  DEPENDS:=+ubusd +ubus +libjson-script +ubox +USE_GLIBC:librt +libubox 
> +libubus +libblobmsg-json +libjson-c +PACKAGE_libselinux:libselinux
>TITLE:=OpenWrt system process manager
>USERID:=:dialout=20 :audio=29
>  endef
> @@ -92,7 +92,8 @@ ifdef CONFIG_PACKAGE_procd-ujail
>  endif
>  
>  SECCOMP=$(if $(CONFIG_PACKAGE_procd-seccomp),1,0)
> -CMAKE_OPTIONS += -DSECCOMP_SUPPORT=$(SECCOMP) -DUTRACE_SUPPORT=$(SECCOMP)
> +SELINUX=$(if $(CONFIG_PACKAGE_libselinux),1,0)

Selecting this based on libselinux being selected for build is not
feasible. The buildbot always builds with all packages enabled, yet
not everyone will want libselinux installed on their small-flash
devices... Please use introduce a VARIANT:=selinux instead to have
an additional package procd-selinux. In that way, binary builds will
allow for both, selinux-enabled and non-selinux images being generated.
Another (and even better) solution would be to out-source SELinux
policy loading into a small independent executable in it's own packages
(like eg. procd-seccomp).


Cheers


Daniel

> +CMAKE_OPTIONS += -DSECCOMP_SUPPORT=$(SECCOMP) -DUTRACE_SUPPORT=$(SECCOMP) 
> -DSELINUX=$(SELINUX)
>  
>  define Package/procd/install
>   $(INSTALL_DIR) $(1)/sbin $(1)/etc $(1)/lib/functions
> diff --git 
> a/package/system/procd/patches/0001-initd-init-add-minimal-SELinux-policy-loading-suppor.patch
>  
> b/package/system/procd/patches/0001-initd-init-add-minimal-SELinux-policy-loading-suppor.patch
> new file mode 100644
> index 00..cfab059b40
> --- /dev/null
> +++ 
> b/package/system/procd/patches/0001-initd-init-add-minimal-SELinux-policy-loading-suppor.patch
> @@ -0,0 +1,110 @@
> +From fe74ad8b11977d0ced5c44f5e389c50ee70bc008 Mon Sep 17 00:00:00 2001
> +From: Thomas Petazzoni 
> +Date: Thu, 23 May 2019 13:57:30 +0200
> +Subject: [PATCH] initd/init: add minimal SELinux policy loading support
> +
> +In order to support SELinux in OpenWRT, this commit introduces minimal
> +support for loading the SELinux policy in the init code. The logic is
> +very much inspired from what Busybox is doing: call
> +selinux_init_load_policy() from libselinux, and then re-execute init
> +so that it runs with the SELinux policy in place and enforced.
> +
> +Signed-off-by: Thomas Petazzoni 
> +---
> + CMakeLists.txt |  9 -
> + initd/init.c   | 38 ++
> + 2 files changed, 46 insertions(+), 1 deletion(-)
> +
> +diff --git a/CMakeLists.txt b/CMakeLists.txt
> +index 4b3eebd..865e43c 100644
> +--- a/CMakeLists.txt
>  b/CMakeLists.txt
> +@@ -40,6 +40,12 @@ IF(ZRAM_TMPFS)
> +   SET(SOURCES_ZRAM initd/zram.c)
> + ENDIF()
> + 
> ++IF(SELINUX)
> ++  include(FindPkgConfig)
> ++  pkg_search_module(SELINUX REQUIRED libselinux)
> ++  add_compile_definitions(WITH_SELINUX)
> ++ENDIF()
> ++
> + add_subdirectory(upgraded)
> + 
> + ADD_EXECUTABLE(procd ${SOURCES})
> +@@ -56,7 +62,8 @@ ADD_DEFINITIONS(-DDISABLE_INIT)
> + ELSE()
> + ADD_EXECUTABLE(init initd/init.c initd/early.c initd/preinit.c 
> initd/mkdev.c sysupgrade.c watchdog.c
> + utils/utils.c ${SOURCES_ZRAM})
> +-TARGET_LINK_LIBRARIES(init ${LIBS})
> ++TARGET_INCLUDE_DIRECTORIES(init PUBLIC ${SELINUX_INCLUDE_DIRS})
> ++TARGET_LINK_LIBRARIES(init ${LIBS} ${SELINUX_LIBRARIES})
> + INSTALL(TARGETS init
> + RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
> + )
> +diff --git a/initd/init.c b/initd/init.c
> +index 29eee50..561970c 100644
> +--- a/initd/init.c
>  b/initd/init.c
> +@@ -29,6 +29,10 @@
> + #include 
> + #include 
> + 
> ++#if defined(WITH_SELINUX)
> ++#include 
> ++#endif
> ++
> + #include "../utils/utils.h"
> + #include "init.h"
> + #include "../watchdog.h"
> +@@ -67,6 +71,38 @@ cmdline(void)

Re: [OpenWrt-Devel] ar71xx: Remove mtd cfi_cmdset_0002 status check patch

2020-01-04 Thread mail
Hi Ikegami,

> -Original Message-
> From: openwrt-devel [mailto:openwrt-devel-boun...@lists.openwrt.org]
> On Behalf Of Tokunori Ikegami
> Sent: Samstag, 4. Januar 2020 03:06
> To: m...@adrianschmutzler.de; openwrt-devel@lists.openwrt.org
> Subject: Re: [OpenWrt-Devel] ar71xx: Remove mtd cfi_cmdset_0002 status
> check patch
> 
> Hi,
> 
> Thanks for the confirmation.
> 

Thanks for your response.

> Yes your understanding is correct.
> Also I could understand it as rejected patch since ar71xx is deprecated.
> 
> By the way how about ath79 is if deprecated as same?
> Since there are same patches in ath79 also.

I wasn't aware of that. (Actually, I didn't check as there was only a patch for 
ar71xx.)

In this case, you should consider resending this for ath79, and if you do that, 
you might also include the (identical) ar71xx version again in the same 
patchset (but as separate patch.)

Some comments:
1. I've looked into the code and from my perspective your patch looks correct 
to me. However, I would like to have Koen's statement, who was involved in 
changing this in the first place:
https://github.com/openwrt/openwrt/commit/ddc11c3932c7b7b7df7d5fbd48f207e77619eaa7
(They also do a function rename there, though.)
2. When you resend, please add the reference to this commit and state that you 
are reverting it partially in the commit message, so that other people do not 
have to look for themselves.
3. Remove the Cc: of the openwrt-devel list in the commit message, and add Koen 
as Cc:

I've marked the old patch as "Changes Requested".

Best

Adrian

> 
> Regards,
> Ikegami
> 
> On 2020/01/03 22:43, m...@adrianschmutzler.de wrote:
> > Hi,
> >
> > your patch "ar71xx: Remove mtd cfi_cmdset_0002 status check patch"
> looks cosmetical to me. Is this impression correct?
> >
> > If yes, since ar71xx is effectively deprecated and won't be included in next
> (after-19.07) release, I would reject it to save reviewing time for other
> changes.
> >
> > I hope you understand this and continue to improve OpenWrt with other
> submissions.
> >
> > https://patchwork.ozlabs.org/patch/1198343/
> >
> > Best
> >
> > Adrian
> 
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel


openpgp-digital-signature.asc
Description: PGP signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v2] fstools: Add support to read-only MTD partitions (eg. recovery images)

2020-01-04 Thread Bruno Pena
This patch enables fstools to open read-only MTD partitions, which in
turn also enables OpenWrt to boot from read-only partitions.

The use of read-only partitions is of special importance for WiFi-only
devices, where a protected read-only recovery image can be used in case
something goes wrong with the main firmware (eg. user gets locked out
due to bad settings, flash of an unbootable dev firmware, etc).

Signed-off-by: Bruno Pena 
---
 libfstools/mtd.c | 19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/libfstools/mtd.c b/libfstools/mtd.c
index 77c71ee..aae633e 100644
--- a/libfstools/mtd.c
+++ b/libfstools/mtd.c
@@ -36,20 +36,31 @@ struct mtd_volume {
 
 static struct driver mtd_driver;
 
+static int mtd_open_device(const char *dev)
+{
+   int ret;
+
+   ret = open(dev, O_RDWR | O_SYNC);
+   if (ret < 0)
+   ret = open(dev, O_RDONLY);
+
+   return ret;
+}
+
 static int mtd_open(const char *mtd, int block)
 {
FILE *fp;
char dev[PATH_MAX];
-   int i, ret, flags = O_RDWR | O_SYNC;
+   int i, ret;
 
if ((fp = fopen("/proc/mtd", "r"))) {
while (fgets(dev, sizeof(dev), fp)) {
if (sscanf(dev, "mtd%d:", ) && strstr(dev, mtd)) {
snprintf(dev, sizeof(dev), "/dev/mtd%s/%d", 
(block ? "block" : ""), i);
-   ret = open(dev, flags);
+   ret = mtd_open_device(dev);
if (ret < 0) {
snprintf(dev, sizeof(dev), 
"/dev/mtd%s%d", (block ? "block" : ""), i);
-   ret = open(dev, flags);
+   ret = mtd_open_device(dev);
}
fclose(fp);
return ret;
@@ -58,7 +69,7 @@ static int mtd_open(const char *mtd, int block)
fclose(fp);
}
 
-   return open(mtd, flags);
+   return mtd_open_device(mtd);
 }
 
 static void mtd_volume_close(struct mtd_volume *p)
-- 
2.7.4


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 2/2] scripts/gen_image_generic.sh: use /bin/sh

2020-01-04 Thread Bjørn Mork
Rosen Penev  writes:

> -#!/usr/bin/env bash
> +#!/bin/bash

That's still not /bin/sh. I guess you do these pacthes by hand ;-)


Bjørn

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] strace: update to version 5.4

2020-01-04 Thread Josef Schlehofer
Changelog: https://strace.io/files/5.4/

Signed-off-by: Josef Schlehofer 
---
 package/devel/strace/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/package/devel/strace/Makefile b/package/devel/strace/Makefile
index 950dafc5d9..0d22b0bb23 100644
--- a/package/devel/strace/Makefile
+++ b/package/devel/strace/Makefile
@@ -9,12 +9,12 @@ include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=strace
-PKG_VERSION:=5.3
+PKG_VERSION:=5.4
 PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=https://strace.io/files/$(PKG_VERSION)
-PKG_HASH:=6c131198749656401fe3efd6b4b16a07ea867e8f530867ceae8930bbc937a047
+PKG_HASH:=f7d00514d51290b6db78ad7a9de709baf93caa5981498924cbc9a744cfd2a741
 
 PKG_MAINTAINER:=Felix Fietkau 
 PKG_LICENSE:=LGPL-2.1-or-later
-- 
2.24.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel