From db4bfcba7bb8d10f00bba2a3da6b9a9c2a1d7b71 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Tue, 1 Aug 2023 22:15:00 -0700 Subject: um: Fix hostaudio build errors Use "select" to ensure that the required kconfig symbols are set as expected. Drop HOSTAUDIO since it is now equivalent to UML_SOUND. Set CONFIG_SOUND=m in ARCH=um defconfig files to maintain the status quo of the default configs. Allow SOUND with UML regardless of HAS_IOMEM. Otherwise there is a kconfig warning for unmet dependencies. (This was not an issue when SOUND was defined in arch/um/drivers/Kconfig. I have done 50 randconfig builds and didn't find any issues.) This fixes build errors when CONFIG_SOUND is not set: ld: arch/um/drivers/hostaudio_kern.o: in function `hostaudio_cleanup_module': hostaudio_kern.c:(.exit.text+0xa): undefined reference to `unregister_sound_mixer' ld: hostaudio_kern.c:(.exit.text+0x15): undefined reference to `unregister_sound_dsp' ld: arch/um/drivers/hostaudio_kern.o: in function `hostaudio_init_module': hostaudio_kern.c:(.init.text+0x19): undefined reference to `register_sound_dsp' ld: hostaudio_kern.c:(.init.text+0x31): undefined reference to `register_sound_mixer' ld: hostaudio_kern.c:(.init.text+0x49): undefined reference to `unregister_sound_dsp' and this kconfig warning: WARNING: unmet direct dependencies detected for SOUND Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Fixes: d886e87cb82b ("sound: make OSS sound core optional") Signed-off-by: Randy Dunlap Reported-by: kernel test robot Closes: lore.kernel.org/r/202307141416.vxuRVpFv-lkp@intel.com Cc: Richard Weinberger Cc: Anton Ivanov Cc: Johannes Berg Cc: linux-um@lists.infradead.org Cc: Tejun Heo Cc: Takashi Iwai Cc: Jaroslav Kysela Cc: Masahiro Yamada Cc: Nathan Chancellor Cc: Nick Desaulniers Cc: Nicolas Schier Cc: linux-kbuild@vger.kernel.org Cc: alsa-devel@alsa-project.org Reviewed-by: Masahiro Yamada Signed-off-by: Richard Weinberger --- arch/um/drivers/Kconfig | 16 +++------------- arch/um/drivers/Makefile | 2 +- 2 files changed, 4 insertions(+), 14 deletions(-) (limited to 'arch/um/drivers') diff --git a/arch/um/drivers/Kconfig b/arch/um/drivers/Kconfig index 36911b1fddcf..b94b2618e7d8 100644 --- a/arch/um/drivers/Kconfig +++ b/arch/um/drivers/Kconfig @@ -111,24 +111,14 @@ config SSL_CHAN config UML_SOUND tristate "Sound support" + depends on SOUND + select SOUND_OSS_CORE help This option enables UML sound support. If enabled, it will pull in - soundcore and the UML hostaudio relay, which acts as a intermediary + the UML hostaudio relay, which acts as a intermediary between the host's dsp and mixer devices and the UML sound system. It is safe to say 'Y' here. -config SOUND - tristate - default UML_SOUND - -config SOUND_OSS_CORE - bool - default UML_SOUND - -config HOSTAUDIO - tristate - default UML_SOUND - endmenu menu "UML Network Devices" diff --git a/arch/um/drivers/Makefile b/arch/um/drivers/Makefile index a461a950f051..0e6af81096fd 100644 --- a/arch/um/drivers/Makefile +++ b/arch/um/drivers/Makefile @@ -54,7 +54,7 @@ obj-$(CONFIG_UML_NET) += net.o obj-$(CONFIG_MCONSOLE) += mconsole.o obj-$(CONFIG_MMAPPER) += mmapper_kern.o obj-$(CONFIG_BLK_DEV_UBD) += ubd.o -obj-$(CONFIG_HOSTAUDIO) += hostaudio.o +obj-$(CONFIG_UML_SOUND) += hostaudio.o obj-$(CONFIG_NULL_CHAN) += null.o obj-$(CONFIG_PORT_CHAN) += port.o obj-$(CONFIG_PTY_CHAN) += pty.o -- cgit v1.2.3 From e30955d029a8834c93c9bd0226fa6c1dfc59c812 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Mon, 7 Aug 2023 18:22:30 +0000 Subject: um: vector: refactor deprecated strncpy `strncpy` is deprecated for use on NUL-terminated destination strings [1]. A suitable replacement is `strscpy` [2] due to the fact that it guarantees NUL-termination on its destination buffer argument which is _not_ the case for `strncpy`! In this case, we are able to drop the now superfluous `... - 1` instances because `strscpy` will automatically truncate the last byte by setting it to a NUL byte if the source size exceeds the destination size or if the source string is not NUL-terminated. I've also opted to remove the seemingly useless char* casts. I'm not sure why they're present at all since (after expanding the `ifr_name` macro) `ifr.ifr_ifrn.ifrn_name` is a char* already. All in all, `strscpy` is a more robust and less ambiguous interface while also letting us remove some `... -1`'s which cleans things up a bit. [1]: www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [2]: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html Link: https://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt Acked-by: Anton Ivanov Signed-off-by: Richard Weinberger --- arch/um/drivers/vector_user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'arch/um/drivers') diff --git a/arch/um/drivers/vector_user.c b/arch/um/drivers/vector_user.c index c650e428432b..c719e1ec4645 100644 --- a/arch/um/drivers/vector_user.c +++ b/arch/um/drivers/vector_user.c @@ -141,7 +141,7 @@ static int create_tap_fd(char *iface) } memset(&ifr, 0, sizeof(ifr)); ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_VNET_HDR; - strncpy((char *)&ifr.ifr_name, iface, sizeof(ifr.ifr_name) - 1); + strscpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)); err = ioctl(fd, TUNSETIFF, (void *) &ifr); if (err != 0) { @@ -171,7 +171,7 @@ static int create_raw_fd(char *iface, int flags, int proto) goto raw_fd_cleanup; } memset(&ifr, 0, sizeof(ifr)); - strncpy((char *)&ifr.ifr_name, iface, sizeof(ifr.ifr_name) - 1); + strscpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCGIFINDEX, (void *) &ifr) < 0) { err = -errno; goto raw_fd_cleanup; -- cgit v1.2.3 From b10eee784c767975d345540e5569bdad31b9aec3 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Tue, 8 Aug 2023 10:22:59 -0700 Subject: uml: audio: fix -Wmissing-variable-declarations I'm looking to enable -Wmissing-variable-declarations behind W=1. 0day bot spotted the following instance: arch/um/drivers/hostaudio_kern.c:316:3: warning: no previous extern declaration for non-static variable 'module_data' [-Wmissing-variable-declarations] } module_data; ^ arch/um/drivers/hostaudio_kern.c:313:1: note: declare 'static' if the variable is not intended to be used outside of this translation unit struct { ^ This symbol is not referenced by more than one translation unit, so give it static storage. Reported-by: kernel test robot Closes: https://lore.kernel.org/llvm/202308081050.sZEw4cQ5-lkp@intel.com/ Signed-off-by: Nick Desaulniers Signed-off-by: Richard Weinberger --- arch/um/drivers/hostaudio_kern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/um/drivers') diff --git a/arch/um/drivers/hostaudio_kern.c b/arch/um/drivers/hostaudio_kern.c index 5b064d360cb7..c42b793bce65 100644 --- a/arch/um/drivers/hostaudio_kern.c +++ b/arch/um/drivers/hostaudio_kern.c @@ -310,7 +310,7 @@ static const struct file_operations hostmixer_fops = { .release = hostmixer_release, }; -struct { +static struct { int dev_audio; int dev_mixer; } module_data; -- cgit v1.2.3 From 4b038701e3dd02091e1086bdd89e31e16ceb8e04 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Tue, 8 Aug 2023 10:31:45 -0700 Subject: um: port_kern: fix -Wmissing-variable-declarations I'm looking to enable -Wmissing-variable-declarations behind W=1. 0day bot spotted the following instance: arch/um/drivers/port_kern.c:147:14: warning: no previous extern declaration for non-static variable 'port_work' [-Wmissing-variable-declarations] DECLARE_WORK(port_work, port_work_proc); ^ arch/um/drivers/port_kern.c:147:1: note: declare 'static' if the variable is not intended to be used outside of this translation unit DECLARE_WORK(port_work, port_work_proc); ^ This symbol is not referenced by more than one translation unit, so give it static storage. Reported-by: kernel test robot Closes: https://lore.kernel.org/llvm/202308081050.sZEw4cQ5-lkp@intel.com/ Signed-off-by: Nick Desaulniers Signed-off-by: Richard Weinberger --- arch/um/drivers/port_kern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/um/drivers') diff --git a/arch/um/drivers/port_kern.c b/arch/um/drivers/port_kern.c index efa8b7304090..c52b3ff3c092 100644 --- a/arch/um/drivers/port_kern.c +++ b/arch/um/drivers/port_kern.c @@ -144,7 +144,7 @@ static void port_work_proc(struct work_struct *unused) local_irq_restore(flags); } -DECLARE_WORK(port_work, port_work_proc); +static DECLARE_WORK(port_work, port_work_proc); static irqreturn_t port_interrupt(int irq, void *data) { -- cgit v1.2.3 From ab7ca2eb63a2168619f7595622fe29967ed0959b Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Tue, 8 Aug 2023 11:15:24 -0700 Subject: um: fix 3 instances of -Wmissing-prototypes Fixes the following build errors observed from W=1 builds: arch/um/drivers/xterm_kern.c:35:5: warning: no previous prototype for function 'xterm_fd' [-Wmissing-prototypes] 35 | int xterm_fd(int socket, int *pid_out) | ^ arch/um/drivers/xterm_kern.c:35:1: note: declare 'static' if the function is not intended to be used outside of this translation unit 35 | int xterm_fd(int socket, int *pid_out) | ^ | static arch/um/drivers/chan_kern.c:183:6: warning: no previous prototype for function 'free_irqs' [-Wmissing-prototypes] 183 | void free_irqs(void) | ^ arch/um/drivers/chan_kern.c:183:1: note: declare 'static' if the function is not intended to be used outside of this translation unit 183 | void free_irqs(void) | ^ | static arch/um/drivers/slirp_kern.c:18:6: warning: no previous prototype for function 'slirp_init' [-Wmissing-prototypes] 18 | void slirp_init(struct net_device *dev, void *data) | ^ arch/um/drivers/slirp_kern.c:18:1: note: declare 'static' if the function is not intended to be used outside of this translation unit 18 | void slirp_init(struct net_device *dev, void *data) | ^ | static Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202308081050.sZEw4cQ5-lkp@intel.com/ Signed-off-by: Nick Desaulniers Signed-off-by: Richard Weinberger --- arch/um/drivers/slirp_kern.c | 2 +- arch/um/drivers/xterm_kern.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'arch/um/drivers') diff --git a/arch/um/drivers/slirp_kern.c b/arch/um/drivers/slirp_kern.c index 2d9769237f08..0a6151ee9572 100644 --- a/arch/um/drivers/slirp_kern.c +++ b/arch/um/drivers/slirp_kern.c @@ -15,7 +15,7 @@ struct slirp_init { struct arg_list_dummy_wrapper argw; /* XXX should be simpler... */ }; -void slirp_init(struct net_device *dev, void *data) +static void slirp_init(struct net_device *dev, void *data) { struct uml_net_private *private; struct slirp_data *spri; diff --git a/arch/um/drivers/xterm_kern.c b/arch/um/drivers/xterm_kern.c index 50f11b7b4774..8011e51993d5 100644 --- a/arch/um/drivers/xterm_kern.c +++ b/arch/um/drivers/xterm_kern.c @@ -9,6 +9,7 @@ #include #include #include +#include "xterm.h" struct xterm_wait { struct completion ready; -- cgit v1.2.3 From 32280e83b555d692e8c7b96563b0ee2037585712 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Wed, 9 Aug 2023 18:19:32 +0000 Subject: um: Refactor deprecated strncpy to memcpy Use `memcpy` since `console_buf` is not expected to be NUL-terminated and it more accurately describes what is happening with the buffers `console_buf` and `string` as per Kees' analysis [1]. Also mark char buffer as `__nonstring` as per Kees' suggestion [2]. This change now makes it more clear what this code does and that `console_buf` is not expected to be NUL-terminated. Link: https://lore.kernel.org/all/202308081708.D5ADC80F@keescook/ [1] Link: https://github.com/KSPP/linux/issues/90 [2] Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings Cc: linux-hardening@vger.kernel.org Suggested-by: Kees Cook Signed-off-by: Justin Stitt Signed-off-by: Richard Weinberger --- arch/um/drivers/mconsole_kern.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'arch/um/drivers') diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c index 5026e7b9adfe..ff4bda95b9c7 100644 --- a/arch/um/drivers/mconsole_kern.c +++ b/arch/um/drivers/mconsole_kern.c @@ -554,7 +554,7 @@ struct mconsole_output { static DEFINE_SPINLOCK(client_lock); static LIST_HEAD(clients); -static char console_buf[MCONSOLE_MAX_DATA]; +static char console_buf[MCONSOLE_MAX_DATA] __nonstring; static void console_write(struct console *console, const char *string, unsigned int len) @@ -567,7 +567,7 @@ static void console_write(struct console *console, const char *string, while (len > 0) { n = min((size_t) len, ARRAY_SIZE(console_buf)); - strncpy(console_buf, string, n); + memcpy(console_buf, string, n); string += n; len -= n; -- cgit v1.2.3 From 974b808d85abbc03c3914af63d60d5816aabf2ca Mon Sep 17 00:00:00 2001 From: Vincent Whitchurch Date: Wed, 23 Aug 2023 12:40:44 +0200 Subject: um: virt-pci: fix missing declaration warning Fix this warning which appears with W=1 and without CONFIG_OF: warning: no previous declaration for 'pcibios_get_phb_of_node' Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202308230949.PphIIlhq-lkp@intel.com/ Fixes: 314a1408b79a ("um: virt-pci: implement pcibios_get_phb_of_node()") Signed-off-by: Vincent Whitchurch Signed-off-by: Richard Weinberger --- arch/um/drivers/virt-pci.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch/um/drivers') diff --git a/arch/um/drivers/virt-pci.c b/arch/um/drivers/virt-pci.c index 7699ca5f35d4..ffe2ee8a0246 100644 --- a/arch/um/drivers/virt-pci.c +++ b/arch/um/drivers/virt-pci.c @@ -544,6 +544,7 @@ static void um_pci_irq_vq_cb(struct virtqueue *vq) } } +#ifdef CONFIG_OF /* Copied from arch/x86/kernel/devicetree.c */ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) { @@ -562,6 +563,7 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) } return NULL; } +#endif static int um_pci_init_vqs(struct um_pci_device *dev) { -- cgit v1.2.3