diff --git a/patch.sh b/patch.sh index 4107b9942b6d178a526819a349e8fe4b9fbe1ca6..edf95681350633d853cd33aa956b91deb750fe52 100644 --- a/patch.sh +++ b/patch.sh @@ -558,7 +558,7 @@ patch_backports (){ } backports () { - backport_tag="v5.10.179" + backport_tag="v5.10.180" subsystem="uio" #regenerate="enable" @@ -574,7 +574,7 @@ backports () { dir 'drivers/ti/uio' fi - backport_tag="v6.1.27" + backport_tag="v6.1.29" subsystem="iio" #regenerate="enable" @@ -585,7 +585,6 @@ backports () { cp -rv ~/linux-src/include/uapi/linux/iio/* ./include/uapi/linux/iio/ cp -rv ~/linux-src/drivers/iio/* ./drivers/iio/ cp -rv ~/linux-src/drivers/staging/iio/* ./drivers/staging/iio/ - cp -v ~/linux-src/include/linux/interrupt.h ./include/linux/ post_backports exit 2 diff --git a/patches/backports/iio/0001-backports-iio-from-linux.git.patch b/patches/backports/iio/0001-backports-iio-from-linux.git.patch index 3a3201eec475e92636eb9dafb3e8481c2e1ebbba..666c9a9b5d5a7d84d41ad444f6980754a93a015c 100644 --- a/patches/backports/iio/0001-backports-iio-from-linux.git.patch +++ b/patches/backports/iio/0001-backports-iio-from-linux.git.patch @@ -1,306 +1,145 @@ -From 17b68ed5d56b809914984cfc2bf93037bd0a8d5a Mon Sep 17 00:00:00 2001 +From e61ca0aaae95a8aeccbab634da9cfe6440175f5a Mon Sep 17 00:00:00 2001 From: Robert Nelson <robertcnelson@gmail.com> -Date: Wed, 3 May 2023 16:34:43 -0500 +Date: Wed, 17 May 2023 17:06:16 -0500 Subject: [PATCH] backports: iio: from: linux.git -Reference: v6.1.27 +Reference: v6.1.29 Signed-off-by: Robert Nelson <robertcnelson@gmail.com> --- - drivers/iio/accel/mma9551_core.c | 10 ++++++++-- - drivers/iio/adc/ad7791.c | 2 +- - drivers/iio/adc/at91-sama5d2_adc.c | 2 +- - drivers/iio/adc/ltc2497.c | 6 ++---- - drivers/iio/adc/qcom-spmi-adc5.c | 10 +++++++++- - drivers/iio/adc/ti-ads7950.c | 1 + - drivers/iio/dac/ad5755.c | 1 + - drivers/iio/dac/cio-dac.c | 4 ++-- - drivers/iio/imu/Kconfig | 1 + - drivers/iio/industrialio-buffer.c | 21 ++++++++++++--------- - drivers/iio/light/cm32181.c | 12 ++++++++++++ - drivers/iio/light/tsl2563.c | 8 +++++++- - drivers/iio/light/tsl2772.c | 1 + - 13 files changed, 58 insertions(+), 21 deletions(-) + drivers/iio/adc/palmas_gpadc.c | 2 +- + drivers/iio/addac/stx104.c | 12 ++++++++++++ + drivers/iio/light/max44009.c | 13 +++++++------ + drivers/staging/iio/resolver/ad2s1210.c | 2 +- + 4 files changed, 21 insertions(+), 8 deletions(-) -diff --git a/drivers/iio/accel/mma9551_core.c b/drivers/iio/accel/mma9551_core.c -index 64ca7d7a9673..b898f865fb87 100644 ---- a/drivers/iio/accel/mma9551_core.c -+++ b/drivers/iio/accel/mma9551_core.c -@@ -296,9 +296,12 @@ int mma9551_read_config_word(struct i2c_client *client, u8 app_id, +diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c +index fd000345ec5c..849a697a467e 100644 +--- a/drivers/iio/adc/palmas_gpadc.c ++++ b/drivers/iio/adc/palmas_gpadc.c +@@ -639,7 +639,7 @@ static int palmas_gpadc_probe(struct platform_device *pdev) - ret = mma9551_transfer(client, app_id, MMA9551_CMD_READ_CONFIG, - reg, NULL, 0, (u8 *)&v, 2); -+ if (ret < 0) -+ return ret; -+ - *val = be16_to_cpu(v); - -- return ret; -+ return 0; - } - EXPORT_SYMBOL_NS(mma9551_read_config_word, IIO_MMA9551); - -@@ -354,9 +357,12 @@ int mma9551_read_status_word(struct i2c_client *client, u8 app_id, - - ret = mma9551_transfer(client, app_id, MMA9551_CMD_READ_STATUS, - reg, NULL, 0, (u8 *)&v, 2); -+ if (ret < 0) -+ return ret; -+ - *val = be16_to_cpu(v); - -- return ret; -+ return 0; - } - EXPORT_SYMBOL_NS(mma9551_read_status_word, IIO_MMA9551); + static int palmas_gpadc_remove(struct platform_device *pdev) + { +- struct iio_dev *indio_dev = dev_to_iio_dev(&pdev->dev); ++ struct iio_dev *indio_dev = dev_get_drvdata(&pdev->dev); + struct palmas_gpadc *adc = iio_priv(indio_dev); + + if (adc->wakeup1_enable || adc->wakeup2_enable) +diff --git a/drivers/iio/addac/stx104.c b/drivers/iio/addac/stx104.c +index 48a91a95e597..b658a75d4e3a 100644 +--- a/drivers/iio/addac/stx104.c ++++ b/drivers/iio/addac/stx104.c +@@ -15,6 +15,7 @@ + #include <linux/kernel.h> + #include <linux/module.h> + #include <linux/moduleparam.h> ++#include <linux/mutex.h> + #include <linux/spinlock.h> + #include <linux/types.h> + +@@ -69,10 +70,12 @@ struct stx104_reg { -diff --git a/drivers/iio/adc/ad7791.c b/drivers/iio/adc/ad7791.c -index fee8d129a5f0..86effe8501b4 100644 ---- a/drivers/iio/adc/ad7791.c -+++ b/drivers/iio/adc/ad7791.c -@@ -253,7 +253,7 @@ static const struct ad_sigma_delta_info ad7791_sigma_delta_info = { - .has_registers = true, - .addr_shift = 4, - .read_mask = BIT(3), -- .irq_flags = IRQF_TRIGGER_LOW, -+ .irq_flags = IRQF_TRIGGER_FALLING, + /** + * struct stx104_iio - IIO device private data structure ++ * @lock: synchronization lock to prevent I/O race conditions + * @chan_out_states: channels' output states + * @reg: I/O address offset for the device registers + */ + struct stx104_iio { ++ struct mutex lock; + unsigned int chan_out_states[STX104_NUM_OUT_CHAN]; + struct stx104_reg __iomem *reg; }; - - static int ad7791_read_raw(struct iio_dev *indio_dev, -diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c -index 870f4cb60923..3ad5678f2613 100644 ---- a/drivers/iio/adc/at91-sama5d2_adc.c -+++ b/drivers/iio/adc/at91-sama5d2_adc.c -@@ -1409,7 +1409,7 @@ static struct iio_trigger *at91_adc_allocate_trigger(struct iio_dev *indio, - trig = devm_iio_trigger_alloc(&indio->dev, "%s-dev%d-%s", indio->name, - iio_device_id(indio), trigger_name); - if (!trig) -- return NULL; -+ return ERR_PTR(-ENOMEM); - - trig->dev.parent = indio->dev.parent; - iio_trigger_set_drvdata(trig, indio); -diff --git a/drivers/iio/adc/ltc2497.c b/drivers/iio/adc/ltc2497.c -index 556f10dfb502..e1e14f5d237d 100644 ---- a/drivers/iio/adc/ltc2497.c -+++ b/drivers/iio/adc/ltc2497.c -@@ -28,7 +28,6 @@ struct ltc2497_driverdata { - struct ltc2497core_driverdata common_ddata; - struct i2c_client *client; - u32 recv_size; -- u32 sub_lsb; - /* - * DMA (thus cache coherency maintenance) may require the - * transfer buffers to live in their own cache lines. -@@ -65,10 +64,10 @@ static int ltc2497_result_and_measure(struct ltc2497core_driverdata *ddata, - * equivalent to a sign extension. - */ - if (st->recv_size == 3) { -- *val = (get_unaligned_be24(st->data.d8) >> st->sub_lsb) -+ *val = (get_unaligned_be24(st->data.d8) >> 6) - - BIT(ddata->chip_info->resolution + 1); - } else { -- *val = (be32_to_cpu(st->data.d32) >> st->sub_lsb) -+ *val = (be32_to_cpu(st->data.d32) >> 6) - - BIT(ddata->chip_info->resolution + 1); +@@ -114,6 +117,8 @@ static int stx104_read_raw(struct iio_dev *indio_dev, + return IIO_VAL_INT; } -@@ -122,7 +121,6 @@ static int ltc2497_probe(struct i2c_client *client, - st->common_ddata.chip_info = chip_info; - - resolution = chip_info->resolution; -- st->sub_lsb = 31 - (resolution + 1); - st->recv_size = BITS_TO_BYTES(resolution) + 1; ++ mutex_lock(&priv->lock); ++ + /* select ADC channel */ + iowrite8(chan->channel | (chan->channel << 4), ®->achan); - return ltc2497core_probe(dev, indio_dev); -diff --git a/drivers/iio/adc/qcom-spmi-adc5.c b/drivers/iio/adc/qcom-spmi-adc5.c -index 821fee60a765..d1b86570768a 100644 ---- a/drivers/iio/adc/qcom-spmi-adc5.c -+++ b/drivers/iio/adc/qcom-spmi-adc5.c -@@ -626,12 +626,20 @@ static int adc5_get_fw_channel_data(struct adc5_chip *adc, - struct fwnode_handle *fwnode, - const struct adc5_data *data) - { -- const char *name = fwnode_get_name(fwnode), *channel_name; -+ const char *channel_name; -+ char *name; - u32 chan, value, varr[2]; - u32 sid = 0; - int ret; - struct device *dev = adc->dev; +@@ -124,6 +129,8 @@ static int stx104_read_raw(struct iio_dev *indio_dev, + while (ioread8(®->cir_asr) & BIT(7)); -+ name = devm_kasprintf(dev, GFP_KERNEL, "%pfwP", fwnode); -+ if (!name) -+ return -ENOMEM; + *val = ioread16(®->ssr_ad); + -+ /* Cut the address part */ -+ name[strchrnul(name, '@') - name] = '\0'; ++ mutex_unlock(&priv->lock); + return IIO_VAL_INT; + case IIO_CHAN_INFO_OFFSET: + /* get ADC bipolar/unipolar configuration */ +@@ -178,9 +185,12 @@ static int stx104_write_raw(struct iio_dev *indio_dev, + if ((unsigned int)val > 65535) + return -EINVAL; + ++ mutex_lock(&priv->lock); + - ret = fwnode_property_read_u32(fwnode, "reg", &chan); - if (ret) { - dev_err(dev, "invalid channel number %s\n", name); -diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c -index 2cc9a9bd9db6..263fc3a1b87e 100644 ---- a/drivers/iio/adc/ti-ads7950.c -+++ b/drivers/iio/adc/ti-ads7950.c -@@ -634,6 +634,7 @@ static int ti_ads7950_probe(struct spi_device *spi) - st->chip.label = dev_name(&st->spi->dev); - st->chip.parent = &st->spi->dev; - st->chip.owner = THIS_MODULE; -+ st->chip.can_sleep = true; - st->chip.base = -1; - st->chip.ngpio = TI_ADS7950_NUM_GPIOS; - st->chip.get_direction = ti_ads7950_get_direction; -diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c -index beadfa938d2d..404865e35460 100644 ---- a/drivers/iio/dac/ad5755.c -+++ b/drivers/iio/dac/ad5755.c -@@ -802,6 +802,7 @@ static struct ad5755_platform_data *ad5755_parse_fw(struct device *dev) - return pdata; - - error_out: -+ fwnode_handle_put(pp); - devm_kfree(dev, pdata); - return NULL; - } -diff --git a/drivers/iio/dac/cio-dac.c b/drivers/iio/dac/cio-dac.c -index 791dd999cf29..18a64f72fc18 100644 ---- a/drivers/iio/dac/cio-dac.c -+++ b/drivers/iio/dac/cio-dac.c -@@ -66,8 +66,8 @@ static int cio_dac_write_raw(struct iio_dev *indio_dev, - if (mask != IIO_CHAN_INFO_RAW) - return -EINVAL; - -- /* DAC can only accept up to a 16-bit value */ -- if ((unsigned int)val > 65535) -+ /* DAC can only accept up to a 12-bit value */ -+ if ((unsigned int)val > 4095) - return -EINVAL; - - priv->chan_out_states[chan->channel] = val; -diff --git a/drivers/iio/imu/Kconfig b/drivers/iio/imu/Kconfig -index f1d7d4b5e222..c2f97629e9cd 100644 ---- a/drivers/iio/imu/Kconfig -+++ b/drivers/iio/imu/Kconfig -@@ -47,6 +47,7 @@ config ADIS16480 - depends on SPI - select IIO_ADIS_LIB - select IIO_ADIS_LIB_BUFFER if IIO_BUFFER -+ select CRC32 - help - Say yes here to build support for Analog Devices ADIS16375, ADIS16480, - ADIS16485, ADIS16488 inertial sensors. -diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c -index 228598b82a2f..7e7ee307a3f7 100644 ---- a/drivers/iio/industrialio-buffer.c -+++ b/drivers/iio/industrialio-buffer.c -@@ -203,24 +203,27 @@ static ssize_t iio_buffer_write(struct file *filp, const char __user *buf, - break; - } + priv->chan_out_states[chan->channel] = val; + iowrite16(val, &priv->reg->dac[chan->channel]); -+ if (filp->f_flags & O_NONBLOCK) { -+ if (!written) -+ ret = -EAGAIN; -+ break; -+ } -+ - wait_woken(&wait, TASK_INTERRUPTIBLE, - MAX_SCHEDULE_TIMEOUT); - continue; ++ mutex_unlock(&priv->lock); + return 0; } + return -EINVAL; +@@ -351,6 +361,8 @@ static int stx104_probe(struct device *dev, unsigned int id) - ret = rb->access->write(rb, n - written, buf + written); -- if (ret == 0 && (filp->f_flags & O_NONBLOCK)) -- ret = -EAGAIN; -+ if (ret < 0) -+ break; + indio_dev->name = dev_name(dev); -- if (ret > 0) { -- written += ret; -- if (written != n && !(filp->f_flags & O_NONBLOCK)) -- continue; -- } -- } while (ret == 0); -+ written += ret; ++ mutex_init(&priv->lock); + -+ } while (written != n); - remove_wait_queue(&rb->pollq, &wait); - -- return ret < 0 ? ret : n; -+ return ret < 0 ? ret : written; + /* configure device for software trigger operation */ + iowrite8(0, &priv->reg->acr); + +diff --git a/drivers/iio/light/max44009.c b/drivers/iio/light/max44009.c +index 801e5a0ad496..f3648f20ef2c 100644 +--- a/drivers/iio/light/max44009.c ++++ b/drivers/iio/light/max44009.c +@@ -528,6 +528,12 @@ static int max44009_probe(struct i2c_client *client, + return devm_iio_device_register(&client->dev, indio_dev); } - /** -diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c -index b1674a5bfa36..d4a34a3bf00d 100644 ---- a/drivers/iio/light/cm32181.c -+++ b/drivers/iio/light/cm32181.c -@@ -429,6 +429,14 @@ static const struct iio_info cm32181_info = { - .attrs = &cm32181_attribute_group, - }; - -+static void cm32181_unregister_dummy_client(void *data) -+{ -+ struct i2c_client *client = data; ++static const struct of_device_id max44009_of_match[] = { ++ { .compatible = "maxim,max44009" }, ++ { } ++}; ++MODULE_DEVICE_TABLE(of, max44009_of_match); + -+ /* Unregister the dummy client */ -+ i2c_unregister_device(client); -+} -+ - static int cm32181_probe(struct i2c_client *client) - { - struct device *dev = &client->dev; -@@ -460,6 +468,10 @@ static int cm32181_probe(struct i2c_client *client) - client = i2c_acpi_new_device(dev, 1, &board_info); - if (IS_ERR(client)) - return PTR_ERR(client); -+ -+ ret = devm_add_action_or_reset(dev, cm32181_unregister_dummy_client, client); -+ if (ret) -+ return ret; - } - - cm32181 = iio_priv(indio_dev); -diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c -index 951f35ef3f41..47a4626e9461 100644 ---- a/drivers/iio/light/tsl2563.c -+++ b/drivers/iio/light/tsl2563.c -@@ -705,6 +705,7 @@ static int tsl2563_probe(struct i2c_client *client, - struct iio_dev *indio_dev; - struct tsl2563_chip *chip; - struct tsl2563_platform_data *pdata = client->dev.platform_data; -+ unsigned long irq_flags; - int err = 0; - u8 id = 0; - -@@ -760,10 +761,15 @@ static int tsl2563_probe(struct i2c_client *client, - indio_dev->info = &tsl2563_info_no_irq; - - if (client->irq) { -+ irq_flags = irq_get_trigger_type(client->irq); -+ if (irq_flags == IRQF_TRIGGER_NONE) -+ irq_flags = IRQF_TRIGGER_RISING; -+ irq_flags |= IRQF_ONESHOT; -+ - err = devm_request_threaded_irq(&client->dev, client->irq, - NULL, - &tsl2563_event_handler, -- IRQF_TRIGGER_RISING | IRQF_ONESHOT, -+ irq_flags, - "tsl2563_event", - indio_dev); - if (err) { -diff --git a/drivers/iio/light/tsl2772.c b/drivers/iio/light/tsl2772.c -index dd9051f1cc1a..13a6c3d07861 100644 ---- a/drivers/iio/light/tsl2772.c -+++ b/drivers/iio/light/tsl2772.c -@@ -601,6 +601,7 @@ static int tsl2772_read_prox_diodes(struct tsl2772_chip *chip) - return -EINVAL; - } - } -+ chip->settings.prox_diode = prox_diode_mask; + static const struct i2c_device_id max44009_id[] = { + { "max44009", 0 }, + { } +@@ -537,18 +543,13 @@ MODULE_DEVICE_TABLE(i2c, max44009_id); + static struct i2c_driver max44009_driver = { + .driver = { + .name = MAX44009_DRV_NAME, ++ .of_match_table = max44009_of_match, + }, + .probe = max44009_probe, + .id_table = max44009_id, + }; + module_i2c_driver(max44009_driver); + +-static const struct of_device_id max44009_of_match[] = { +- { .compatible = "maxim,max44009" }, +- { } +-}; +-MODULE_DEVICE_TABLE(of, max44009_of_match); +- + MODULE_AUTHOR("Robert Eshleman <bobbyeshleman@gmail.com>"); + MODULE_LICENSE("GPL v2"); + MODULE_DESCRIPTION("MAX44009 ambient light sensor driver"); +diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c +index e4cf42438487..636c45b12843 100644 +--- a/drivers/staging/iio/resolver/ad2s1210.c ++++ b/drivers/staging/iio/resolver/ad2s1210.c +@@ -101,7 +101,7 @@ struct ad2s1210_state { + static const int ad2s1210_mode_vals[4][2] = { + [MOD_POS] = { 0, 0 }, + [MOD_VEL] = { 0, 1 }, +- [MOD_CONFIG] = { 1, 0 }, ++ [MOD_CONFIG] = { 1, 1 }, + }; - return 0; - } + static inline void ad2s1210_set_mode(enum ad2s1210_mode mode, -- 2.39.2 diff --git a/patches/backports/uio/0001-backports-uio-from-linux.git.patch b/patches/backports/uio/0001-backports-uio-from-linux.git.patch index 63ccfaa20439575a553674676644059dee53220e..51927299bab8102659efa28013e0422cecb8ccdb 100644 --- a/patches/backports/uio/0001-backports-uio-from-linux.git.patch +++ b/patches/backports/uio/0001-backports-uio-from-linux.git.patch @@ -1,9 +1,9 @@ -From 0d84e1d18460a740546add4d74468615fbd8f6c6 Mon Sep 17 00:00:00 2001 +From 83ebf7bfee0524f4f8cc0a29853cc28f95d4303a Mon Sep 17 00:00:00 2001 From: Robert Nelson <robertcnelson@gmail.com> -Date: Thu, 4 May 2023 15:00:42 -0500 +Date: Wed, 17 May 2023 16:59:54 -0500 Subject: [PATCH] backports: uio: from: linux.git -Reference: v5.10.179 +Reference: v5.10.180 Signed-off-by: Robert Nelson <robertcnelson@gmail.com> --- drivers/uio/uio_pruss.c | 44 +++++++++++++++++++++++++++++++---------- diff --git a/patches/defconfig b/patches/defconfig index 80528426ed3cfb8a85349f9f3463960667eb0169..f37ae8e5d1ddf878d79b96858965a82bf6ee3d2f 100644 --- a/patches/defconfig +++ b/patches/defconfig @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm 6.1.12 Kernel Configuration +# Linux/arm 6.1.26 Kernel Configuration # CONFIG_CC_VERSION_TEXT="arm-linux-gnueabi-gcc (GCC) 12.2.0" CONFIG_CC_IS_GCC=y @@ -161,7 +161,6 @@ CONFIG_GENERIC_SCHED_CLOCK=y CONFIG_CC_IMPLICIT_FALLTHROUGH="-Wimplicit-fallthrough=5" CONFIG_GCC11_NO_ARRAY_BOUNDS=y -CONFIG_GCC12_NO_ARRAY_BOUNDS=y CONFIG_CC_NO_ARRAY_BOUNDS=y CONFIG_CGROUPS=y CONFIG_PAGE_COUNTER=y @@ -1513,7 +1512,6 @@ CONFIG_DEFAULT_NET_SCH="fq_codel" # CONFIG_NET_CLS=y CONFIG_NET_CLS_BASIC=m -CONFIG_NET_CLS_TCINDEX=m CONFIG_NET_CLS_ROUTE4=m CONFIG_NET_CLS_FW=m CONFIG_NET_CLS_U32=m @@ -2137,6 +2135,9 @@ CONFIG_SRAM_EXEC=y # CONFIG_HISI_HIKEY_USB is not set # CONFIG_OPEN_DICE is not set # CONFIG_VCPU_STALL_DETECTOR is not set +CONFIG_DMA_BUF_PHYS=y +CONFIG_TPS6594_ESM=y +CONFIG_TPS6594_PFSM=y # CONFIG_C2PORT is not set # @@ -3036,6 +3037,7 @@ CONFIG_INPUT_YEALINK=m CONFIG_INPUT_CM109=m # CONFIG_INPUT_REGULATOR_HAPTIC is not set CONFIG_INPUT_TPS65218_PWRBUTTON=y +# CONFIG_INPUT_TPS65219_PWRBUTTON is not set CONFIG_INPUT_UINPUT=y CONFIG_INPUT_PALMAS_PWRBUTTON=y # CONFIG_INPUT_PCF8574 is not set @@ -3208,6 +3210,7 @@ CONFIG_I2C_MUX_PINCTRL=y # CONFIG_I2C_MUX_MLXCPLD is not set # end of Multiplexer I2C Chip support +# CONFIG_I2C_ATR is not set CONFIG_I2C_HELPER_AUTO=y CONFIG_I2C_ALGOBIT=y @@ -3347,6 +3350,7 @@ CONFIG_PINCTRL_PALMAS=y CONFIG_PINCTRL_SINGLE=y # CONFIG_PINCTRL_STMFX is not set # CONFIG_PINCTRL_SX150X is not set +CONFIG_PINCTRL_TPS6594=y # # Renesas pinctrl drivers @@ -3636,8 +3640,6 @@ CONFIG_SENSORS_PC87360=m CONFIG_SENSORS_PC87427=m CONFIG_SENSORS_NTC_THERMISTOR=m CONFIG_SENSORS_NCT6683=m -CONFIG_SENSORS_NCT6775_CORE=m -CONFIG_SENSORS_NCT6775=m # CONFIG_SENSORS_NCT6775_I2C is not set CONFIG_SENSORS_NCT7802=m CONFIG_SENSORS_NCT7904=m @@ -3915,10 +3917,14 @@ CONFIG_MFD_TPS65217=y # CONFIG_MFD_TI_LP873X is not set # CONFIG_MFD_TI_LP87565 is not set CONFIG_MFD_TPS65218=y +CONFIG_MFD_TPS65219=y # CONFIG_MFD_TPS6586X is not set # CONFIG_MFD_TPS65910 is not set # CONFIG_MFD_TPS65912_I2C is not set # CONFIG_MFD_TPS65912_SPI is not set +CONFIG_MFD_TPS6594=y +CONFIG_MFD_TPS6594_I2C=y +CONFIG_MFD_TPS6594_SPI=y # CONFIG_TWL4030_CORE is not set # CONFIG_TWL6040_CORE is not set CONFIG_MFD_WL1273_CORE=m @@ -4016,6 +4022,8 @@ CONFIG_REGULATOR_TI_ABB=y # CONFIG_REGULATOR_TPS65132 is not set CONFIG_REGULATOR_TPS65217=y CONFIG_REGULATOR_TPS65218=y +CONFIG_REGULATOR_TPS65219=y +CONFIG_REGULATOR_TPS6594=y # CONFIG_REGULATOR_TPS6524X is not set # CONFIG_REGULATOR_VCTRL is not set CONFIG_RC_CORE=m @@ -4339,6 +4347,11 @@ CONFIG_VIDEO_MUX=m # # Chips&Media media platform drivers # +# CONFIG_VIDEO_WAVE_VPU is not set + +# +# IMG media platform drivers +# # # Intel media platform drivers @@ -4462,6 +4475,7 @@ CONFIG_VIDEO_IMX290=m # CONFIG_VIDEO_IMX334 is not set # CONFIG_VIDEO_IMX335 is not set # CONFIG_VIDEO_IMX355 is not set +# CONFIG_VIDEO_IMX390 is not set # CONFIG_VIDEO_IMX412 is not set # CONFIG_VIDEO_MT9M001 is not set # CONFIG_VIDEO_MT9M032 is not set @@ -4478,6 +4492,7 @@ CONFIG_VIDEO_NOON010PC30=m # CONFIG_VIDEO_OV08D10 is not set # CONFIG_VIDEO_OV13858 is not set # CONFIG_VIDEO_OV13B10 is not set +# CONFIG_VIDEO_OV2312 is not set CONFIG_VIDEO_OV2640=m # CONFIG_VIDEO_OV2659 is not set # CONFIG_VIDEO_OV2680 is not set @@ -4637,6 +4652,14 @@ CONFIG_VIDEO_M52790=m # CONFIG_VIDEO_THS7303 is not set # end of Miscellaneous helper chips +# +# Video serializers and deserializers +# +# CONFIG_VIDEO_DS90UB913 is not set +# CONFIG_VIDEO_DS90UB953 is not set +# CONFIG_VIDEO_DS90UB960 is not set +# end of Video serializers and deserializers + # # Media SPI Adapters # @@ -4868,7 +4891,6 @@ CONFIG_DRM=y CONFIG_DRM_MIPI_DBI=m CONFIG_DRM_MIPI_DSI=y # CONFIG_DRM_DEBUG_MM is not set -CONFIG_DRM_USE_DYNAMIC_DEBUG=y CONFIG_DRM_KMS_HELPER=y # CONFIG_DRM_DEBUG_DP_MST_TOPOLOGY_REFS is not set # CONFIG_DRM_DEBUG_MODESET_LOCK is not set @@ -5055,8 +5077,6 @@ CONFIG_DRM_I2C_ADV7511_CEC=y CONFIG_DRM_ETNAVIV=y CONFIG_DRM_ETNAVIV_THERMAL=y # CONFIG_DRM_LOGICVC is not set -# CONFIG_DRM_MXSFB is not set -# CONFIG_DRM_IMX_LCDIF is not set # CONFIG_DRM_ARCPGU is not set CONFIG_DRM_GM12U320=m # CONFIG_DRM_PANEL_MIPI_DBI is not set @@ -6198,6 +6218,7 @@ CONFIG_RTC_DRV_M41T80=y CONFIG_RTC_DRV_M41T80_WDT=y CONFIG_RTC_DRV_BQ32K=y CONFIG_RTC_DRV_PALMAS=y +CONFIG_RTC_DRV_TPS6594=y CONFIG_RTC_DRV_S35390A=y CONFIG_RTC_DRV_FM3130=y CONFIG_RTC_DRV_RX8010=y @@ -6581,6 +6602,15 @@ CONFIG_RPMSG_NS=m CONFIG_RPMSG_VIRTIO=m # end of Rpmsg drivers +# +# Rpmsg virtual device drivers +# +CONFIG_RPMSG_KDRV=m +# CONFIG_RPMSG_KDRV_DEMO is not set +# CONFIG_RPMSG_KDRV_DISPLAY is not set +CONFIG_RPMSG_KDRV_ETH_SWITCH=m +# end of Rpmsg virtual device drivers + # CONFIG_SOUNDWIRE is not set # @@ -8149,7 +8179,7 @@ CONFIG_CRC64=y # CONFIG_CRC4 is not set CONFIG_CRC7=y CONFIG_LIBCRC32C=y -CONFIG_CRC8=m +CONFIG_CRC8=y CONFIG_XXHASH=y CONFIG_AUDIT_GENERIC=y # CONFIG_RANDOM32_SELFTEST is not set diff --git a/patches/drivers/ti/gpio/0002-bone-pinmux-helper.patch b/patches/drivers/ti/gpio/0002-bone-pinmux-helper.patch index 219949e1365ed95ebfa84437e685680c4350884d..6592923fdb18f29c465d4e41aa844a6ea5587651 100644 --- a/patches/drivers/ti/gpio/0002-bone-pinmux-helper.patch +++ b/patches/drivers/ti/gpio/0002-bone-pinmux-helper.patch @@ -31,10 +31,10 @@ Signed-off-by: Robert Nelson <robertcnelson@gmail.com> create mode 100644 drivers/misc/cape/beaglebone/bone-pinmux-helper.c diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig -index f4fb5c52b863..8403506a4abf 100644 +index 555dd203f568..5f35c1c50710 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig -@@ -456,6 +456,7 @@ source "drivers/misc/altera-stapl/Kconfig" +@@ -541,6 +541,7 @@ source "drivers/misc/altera-stapl/Kconfig" source "drivers/misc/mei/Kconfig" source "drivers/misc/vmw_vmci/Kconfig" source "drivers/misc/genwqe/Kconfig" @@ -43,12 +43,12 @@ index f4fb5c52b863..8403506a4abf 100644 source "drivers/misc/cxl/Kconfig" source "drivers/misc/ocxl/Kconfig" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile -index e92a56d4442f..2756a0302d60 100644 +index f8eb8f77e102..da87134a13fd 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile -@@ -45,6 +45,7 @@ obj-$(CONFIG_LATTICE_ECP3_CONFIG) += lattice-ecp3-config.o - obj-$(CONFIG_SRAM) += sram.o +@@ -47,6 +47,7 @@ obj-$(CONFIG_SRAM) += sram.o obj-$(CONFIG_SRAM_EXEC) += sram-exec.o + obj-$(CONFIG_SRAM_DMA_HEAP) += sram-dma-heap.o obj-$(CONFIG_GENWQE) += genwqe/ +obj-y += cape/ obj-$(CONFIG_ECHO) += echo/ @@ -352,5 +352,5 @@ index 000000000000..d81363a77b10 +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:bone-pinmux-helper"); -- -2.30.2 +2.39.2 diff --git a/patches/external/aufs/0001-merge-aufs-kbuild.patch b/patches/external/aufs/0001-merge-aufs-kbuild.patch index e7cfd43da7909fdaec13443ff3473882f218ec99..5ffabe97e57063729ac0d228207a597b513d0663 100644 --- a/patches/external/aufs/0001-merge-aufs-kbuild.patch +++ b/patches/external/aufs/0001-merge-aufs-kbuild.patch @@ -1,6 +1,6 @@ -From 8c91cfa2522839641cd859303ab81a83e862b8d6 Mon Sep 17 00:00:00 2001 +From 66e77051257b0ddeaf82438857286b91783f310d Mon Sep 17 00:00:00 2001 From: Robert Nelson <robertcnelson@gmail.com> -Date: Wed, 3 May 2023 15:33:06 -0500 +Date: Wed, 17 May 2023 16:50:36 -0500 Subject: [PATCH 1/5] merge: aufs-kbuild Signed-off-by: Robert Nelson <robertcnelson@gmail.com> diff --git a/patches/external/aufs/0002-merge-aufs-base.patch b/patches/external/aufs/0002-merge-aufs-base.patch index 559dfeb7ef71eb54e3851bcdd2f6514b396d92eb..f2df95ecb16e2eac21affadf73661cdb1feccd70 100644 --- a/patches/external/aufs/0002-merge-aufs-base.patch +++ b/patches/external/aufs/0002-merge-aufs-base.patch @@ -1,6 +1,6 @@ -From 6d2b83484122aec248a4108a6024053ead1c5116 Mon Sep 17 00:00:00 2001 +From 5859dac969099de387acf0dd779a4e30e616f56c Mon Sep 17 00:00:00 2001 From: Robert Nelson <robertcnelson@gmail.com> -Date: Wed, 3 May 2023 15:33:06 -0500 +Date: Wed, 17 May 2023 16:50:37 -0500 Subject: [PATCH 2/5] merge: aufs-base Signed-off-by: Robert Nelson <robertcnelson@gmail.com> @@ -19,7 +19,7 @@ Signed-off-by: Robert Nelson <robertcnelson@gmail.com> 11 files changed, 61 insertions(+), 8 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS -index d4822ae39e39..f167df31018e 100644 +index 304829687179..d8a6a975a5c6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3455,6 +3455,19 @@ F: include/uapi/linux/audit.h @@ -43,7 +43,7 @@ index d4822ae39e39..f167df31018e 100644 M: Miguel Ojeda <ojeda@kernel.org> S: Maintained diff --git a/drivers/block/loop.c b/drivers/block/loop.c -index df628e30bca4..afc41410ac5f 100644 +index 426d0b42685a..49ca6b9e71c1 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -645,6 +645,24 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev, @@ -107,7 +107,7 @@ index 146c9ab0cd4b..c980a0524118 100644 return error; diff --git a/fs/namespace.c b/fs/namespace.c -index df137ba19d37..faae7f8644ac 100644 +index e04a9e9e3f14..f0a33f8f2162 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -852,6 +852,12 @@ static inline int check_mnt(struct mount *mnt) @@ -152,7 +152,7 @@ index 5969b7a1d353..21db9b057d60 100644 unsigned int p_space; int ret; diff --git a/include/linux/fs.h b/include/linux/fs.h -index 081d1f539628..38a1396f9bdd 100644 +index f14ecbeab2a9..a6b5e21801f6 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1370,6 +1370,7 @@ extern void fasync_free(struct fasync_struct *); @@ -220,10 +220,10 @@ index a55179fd60fc..8e21c53cf883 100644 + unsigned int flags); #endif diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c -index e3375bc40dad..c1f0aadde539 100644 +index 50d4863974e7..36caa2ccf344 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c -@@ -217,7 +217,7 @@ unsigned long max_lock_class_idx; +@@ -218,7 +218,7 @@ unsigned long max_lock_class_idx; struct lock_class lock_classes[MAX_LOCKDEP_KEYS]; DECLARE_BITMAP(lock_classes_in_use, MAX_LOCKDEP_KEYS); @@ -232,7 +232,7 @@ index e3375bc40dad..c1f0aadde539 100644 { unsigned int class_idx = hlock->class_idx; -@@ -238,6 +238,7 @@ static inline struct lock_class *hlock_class(struct held_lock *hlock) +@@ -239,6 +239,7 @@ static inline struct lock_class *hlock_class(struct held_lock *hlock) */ return lock_classes + class_idx; } diff --git a/patches/external/aufs/0003-merge-aufs-mmap.patch b/patches/external/aufs/0003-merge-aufs-mmap.patch index ade1737e96144a23bedb7b36e2326467e8b3e1be..7e474871677ca5f654ad375a57e4f144a4277b28 100644 --- a/patches/external/aufs/0003-merge-aufs-mmap.patch +++ b/patches/external/aufs/0003-merge-aufs-mmap.patch @@ -1,6 +1,6 @@ -From 4548adb9965d722d97ad11243e86cfef5228e141 Mon Sep 17 00:00:00 2001 +From 4fe69054594b3de363f6a9cbd4d4f74995b0d145 Mon Sep 17 00:00:00 2001 From: Robert Nelson <robertcnelson@gmail.com> -Date: Wed, 3 May 2023 15:33:06 -0500 +Date: Wed, 17 May 2023 16:50:38 -0500 Subject: [PATCH 3/5] merge: aufs-mmap Signed-off-by: Robert Nelson <robertcnelson@gmail.com> @@ -91,10 +91,10 @@ index 2fd06f52b6a4..b01030da424f 100644 ino = inode->i_ino; pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT; diff --git a/include/linux/mm.h b/include/linux/mm.h -index 974ccca609d2..cfdfe8795d99 100644 +index e5e8acf8eb89..e9e184dc3686 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h -@@ -1954,6 +1954,43 @@ static inline void unmap_shared_mapping_range(struct address_space *mapping, +@@ -1960,6 +1960,43 @@ static inline void unmap_shared_mapping_range(struct address_space *mapping, unmap_mapping_range(mapping, holebegin, holelen, 0); } @@ -139,7 +139,7 @@ index 974ccca609d2..cfdfe8795d99 100644 void *buf, int len, unsigned int gup_flags); extern int access_remote_vm(struct mm_struct *mm, unsigned long addr, diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h -index 500e536796ca..2919f7112705 100644 +index 247aedb18d5c..7ab0a6699c43 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -413,6 +413,9 @@ struct vm_region { @@ -163,10 +163,10 @@ index 500e536796ca..2919f7112705 100644 #ifdef CONFIG_SWAP diff --git a/kernel/fork.c b/kernel/fork.c -index 844dfdc8c639..6101715c4604 100644 +index ec913b13c5ed..bc61485349dc 100644 --- a/kernel/fork.c +++ b/kernel/fork.c -@@ -664,7 +664,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, +@@ -665,7 +665,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, if (file) { struct address_space *mapping = file->f_mapping; @@ -185,10 +185,10 @@ index 8e105e5b3e29..7d7a0e74fc7d 100644 obj-$(CONFIG_SHRINKER_DEBUG) += shrinker_debug.o +obj-y += prfile.o diff --git a/mm/filemap.c b/mm/filemap.c -index 08341616ae7a..410ca60fbf39 100644 +index 322aea78058a..ff987ca36b1e 100644 --- a/mm/filemap.c +++ b/mm/filemap.c -@@ -3418,7 +3418,7 @@ vm_fault_t filemap_page_mkwrite(struct vm_fault *vmf) +@@ -3419,7 +3419,7 @@ vm_fault_t filemap_page_mkwrite(struct vm_fault *vmf) vm_fault_t ret = VM_FAULT_LOCKED; sb_start_pagefault(mapping->host->i_sb); @@ -198,7 +198,7 @@ index 08341616ae7a..410ca60fbf39 100644 if (folio->mapping != mapping) { folio_unlock(folio); diff --git a/mm/mmap.c b/mm/mmap.c -index 177714886849..113341dd964f 100644 +index 14ca259189b7..945f515ab10b 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -139,7 +139,7 @@ static void remove_vma(struct vm_area_struct *vma) @@ -228,7 +228,7 @@ index 177714886849..113341dd964f 100644 } if (next->anon_vma) anon_vma_merge(vma, next); -@@ -2228,7 +2228,7 @@ int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma, +@@ -2266,7 +2266,7 @@ int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma, goto out_free_mpol; if (new->vm_file) @@ -237,7 +237,7 @@ index 177714886849..113341dd964f 100644 if (new->vm_ops && new->vm_ops->open) new->vm_ops->open(new); -@@ -2250,7 +2250,7 @@ int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma, +@@ -2288,7 +2288,7 @@ int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma, if (new->vm_ops && new->vm_ops->close) new->vm_ops->close(new); if (new->vm_file) @@ -246,7 +246,7 @@ index 177714886849..113341dd964f 100644 unlink_anon_vmas(new); out_free_mpol: mpol_put(vma_policy(new)); -@@ -2750,7 +2750,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr, +@@ -2788,7 +2788,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr, if (vma->vm_ops && vma->vm_ops->close) vma->vm_ops->close(vma); unmap_and_free_vma: @@ -255,7 +255,7 @@ index 177714886849..113341dd964f 100644 vma->vm_file = NULL; /* Undo any partial mapping done by a device driver. */ -@@ -2817,6 +2817,9 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, +@@ -2855,6 +2855,9 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, unsigned long populate = 0; unsigned long ret = -EINVAL; struct file *file; @@ -265,7 +265,7 @@ index 177714886849..113341dd964f 100644 pr_warn_once("%s (%d) uses deprecated remap_file_pages() syscall. See Documentation/mm/remap_file_pages.rst.\n", current->comm, current->pid); -@@ -2875,10 +2878,34 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, +@@ -2913,10 +2916,34 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, if (vma->vm_flags & VM_LOCKED) flags |= MAP_LOCKED; @@ -300,7 +300,7 @@ index 177714886849..113341dd964f 100644 out: mmap_write_unlock(mm); if (populate) -@@ -3226,7 +3253,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap, +@@ -3265,7 +3292,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap, if (anon_vma_clone(new_vma, vma)) goto out_free_mempol; if (new_vma->vm_file) diff --git a/patches/external/aufs/0004-merge-aufs-standalone.patch b/patches/external/aufs/0004-merge-aufs-standalone.patch index be6bda2fbaaffa563e6d88b58768166b312b7538..2c7c06e2d066dc61628619f97fabd2e9ba022e2a 100644 --- a/patches/external/aufs/0004-merge-aufs-standalone.patch +++ b/patches/external/aufs/0004-merge-aufs-standalone.patch @@ -1,6 +1,6 @@ -From 0076c666e962ba51fa73ac8a784bc98e2e60ce8d Mon Sep 17 00:00:00 2001 +From 9ec995c921df2247387fc0be34500e23d0e5544b Mon Sep 17 00:00:00 2001 From: Robert Nelson <robertcnelson@gmail.com> -Date: Wed, 3 May 2023 15:33:07 -0500 +Date: Wed, 17 May 2023 16:50:38 -0500 Subject: [PATCH 4/5] merge: aufs-standalone Signed-off-by: Robert Nelson <robertcnelson@gmail.com> @@ -77,7 +77,7 @@ index dd88701e54a9..ecdb7817b074 100644 /* * Variant of alloc_empty_file() that doesn't check and modify nr_files. diff --git a/fs/namespace.c b/fs/namespace.c -index faae7f8644ac..0310c99a83dd 100644 +index f0a33f8f2162..f93c203173a8 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -456,6 +456,7 @@ void __mnt_drop_write(struct vfsmount *mnt) @@ -117,7 +117,7 @@ index 1de6631a3925..3008eb37a18d 100644 /* * Drop a reference to a group. Free it if it's through. diff --git a/fs/open.c b/fs/open.c -index a81319b6177f..50bb15ea3fb5 100644 +index 20717ec510c0..2fc6dc614f72 100644 --- a/fs/open.c +++ b/fs/open.c @@ -66,6 +66,7 @@ int do_truncate(struct user_namespace *mnt_userns, struct dentry *dentry, @@ -181,10 +181,10 @@ index 427b8cea1f96..6ad1281d9119 100644 ssize_t __vfs_getxattr(struct dentry *dentry, struct inode *inode, const char *name, diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c -index c1f0aadde539..278e0a322d20 100644 +index 36caa2ccf344..67085f2c8221 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c -@@ -238,6 +238,7 @@ inline struct lock_class *lockdep_hlock_class(struct held_lock *hlock) +@@ -239,6 +239,7 @@ inline struct lock_class *lockdep_hlock_class(struct held_lock *hlock) */ return lock_classes + class_idx; } @@ -202,7 +202,7 @@ index 065e1ef8fc8d..c623c6f0c645 100644 } +EXPORT_SYMBOL_GPL(task_work_run); diff --git a/security/security.c b/security/security.c -index 79d82cb6e469..1c50e6faadcd 100644 +index 75dc0947ee0c..547d4a886e36 100644 --- a/security/security.c +++ b/security/security.c @@ -1167,6 +1167,7 @@ int security_path_rmdir(const struct path *dir, struct dentry *dentry) diff --git a/patches/external/aufs/0005-merge-aufs.patch b/patches/external/aufs/0005-merge-aufs.patch index d340b0445490c86aa839e82c37dd0acef1402ccc..5c02a1213339d4bb23b6ba7e0c88c28fb2560a37 100644 --- a/patches/external/aufs/0005-merge-aufs.patch +++ b/patches/external/aufs/0005-merge-aufs.patch @@ -1,9 +1,9 @@ -From ebf666ad8b93d6662c24359147b343b3cebf3eaa Mon Sep 17 00:00:00 2001 +From b70a334da614e3265b2e808f079ed9ca3b793a05 Mon Sep 17 00:00:00 2001 From: Robert Nelson <robertcnelson@gmail.com> -Date: Wed, 3 May 2023 15:33:08 -0500 +Date: Wed, 17 May 2023 16:50:40 -0500 Subject: [PATCH 5/5] merge: aufs -https://github.com/sfjro/aufs-standalone/commit/2049a4559234e81aa4f112396cab2304d3522bda +https://github.com/sfjro/aufs-standalone/commit/80bbd686e8be627d87bfa0ede768c2a52843647f Signed-off-by: Robert Nelson <robertcnelson@gmail.com> --- Documentation/ABI/testing/debugfs-aufs | 55 + @@ -294,7 +294,7 @@ index 000000000000..48500c0569e6 + will be empty. About XINO files, see the aufs manual. diff --git a/Documentation/filesystems/aufs/README b/Documentation/filesystems/aufs/README new file mode 100644 -index 000000000000..ad9be09183f5 +index 000000000000..58cfd7b93922 --- /dev/null +++ b/Documentation/filesystems/aufs/README @@ -0,0 +1,408 @@ @@ -688,7 +688,7 @@ index 000000000000..ad9be09183f5 +James Burry made a donation (2016/12). +Carsten Rose made a donation (2018/9). +Porteus Kiosk made a donation (2018/10). -+Enya Quetzalli Gomez Rodriguez made a donation (2022/5). ++huronOS team: Enya Quetzalli made donations (2022/5 and 2023/5). + +Thank you very much. +Donations are always, including future donations, very important and @@ -38473,7 +38473,7 @@ index 000000000000..35f9291c8026 +} diff --git a/include/uapi/linux/aufs_type.h b/include/uapi/linux/aufs_type.h new file mode 100644 -index 000000000000..3c966520f776 +index 000000000000..255d99bc0877 --- /dev/null +++ b/include/uapi/linux/aufs_type.h @@ -0,0 +1,452 @@ @@ -38519,7 +38519,7 @@ index 000000000000..3c966520f776 +#include <limits.h> +#endif /* __KERNEL__ */ + -+#define AUFS_VERSION "6.1-20230227" ++#define AUFS_VERSION "6.1-20230515" + +/* todo? move this to linux-2.6.19/include/magic.h */ +#define AUFS_SUPER_MAGIC ('a' << 24 | 'u' << 16 | 'f' << 8 | 's') diff --git a/patches/external/bcfserial/0001-merge-bcfserial-https-git.beagleboard.org-beagleconn.patch b/patches/external/bcfserial/0001-merge-bcfserial-https-git.beagleboard.org-beagleconn.patch index 294d06bcf1c6bf81a7afa37e533af1e2ef4db83f..9731df7be0b2c6272bfd8b41d0609d9f2df8448d 100644 --- a/patches/external/bcfserial/0001-merge-bcfserial-https-git.beagleboard.org-beagleconn.patch +++ b/patches/external/bcfserial/0001-merge-bcfserial-https-git.beagleboard.org-beagleconn.patch @@ -1,6 +1,6 @@ -From 13b810928dbc9020f1feb9670ad433d3e442b428 Mon Sep 17 00:00:00 2001 +From e153d37d141d13a75e8bc0d33422b4df79a03613 Mon Sep 17 00:00:00 2001 From: Robert Nelson <robertcnelson@gmail.com> -Date: Wed, 3 May 2023 15:48:07 -0500 +Date: Wed, 17 May 2023 16:52:13 -0500 Subject: [PATCH] merge: bcfserial: https://git.beagleboard.org/beagleconnect/linux/bcfserial.git diff --git a/patches/external/git/AUFS b/patches/external/git/AUFS index b4ae3a30058d9d29d1364e5a8f68d3b84e77d3fb..f5c8443d9479cc8c730b8c36888862518bc3cf46 100644 --- a/patches/external/git/AUFS +++ b/patches/external/git/AUFS @@ -1 +1 @@ -AUFS: https://github.com/sfjro/aufs-standalone/commit/2049a4559234e81aa4f112396cab2304d3522bda +AUFS: https://github.com/sfjro/aufs-standalone/commit/80bbd686e8be627d87bfa0ede768c2a52843647f diff --git a/patches/external/git/BBDTBS b/patches/external/git/BBDTBS index a973cc9705d859a0e239d9d108972c70df1254b5..b4fdfc21fa6dbcc0ab3c7d97d23f6eee94290825 100644 --- a/patches/external/git/BBDTBS +++ b/patches/external/git/BBDTBS @@ -1 +1 @@ -BBDTBS: https://git.beagleboard.org/beagleboard/BeagleBoard-DeviceTrees/-/commit/b92841690e5994821c7882201880e50955278ecd +BBDTBS: https://git.beagleboard.org/beagleboard/BeagleBoard-DeviceTrees/-/commit/0e19df9ed0244271ac27cf9135dbdb453b97255d diff --git a/patches/external/git/KSMBD b/patches/external/git/KSMBD index 0e851d25dd95d05c4d535263e14bb9faaeb96450..229e7fd8c381c27674a576953cfd2acc832239b5 100644 --- a/patches/external/git/KSMBD +++ b/patches/external/git/KSMBD @@ -1 +1 @@ -KSMBD: https://github.com/cifsd-team/ksmbd/commit/274377cd20807ae91ac81f42ad2823d812289a31 +KSMBD: https://github.com/cifsd-team/ksmbd/commit/11aa06fbc7307b3ff68ebbdb96d42484d9b5ae6a diff --git a/patches/external/ksmbd/0001-merge-ksmbd-https-github.com-cifsd-team-ksmbd.patch b/patches/external/ksmbd/0001-merge-ksmbd-https-github.com-cifsd-team-ksmbd.patch index a6e622bbc799d7f91555f9538804fa9207e6b803..6993235c71cbf6fb0dbef6296f99e6bd221720af 100644 --- a/patches/external/ksmbd/0001-merge-ksmbd-https-github.com-cifsd-team-ksmbd.patch +++ b/patches/external/ksmbd/0001-merge-ksmbd-https-github.com-cifsd-team-ksmbd.patch @@ -1,20 +1,20 @@ -From f1db141dc4163f23a989fb4936e22972342cff27 Mon Sep 17 00:00:00 2001 +From 5b8ccf2ad5073ff04458f6a85123d1cb6ac0bbce Mon Sep 17 00:00:00 2001 From: Robert Nelson <robertcnelson@gmail.com> -Date: Wed, 3 May 2023 15:55:45 -0500 +Date: Wed, 17 May 2023 16:55:13 -0500 Subject: [PATCH] merge: ksmbd: https://github.com/cifsd-team/ksmbd -https://github.com/cifsd-team/ksmbd/commit/274377cd20807ae91ac81f42ad2823d812289a31 +https://github.com/cifsd-team/ksmbd/commit/11aa06fbc7307b3ff68ebbdb96d42484d9b5ae6a Signed-off-by: Robert Nelson <robertcnelson@gmail.com> --- fs/ksmbd/Kconfig | 11 + fs/ksmbd/Makefile | 63 +- fs/ksmbd/README.md | 170 + fs/ksmbd/asn1.c | 165 +- - fs/ksmbd/auth.c | 346 +- + fs/ksmbd/auth.c | 360 +- fs/ksmbd/auth.h | 16 +- fs/ksmbd/build_ksmbd.sh | 177 + - fs/ksmbd/connection.c | 46 +- - fs/ksmbd/connection.h | 3 +- + fs/ksmbd/connection.c | 101 +- + fs/ksmbd/connection.h | 58 +- fs/ksmbd/crypto_ctx.c | 16 + fs/ksmbd/crypto_ctx.h | 8 + fs/ksmbd/dkms.conf | 6 + @@ -24,39 +24,42 @@ Signed-off-by: Robert Nelson <robertcnelson@gmail.com> fs/ksmbd/ksmbd_work.h | 2 +- fs/ksmbd/mgmt/ksmbd_ida.c | 17 +- fs/ksmbd/mgmt/ksmbd_ida.h | 6 + - fs/ksmbd/mgmt/user_session.c | 112 +- - fs/ksmbd/mgmt/user_session.h | 12 +- + fs/ksmbd/mgmt/tree_connect.c | 20 +- + fs/ksmbd/mgmt/tree_connect.h | 6 +- + fs/ksmbd/mgmt/user_session.c | 198 +- + fs/ksmbd/mgmt/user_session.h | 13 +- fs/ksmbd/misc.c | 107 + - fs/ksmbd/ndr.c | 24 +- + fs/ksmbd/ndr.c | 36 +- + fs/ksmbd/ndr.h | 4 + fs/ksmbd/netmisc.c | 606 +++ fs/ksmbd/ntlmssp.h | 6 +- - fs/ksmbd/oplock.c | 293 +- - fs/ksmbd/oplock.h | 11 + - fs/ksmbd/server.c | 29 +- + fs/ksmbd/oplock.c | 368 +- + fs/ksmbd/oplock.h | 13 +- + fs/ksmbd/server.c | 47 +- fs/ksmbd/smb1misc.c | 297 ++ fs/ksmbd/smb1ops.c | 89 + fs/ksmbd/smb1pdu.c | 8516 ++++++++++++++++++++++++++++++++++ fs/ksmbd/smb1pdu.h | 1631 +++++++ - fs/ksmbd/smb2misc.c | 32 +- + fs/ksmbd/smb2misc.c | 6 +- fs/ksmbd/smb2ops.c | 69 +- - fs/ksmbd/smb2pdu.c | 473 +- - fs/ksmbd/smb2pdu.h | 1191 ++++- - fs/ksmbd/smb_common.c | 193 +- - fs/ksmbd/smb_common.h | 91 +- - fs/ksmbd/smbacl.c | 71 +- - fs/ksmbd/smbacl.h | 45 + + fs/ksmbd/smb2pdu.c | 819 +++- + fs/ksmbd/smb2pdu.h | 1193 ++++- + fs/ksmbd/smb_common.c | 66 +- + fs/ksmbd/smb_common.h | 77 +- + fs/ksmbd/smbacl.c | 212 +- + fs/ksmbd/smbacl.h | 69 + fs/ksmbd/smberr.h | 235 + fs/ksmbd/transport_ipc.c | 3 +- - fs/ksmbd/transport_rdma.c | 44 +- - fs/ksmbd/transport_tcp.c | 81 +- + fs/ksmbd/transport_rdma.c | 42 +- + fs/ksmbd/transport_tcp.c | 48 +- fs/ksmbd/unicode.c | 18 + fs/ksmbd/unicode.h | 3 + - fs/ksmbd/vfs.c | 1543 ++++-- - fs/ksmbd/vfs.h | 80 +- - fs/ksmbd/vfs_cache.c | 65 +- + fs/ksmbd/vfs.c | 1868 ++++++-- + fs/ksmbd/vfs.h | 150 +- + fs/ksmbd/vfs_cache.c | 68 +- fs/ksmbd/vfs_cache.h | 18 + fs/ksmbd/xattr.h | 2 +- - 50 files changed, 16331 insertions(+), 908 deletions(-) + 53 files changed, 17338 insertions(+), 958 deletions(-) create mode 100644 fs/ksmbd/README.md create mode 100755 fs/ksmbd/build_ksmbd.sh create mode 100644 fs/ksmbd/dkms.conf @@ -581,7 +584,7 @@ index c03eba090368..2276624e47ef 100644 + return ksmbd_neg_token_alloc(context, hdrlen, tag, value, vlen); } diff --git a/fs/ksmbd/auth.c b/fs/ksmbd/auth.c -index 6e61b5bc7d86..221f646828b7 100644 +index cead696b656a..0dbbc48c29d7 100644 --- a/fs/ksmbd/auth.c +++ b/fs/ksmbd/auth.c @@ -29,7 +29,6 @@ @@ -764,7 +767,53 @@ index 6e61b5bc7d86..221f646828b7 100644 /** * ksmbd_auth_ntlmv2() - NTLMv2 authentication handler * @sess: session of connection -@@ -287,6 +444,105 @@ int ksmbd_auth_ntlmv2(struct ksmbd_conn *conn, struct ksmbd_session *sess, +@@ -221,22 +378,22 @@ int ksmbd_auth_ntlmv2(struct ksmbd_conn *conn, struct ksmbd_session *sess, + { + char ntlmv2_hash[CIFS_ENCPWD_SIZE]; + char ntlmv2_rsp[CIFS_HMAC_MD5_HASH_SIZE]; +- struct ksmbd_crypto_ctx *ctx; ++ struct ksmbd_crypto_ctx *ctx = NULL; + char *construct = NULL; + int rc, len; + +- ctx = ksmbd_crypto_ctx_find_hmacmd5(); +- if (!ctx) { +- ksmbd_debug(AUTH, "could not crypto alloc hmacmd5\n"); +- return -ENOMEM; +- } +- + rc = calc_ntlmv2_hash(conn, sess, ntlmv2_hash, domain_name); + if (rc) { + ksmbd_debug(AUTH, "could not get v2 hash rc %d\n", rc); + goto out; + } + ++ ctx = ksmbd_crypto_ctx_find_hmacmd5(); ++ if (!ctx) { ++ ksmbd_debug(AUTH, "could not crypto alloc hmacmd5\n"); ++ return -ENOMEM; ++ } ++ + rc = crypto_shash_setkey(CRYPTO_HMACMD5_TFM(ctx), + ntlmv2_hash, + CIFS_HMAC_MD5_HASH_SIZE); +@@ -272,6 +429,8 @@ int ksmbd_auth_ntlmv2(struct ksmbd_conn *conn, struct ksmbd_session *sess, + ksmbd_debug(AUTH, "Could not generate md5 hash\n"); + goto out; + } ++ ksmbd_release_crypto_ctx(ctx); ++ ctx = NULL; + + rc = ksmbd_gen_sess_key(sess, ntlmv2_hash, ntlmv2_rsp); + if (rc) { +@@ -282,11 +441,111 @@ int ksmbd_auth_ntlmv2(struct ksmbd_conn *conn, struct ksmbd_session *sess, + if (memcmp(ntlmv2->ntlmv2_hash, ntlmv2_rsp, CIFS_HMAC_MD5_HASH_SIZE) != 0) + rc = -EINVAL; + out: +- ksmbd_release_crypto_ctx(ctx); ++ if (ctx) ++ ksmbd_release_crypto_ctx(ctx); + kfree(construct); return rc; } @@ -870,7 +919,7 @@ index 6e61b5bc7d86..221f646828b7 100644 /** * ksmbd_decode_ntlmssp_auth_blob() - helper function to construct * authenticate blob -@@ -303,6 +559,10 @@ int ksmbd_decode_ntlmssp_auth_blob(struct authenticate_message *authblob, +@@ -303,6 +562,10 @@ int ksmbd_decode_ntlmssp_auth_blob(struct authenticate_message *authblob, char *domain_name; unsigned int nt_off, dn_off; unsigned short nt_len, dn_len; @@ -881,7 +930,7 @@ index 6e61b5bc7d86..221f646828b7 100644 int ret; if (blob_len < sizeof(struct authenticate_message)) { -@@ -319,6 +579,7 @@ int ksmbd_decode_ntlmssp_auth_blob(struct authenticate_message *authblob, +@@ -319,6 +582,7 @@ int ksmbd_decode_ntlmssp_auth_blob(struct authenticate_message *authblob, nt_off = le32_to_cpu(authblob->NtChallengeResponse.BufferOffset); nt_len = le16_to_cpu(authblob->NtChallengeResponse.Length); @@ -889,7 +938,7 @@ index 6e61b5bc7d86..221f646828b7 100644 dn_off = le32_to_cpu(authblob->DomainName.BufferOffset); dn_len = le16_to_cpu(authblob->DomainName.Length); -@@ -326,6 +587,26 @@ int ksmbd_decode_ntlmssp_auth_blob(struct authenticate_message *authblob, +@@ -326,6 +590,26 @@ int ksmbd_decode_ntlmssp_auth_blob(struct authenticate_message *authblob, nt_len < CIFS_ENCPWD_SIZE) return -EINVAL; @@ -916,7 +965,7 @@ index 6e61b5bc7d86..221f646828b7 100644 /* TODO : use domain name that imported from configuration file */ domain_name = smb_strndup_from_utf16((const char *)authblob + dn_off, dn_len, true, conn->local_nls); -@@ -360,7 +641,12 @@ int ksmbd_decode_ntlmssp_auth_blob(struct authenticate_message *authblob, +@@ -360,7 +644,12 @@ int ksmbd_decode_ntlmssp_auth_blob(struct authenticate_message *authblob, SMB2_NTLMV2_SESSKEY_SIZE); cifs_arc4_crypt(ctx_arc4, sess->sess_key, (char *)authblob + sess_key_off, sess_key_len); @@ -929,7 +978,7 @@ index 6e61b5bc7d86..221f646828b7 100644 } return ret; -@@ -557,6 +843,59 @@ int ksmbd_krb5_authenticate(struct ksmbd_session *sess, char *in_blob, +@@ -557,6 +846,59 @@ int ksmbd_krb5_authenticate(struct ksmbd_session *sess, char *in_blob, } #endif @@ -989,18 +1038,6 @@ index 6e61b5bc7d86..221f646828b7 100644 /** * ksmbd_sign_smb2_pdu() - function to generate packet signing * @conn: connection -@@ -727,8 +1066,9 @@ static int generate_key(struct ksmbd_conn *conn, struct ksmbd_session *sess, - goto smb3signkey_ret; - } - -- if (conn->cipher_type == SMB2_ENCRYPTION_AES256_CCM || -- conn->cipher_type == SMB2_ENCRYPTION_AES256_GCM) -+ if (key_size == SMB3_ENC_DEC_KEY_SIZE && -+ (conn->cipher_type == SMB2_ENCRYPTION_AES256_CCM || -+ conn->cipher_type == SMB2_ENCRYPTION_AES256_GCM)) - rc = crypto_shash_update(CRYPTO_HMACSHA256(ctx), L256, 4); - else - rc = crypto_shash_update(CRYPTO_HMACSHA256(ctx), L128, 4); diff --git a/fs/ksmbd/auth.h b/fs/ksmbd/auth.h index 362b6159a6cf..caba4341988b 100644 --- a/fs/ksmbd/auth.h @@ -1224,7 +1261,7 @@ index 000000000000..4b10f0417d84 + +main $1 diff --git a/fs/ksmbd/connection.c b/fs/ksmbd/connection.c -index 56be077e5d8a..b152854fe3ed 100644 +index b8f9d627f241..4b9665f104aa 100644 --- a/fs/ksmbd/connection.c +++ b/fs/ksmbd/connection.c @@ -10,6 +10,9 @@ @@ -1237,7 +1274,34 @@ index 56be077e5d8a..b152854fe3ed 100644 #include "mgmt/ksmbd_ida.h" #include "connection.h" #include "transport_tcp.h" -@@ -61,7 +64,11 @@ struct ksmbd_conn *ksmbd_conn_alloc(void) +@@ -20,7 +23,7 @@ static DEFINE_MUTEX(init_lock); + static struct ksmbd_conn_ops default_conn_ops; + + LIST_HEAD(conn_list); +-DEFINE_RWLOCK(conn_list_lock); ++DECLARE_RWSEM(conn_list_lock); + + /** + * ksmbd_conn_free() - free resources of the connection instance +@@ -32,9 +35,9 @@ DEFINE_RWLOCK(conn_list_lock); + */ + void ksmbd_conn_free(struct ksmbd_conn *conn) + { +- write_lock(&conn_list_lock); ++ down_write(&conn_list_lock); + list_del(&conn->conns_list); +- write_unlock(&conn_list_lock); ++ up_write(&conn_list_lock); + + xa_destroy(&conn->sessions); + kvfree(conn->request_buf); +@@ -56,12 +59,16 @@ struct ksmbd_conn *ksmbd_conn_alloc(void) + return NULL; + + conn->need_neg = true; +- conn->status = KSMBD_SESS_NEW; ++ ksmbd_conn_set_new(conn); + conn->local_nls = load_nls("utf8"); if (!conn->local_nls) conn->local_nls = load_nls_default(); if (IS_ENABLED(CONFIG_UNICODE)) @@ -1249,6 +1313,36 @@ index 56be077e5d8a..b152854fe3ed 100644 else conn->um = ERR_PTR(-EOPNOTSUPP); if (IS_ERR(conn->um)) +@@ -84,9 +91,9 @@ struct ksmbd_conn *ksmbd_conn_alloc(void) + spin_lock_init(&conn->llist_lock); + INIT_LIST_HEAD(&conn->lock_list); + +- write_lock(&conn_list_lock); ++ down_write(&conn_list_lock); + list_add(&conn->conns_list, &conn_list); +- write_unlock(&conn_list_lock); ++ up_write(&conn_list_lock); + return conn; + } + +@@ -95,7 +102,7 @@ bool ksmbd_conn_lookup_dialect(struct ksmbd_conn *c) + struct ksmbd_conn *t; + bool ret = false; + +- read_lock(&conn_list_lock); ++ down_read(&conn_list_lock); + list_for_each_entry(t, &conn_list, conns_list) { + if (memcmp(t->ClientGUID, c->ClientGUID, SMB2_CLIENT_GUID_SIZE)) + continue; +@@ -103,7 +110,7 @@ bool ksmbd_conn_lookup_dialect(struct ksmbd_conn *c) + ret = true; + break; + } +- read_unlock(&conn_list_lock); ++ up_read(&conn_list_lock); + return ret; + } + @@ -111,11 +118,20 @@ void ksmbd_conn_enqueue_request(struct ksmbd_work *work) { struct ksmbd_conn *conn = work->conn; @@ -1273,7 +1367,7 @@ index 56be077e5d8a..b152854fe3ed 100644 if (requests_queue) { atomic_inc(&conn->req_running); -@@ -136,14 +152,14 @@ int ksmbd_conn_try_dequeue_request(struct ksmbd_work *work) +@@ -136,32 +152,60 @@ int ksmbd_conn_try_dequeue_request(struct ksmbd_work *work) if (!work->multiRsp) atomic_dec(&conn->req_running); @@ -1292,62 +1386,245 @@ index 56be077e5d8a..b152854fe3ed 100644 wake_up_all(&conn->req_running_q); return ret; -@@ -298,7 +314,7 @@ int ksmbd_conn_handler_loop(void *p) - kvfree(conn->request_buf); - conn->request_buf = NULL; + } -- size = t->ops->read(t, hdr_buf, sizeof(hdr_buf)); -+ size = t->ops->read(t, hdr_buf, sizeof(hdr_buf), -1); - if (size != sizeof(hdr_buf)) - break; +-static void ksmbd_conn_lock(struct ksmbd_conn *conn) ++void ksmbd_conn_lock(struct ksmbd_conn *conn) + { + mutex_lock(&conn->srv_mutex); + } + +-static void ksmbd_conn_unlock(struct ksmbd_conn *conn) ++void ksmbd_conn_unlock(struct ksmbd_conn *conn) + { + mutex_unlock(&conn->srv_mutex); + } + +-void ksmbd_conn_wait_idle(struct ksmbd_conn *conn) ++void ksmbd_all_conn_set_status(u64 sess_id, u32 status) + { ++ struct ksmbd_conn *conn; ++ ++ down_read(&conn_list_lock); ++ list_for_each_entry(conn, &conn_list, conns_list) { ++ if (conn->binding || xa_load(&conn->sessions, sess_id)) ++ WRITE_ONCE(conn->status, status); ++ } ++ up_read(&conn_list_lock); ++} ++ ++void ksmbd_conn_wait_idle(struct ksmbd_conn *conn, u64 sess_id) ++{ ++ struct ksmbd_conn *bind_conn; ++ + wait_event(conn->req_running_q, atomic_read(&conn->req_running) < 2); ++ ++ down_read(&conn_list_lock); ++ list_for_each_entry(bind_conn, &conn_list, conns_list) { ++ if (bind_conn == conn) ++ continue; ++ ++ if ((bind_conn->binding || xa_load(&bind_conn->sessions, sess_id)) && ++ !ksmbd_conn_releasing(bind_conn) && ++ atomic_read(&bind_conn->req_running)) { ++ wait_event(bind_conn->req_running_q, ++ atomic_read(&bind_conn->req_running) == 0); ++ } ++ } ++ up_read(&conn_list_lock); + } + + int ksmbd_conn_write(struct ksmbd_work *work) +@@ -245,7 +289,7 @@ bool ksmbd_conn_alive(struct ksmbd_conn *conn) + if (!ksmbd_server_running()) + return false; -@@ -319,20 +335,14 @@ int ksmbd_conn_handler_loop(void *p) +- if (conn->status == KSMBD_SESS_EXITING) ++ if (ksmbd_conn_exiting(conn)) + return false; + + if (kthread_should_stop()) +@@ -305,7 +349,7 @@ int ksmbd_conn_handler_loop(void *p) + pdu_size = get_rfc1002_len(hdr_buf); + ksmbd_debug(CONN, "RFC1002 header %u bytes\n", pdu_size); + +- if (conn->status == KSMBD_SESS_GOOD) ++ if (ksmbd_conn_good(conn)) + max_allowed_pdu_size = + SMB3_MAX_MSGSIZE + conn->vals->max_write_size; + else +@@ -314,7 +358,7 @@ int ksmbd_conn_handler_loop(void *p) + if (pdu_size > max_allowed_pdu_size) { + pr_err_ratelimited("PDU length(%u) excceed maximum allowed pdu size(%u) on connection(%d)\n", + pdu_size, max_allowed_pdu_size, +- conn->status); ++ READ_ONCE(conn->status)); + break; } - /* -- * Check if pdu size is valid (min : smb header size, -- * max : 0x00FFFFFF). -+ * Check maximum pdu size(0x00FFFFFF). - */ -- if (pdu_size < __SMB2_HEADER_STRUCTURE_SIZE || -- pdu_size > MAX_STREAM_PROT_LEN) { -+ if (pdu_size > MAX_STREAM_PROT_LEN) +@@ -325,7 +369,8 @@ int ksmbd_conn_handler_loop(void *p) break; -- } /* 4 for rfc1002 length field */ - size = pdu_size + 4; -- conn->request_buf = kvmalloc(size, -- GFP_KERNEL | -- __GFP_NOWARN | -- __GFP_NORETRY); -+ conn->request_buf = kvmalloc(size, GFP_KERNEL); +- size = pdu_size + 4; ++ /* 1 for implied bcc[0] */ ++ size = pdu_size + 4 + 1; + conn->request_buf = kvmalloc(size, GFP_KERNEL); if (!conn->request_buf) break; +@@ -362,10 +407,10 @@ int ksmbd_conn_handler_loop(void *p) + } -@@ -344,7 +354,7 @@ int ksmbd_conn_handler_loop(void *p) - * We already read 4 bytes to find out PDU size, now - * read in PDU - */ -- size = t->ops->read(t, conn->request_buf + 4, pdu_size); -+ size = t->ops->read(t, conn->request_buf + 4, pdu_size, 2); - if (size < 0) { - pr_err("sock_read failed: %d\n", size); - break; + out: ++ ksmbd_conn_set_releasing(conn); + /* Wait till all reference dropped to the Server object*/ + wait_event(conn->r_count_q, atomic_read(&conn->r_count) == 0); + +- + if (IS_ENABLED(CONFIG_UNICODE)) + utf8_unload(conn->um); + unload_nls(conn->local_nls); +@@ -409,7 +454,7 @@ static void stop_sessions(void) + struct ksmbd_transport *t; + + again: +- read_lock(&conn_list_lock); ++ down_read(&conn_list_lock); + list_for_each_entry(conn, &conn_list, conns_list) { + struct task_struct *task; + +@@ -418,14 +463,14 @@ static void stop_sessions(void) + if (task) + ksmbd_debug(CONN, "Stop session handler %s/%d\n", + task->comm, task_pid_nr(task)); +- conn->status = KSMBD_SESS_EXITING; ++ ksmbd_conn_set_exiting(conn); + if (t->ops->shutdown) { +- read_unlock(&conn_list_lock); ++ up_read(&conn_list_lock); + t->ops->shutdown(t); +- read_lock(&conn_list_lock); ++ down_read(&conn_list_lock); + } + } +- read_unlock(&conn_list_lock); ++ up_read(&conn_list_lock); + + if (!list_empty(&conn_list)) { + schedule_timeout_interruptible(HZ / 10); /* 100ms */ diff --git a/fs/ksmbd/connection.h b/fs/ksmbd/connection.h -index 3643354a3fa7..0e3a848defaf 100644 +index 0e3a848defaf..ad8dfaa48ffb 100644 --- a/fs/ksmbd/connection.h +++ b/fs/ksmbd/connection.h -@@ -114,7 +114,8 @@ struct ksmbd_transport_ops { - int (*prepare)(struct ksmbd_transport *t); - void (*disconnect)(struct ksmbd_transport *t); - void (*shutdown)(struct ksmbd_transport *t); -- int (*read)(struct ksmbd_transport *t, char *buf, unsigned int size); -+ int (*read)(struct ksmbd_transport *t, char *buf, -+ unsigned int size, int max_retries); - int (*writev)(struct ksmbd_transport *t, struct kvec *iovs, int niov, - int size, bool need_invalidate_rkey, - unsigned int remote_key); +@@ -26,7 +26,8 @@ enum { + KSMBD_SESS_GOOD, + KSMBD_SESS_EXITING, + KSMBD_SESS_NEED_RECONNECT, +- KSMBD_SESS_NEED_NEGOTIATE ++ KSMBD_SESS_NEED_NEGOTIATE, ++ KSMBD_SESS_RELEASING + }; + + struct ksmbd_stats { +@@ -140,10 +141,10 @@ struct ksmbd_transport { + #define KSMBD_TCP_PEER_SOCKADDR(c) ((struct sockaddr *)&((c)->peer_addr)) + + extern struct list_head conn_list; +-extern rwlock_t conn_list_lock; ++extern struct rw_semaphore conn_list_lock; + + bool ksmbd_conn_alive(struct ksmbd_conn *conn); +-void ksmbd_conn_wait_idle(struct ksmbd_conn *conn); ++void ksmbd_conn_wait_idle(struct ksmbd_conn *conn, u64 sess_id); + struct ksmbd_conn *ksmbd_conn_alloc(void); + void ksmbd_conn_free(struct ksmbd_conn *conn); + bool ksmbd_conn_lookup_dialect(struct ksmbd_conn *c); +@@ -162,6 +163,8 @@ void ksmbd_conn_init_server_callbacks(struct ksmbd_conn_ops *ops); + int ksmbd_conn_handler_loop(void *p); + int ksmbd_conn_transport_init(void); + void ksmbd_conn_transport_destroy(void); ++void ksmbd_conn_lock(struct ksmbd_conn *conn); ++void ksmbd_conn_unlock(struct ksmbd_conn *conn); + + /* + * WARNING +@@ -169,43 +172,60 @@ void ksmbd_conn_transport_destroy(void); + * This is a hack. We will move status to a proper place once we land + * a multi-sessions support. + */ +-static inline bool ksmbd_conn_good(struct ksmbd_work *work) ++static inline bool ksmbd_conn_good(struct ksmbd_conn *conn) + { +- return work->conn->status == KSMBD_SESS_GOOD; ++ return READ_ONCE(conn->status) == KSMBD_SESS_GOOD; + } + +-static inline bool ksmbd_conn_need_negotiate(struct ksmbd_work *work) ++static inline bool ksmbd_conn_need_negotiate(struct ksmbd_conn *conn) + { +- return work->conn->status == KSMBD_SESS_NEED_NEGOTIATE; ++ return READ_ONCE(conn->status) == KSMBD_SESS_NEED_NEGOTIATE; + } + +-static inline bool ksmbd_conn_need_reconnect(struct ksmbd_work *work) ++static inline bool ksmbd_conn_need_reconnect(struct ksmbd_conn *conn) + { +- return work->conn->status == KSMBD_SESS_NEED_RECONNECT; ++ return READ_ONCE(conn->status) == KSMBD_SESS_NEED_RECONNECT; + } + +-static inline bool ksmbd_conn_exiting(struct ksmbd_work *work) ++static inline bool ksmbd_conn_exiting(struct ksmbd_conn *conn) + { +- return work->conn->status == KSMBD_SESS_EXITING; ++ return READ_ONCE(conn->status) == KSMBD_SESS_EXITING; + } + +-static inline void ksmbd_conn_set_good(struct ksmbd_work *work) ++static inline bool ksmbd_conn_releasing(struct ksmbd_conn *conn) + { +- work->conn->status = KSMBD_SESS_GOOD; ++ return READ_ONCE(conn->status) == KSMBD_SESS_RELEASING; + } + +-static inline void ksmbd_conn_set_need_negotiate(struct ksmbd_work *work) ++static inline void ksmbd_conn_set_new(struct ksmbd_conn *conn) + { +- work->conn->status = KSMBD_SESS_NEED_NEGOTIATE; ++ WRITE_ONCE(conn->status, KSMBD_SESS_NEW); + } + +-static inline void ksmbd_conn_set_need_reconnect(struct ksmbd_work *work) ++static inline void ksmbd_conn_set_good(struct ksmbd_conn *conn) + { +- work->conn->status = KSMBD_SESS_NEED_RECONNECT; ++ WRITE_ONCE(conn->status, KSMBD_SESS_GOOD); + } + +-static inline void ksmbd_conn_set_exiting(struct ksmbd_work *work) ++static inline void ksmbd_conn_set_need_negotiate(struct ksmbd_conn *conn) + { +- work->conn->status = KSMBD_SESS_EXITING; ++ WRITE_ONCE(conn->status, KSMBD_SESS_NEED_NEGOTIATE); + } ++ ++static inline void ksmbd_conn_set_need_reconnect(struct ksmbd_conn *conn) ++{ ++ WRITE_ONCE(conn->status, KSMBD_SESS_NEED_RECONNECT); ++} ++ ++static inline void ksmbd_conn_set_exiting(struct ksmbd_conn *conn) ++{ ++ WRITE_ONCE(conn->status, KSMBD_SESS_EXITING); ++} ++ ++static inline void ksmbd_conn_set_releasing(struct ksmbd_conn *conn) ++{ ++ WRITE_ONCE(conn->status, KSMBD_SESS_RELEASING); ++} ++ ++void ksmbd_all_conn_set_status(u64 sess_id, u32 status); + #endif /* __CONNECTION_H__ */ diff --git a/fs/ksmbd/crypto_ctx.c b/fs/ksmbd/crypto_ctx.c index 81488d04199d..5f4b1008d17e 100644 --- a/fs/ksmbd/crypto_ctx.c @@ -1741,8 +2018,79 @@ index 2bc07b16cfde..e7df7786f431 100644 int ksmbd_acquire_smb2_uid(struct ida *ida); int ksmbd_acquire_async_msg_id(struct ida *ida); +diff --git a/fs/ksmbd/mgmt/tree_connect.c b/fs/ksmbd/mgmt/tree_connect.c +index 8ce17b3fb8da..408cddf2f094 100644 +--- a/fs/ksmbd/mgmt/tree_connect.c ++++ b/fs/ksmbd/mgmt/tree_connect.c +@@ -109,18 +109,15 @@ int ksmbd_tree_conn_disconnect(struct ksmbd_session *sess, + struct ksmbd_tree_connect *ksmbd_tree_conn_lookup(struct ksmbd_session *sess, + unsigned int id) + { +- return xa_load(&sess->tree_conns, id); +-} ++ struct ksmbd_tree_connect *tcon; + +-struct ksmbd_share_config *ksmbd_tree_conn_share(struct ksmbd_session *sess, +- unsigned int id) +-{ +- struct ksmbd_tree_connect *tc; ++ tcon = xa_load(&sess->tree_conns, id); ++ if (tcon) { ++ if (test_bit(TREE_CONN_EXPIRE, &tcon->status)) ++ tcon = NULL; ++ } + +- tc = ksmbd_tree_conn_lookup(sess, id); +- if (tc) +- return tc->share_conf; +- return NULL; ++ return tcon; + } + + int ksmbd_tree_conn_session_logoff(struct ksmbd_session *sess) +@@ -129,6 +126,9 @@ int ksmbd_tree_conn_session_logoff(struct ksmbd_session *sess) + struct ksmbd_tree_connect *tc; + unsigned long id; + ++ if (!sess) ++ return -EINVAL; ++ + xa_for_each(&sess->tree_conns, id, tc) + ret |= ksmbd_tree_conn_disconnect(sess, tc); + xa_destroy(&sess->tree_conns); +diff --git a/fs/ksmbd/mgmt/tree_connect.h b/fs/ksmbd/mgmt/tree_connect.h +index 0f97ddc1e39c..562d647ad9fa 100644 +--- a/fs/ksmbd/mgmt/tree_connect.h ++++ b/fs/ksmbd/mgmt/tree_connect.h +@@ -14,6 +14,8 @@ struct ksmbd_share_config; + struct ksmbd_user; + struct ksmbd_conn; + ++#define TREE_CONN_EXPIRE 1 ++ + struct ksmbd_tree_connect { + int id; + +@@ -25,6 +27,7 @@ struct ksmbd_tree_connect { + + int maximal_access; + bool posix_extensions; ++ unsigned long status; + }; + + struct ksmbd_tree_conn_status { +@@ -50,9 +53,6 @@ int ksmbd_tree_conn_disconnect(struct ksmbd_session *sess, + struct ksmbd_tree_connect *ksmbd_tree_conn_lookup(struct ksmbd_session *sess, + unsigned int id); + +-struct ksmbd_share_config *ksmbd_tree_conn_share(struct ksmbd_session *sess, +- unsigned int id); +- + int ksmbd_tree_conn_session_logoff(struct ksmbd_session *sess); + + #endif /* __TREE_CONNECT_MANAGEMENT_H__ */ diff --git a/fs/ksmbd/mgmt/user_session.c b/fs/ksmbd/mgmt/user_session.c -index 92b1603b5abe..50497e78bbe3 100644 +index 92b1603b5abe..25fb3ee32488 100644 --- a/fs/ksmbd/mgmt/user_session.c +++ b/fs/ksmbd/mgmt/user_session.c @@ -25,20 +25,19 @@ static DECLARE_RWSEM(sessions_table_lock); @@ -1850,25 +2198,62 @@ index 92b1603b5abe..50497e78bbe3 100644 } void ksmbd_session_destroy(struct ksmbd_session *sess) -@@ -153,9 +144,17 @@ void ksmbd_session_destroy(struct ksmbd_session *sess) +@@ -153,10 +144,6 @@ void ksmbd_session_destroy(struct ksmbd_session *sess) if (!sess) return; +- down_write(&sessions_table_lock); +- hash_del(&sess->hlist); +- up_write(&sessions_table_lock); +- + if (sess->user) + ksmbd_free_user(sess->user); + +@@ -174,76 +161,116 @@ static struct ksmbd_session *__session_lookup(unsigned long long id) + struct ksmbd_session *sess; + + hash_for_each_possible(sessions_table, sess, hlist, id) { +- if (id == sess->id) ++ if (id == sess->id) { ++ sess->last_active = jiffies; + return sess; ++ } + } + return NULL; + } + ++static void ksmbd_expire_session(struct ksmbd_conn *conn) ++{ ++ unsigned long id; ++ struct ksmbd_session *sess; ++ ++ down_write(&sessions_table_lock); ++ xa_for_each(&conn->sessions, id, sess) { ++ if (sess->state != SMB2_SESSION_VALID || ++ time_after(jiffies, ++ sess->last_active + SMB2_SESSION_TIMEOUT)) { ++ xa_erase(&conn->sessions, sess->id); +#ifdef CONFIG_SMB_INSECURE_SERVER -+ if (hash_hashed(&sess->hlist)) { -+ down_write(&sessions_table_lock); -+ hash_del(&sess->hlist); -+ up_write(&sessions_table_lock); -+ } ++ if (hash_hashed(&sess->hlist)) ++ hash_del(&sess->hlist); +#else - down_write(&sessions_table_lock); - hash_del(&sess->hlist); - up_write(&sessions_table_lock); ++ hash_del(&sess->hlist); +#endif - - if (sess->user) - ksmbd_free_user(sess->user); -@@ -190,21 +189,15 @@ int ksmbd_session_register(struct ksmbd_conn *conn, ++ ksmbd_session_destroy(sess); ++ continue; ++ } ++ } ++ up_write(&sessions_table_lock); ++} ++ + int ksmbd_session_register(struct ksmbd_conn *conn, + struct ksmbd_session *sess) + { + sess->dialect = conn->dialect; + memcpy(sess->ClientGUID, conn->ClientGUID, SMB2_CLIENT_GUID_SIZE); ++ ksmbd_expire_session(conn); + return xa_err(xa_store(&conn->sessions, sess->id, sess, GFP_KERNEL)); + } static int ksmbd_chann_del(struct ksmbd_conn *conn, struct ksmbd_session *sess) { @@ -1893,21 +2278,99 @@ index 92b1603b5abe..50497e78bbe3 100644 - return -ENOENT; + kfree(chann); -+ + return 0; } void ksmbd_sessions_deregister(struct ksmbd_conn *conn) -@@ -234,7 +227,7 @@ void ksmbd_sessions_deregister(struct ksmbd_conn *conn) - return; + { + struct ksmbd_session *sess; ++ unsigned long id; + ++ down_write(&sessions_table_lock); + if (conn->binding) { + int bkt; +- +- down_write(&sessions_table_lock); +- hash_for_each(sessions_table, bkt, sess, hlist) { +- if (!ksmbd_chann_del(conn, sess)) { +- up_write(&sessions_table_lock); +- goto sess_destroy; ++ struct hlist_node *tmp; ++ ++ hash_for_each_safe(sessions_table, bkt, tmp, sess, hlist) { ++ if (!ksmbd_chann_del(conn, sess) && ++ xa_empty(&sess->ksmbd_chann_list)) { ++#ifdef CONFIG_SMB_INSECURE_SERVER ++ if (hash_hashed(&sess->hlist)) ++ hash_del(&sess->hlist); ++#else ++ hash_del(&sess->hlist); ++#endif ++ ksmbd_session_destroy(sess); + } + } +- up_write(&sessions_table_lock); +- } else { +- unsigned long id; +- +- xa_for_each(&conn->sessions, id, sess) { +- if (!ksmbd_chann_del(conn, sess)) +- goto sess_destroy; +- } + } - sess_destroy: +- return; ++ xa_for_each(&conn->sessions, id, sess) { ++ unsigned long chann_id; ++ struct channel *chann; + +-sess_destroy: - if (list_empty(&sess->ksmbd_chann_list)) { -+ if (xa_empty(&sess->ksmbd_chann_list)) { - xa_erase(&conn->sessions, sess->id); - ksmbd_session_destroy(sess); +- xa_erase(&conn->sessions, sess->id); +- ksmbd_session_destroy(sess); ++ xa_for_each(&sess->ksmbd_chann_list, chann_id, chann) { ++ if (chann->conn != conn) ++ ksmbd_conn_set_exiting(chann->conn); ++ } ++ ++ ksmbd_chann_del(conn, sess); ++ if (xa_empty(&sess->ksmbd_chann_list)) { ++ xa_erase(&conn->sessions, sess->id); ++#ifdef CONFIG_SMB_INSECURE_SERVER ++ if (hash_hashed(&sess->hlist)) ++ hash_del(&sess->hlist); ++#else ++ hash_del(&sess->hlist); ++#endif ++ ksmbd_session_destroy(sess); ++ } } -@@ -305,6 +298,18 @@ struct preauth_session *ksmbd_preauth_session_lookup(struct ksmbd_conn *conn, ++ up_write(&sessions_table_lock); + } + + struct ksmbd_session *ksmbd_session_lookup(struct ksmbd_conn *conn, + unsigned long long id) + { +- return xa_load(&conn->sessions, id); ++ struct ksmbd_session *sess; ++ ++ sess = xa_load(&conn->sessions, id); ++ if (sess) ++ sess->last_active = jiffies; ++ return sess; + } + + struct ksmbd_session *ksmbd_session_lookup_slowpath(unsigned long long id) +@@ -252,6 +279,8 @@ struct ksmbd_session *ksmbd_session_lookup_slowpath(unsigned long long id) + + down_read(&sessions_table_lock); + sess = __session_lookup(id); ++ if (sess) ++ sess->last_active = jiffies; + up_read(&sessions_table_lock); + + return sess; +@@ -305,6 +334,18 @@ struct preauth_session *ksmbd_preauth_session_lookup(struct ksmbd_conn *conn, return NULL; } @@ -1926,8 +2389,12 @@ index 92b1603b5abe..50497e78bbe3 100644 static int __init_smb2_session(struct ksmbd_session *sess) { int id = ksmbd_acquire_smb2_uid(&session_ida); -@@ -329,12 +334,16 @@ static struct ksmbd_session *__session_create(int protocol) +@@ -327,14 +368,20 @@ static struct ksmbd_session *__session_create(int protocol) + if (ksmbd_init_file_table(&sess->file_table)) + goto error; ++ sess->last_active = jiffies; ++ sess->state = SMB2_SESSION_IN_PROGRESS; set_session_flag(sess, protocol); xa_init(&sess->tree_conns); - INIT_LIST_HEAD(&sess->ksmbd_chann_list); @@ -1946,7 +2413,7 @@ index 92b1603b5abe..50497e78bbe3 100644 case CIFDS_SESSION_FLAG_SMB2: ret = __init_smb2_session(sess); break; -@@ -360,6 +369,13 @@ static struct ksmbd_session *__session_create(int protocol) +@@ -360,6 +407,13 @@ static struct ksmbd_session *__session_create(int protocol) return NULL; } @@ -1960,7 +2427,7 @@ index 92b1603b5abe..50497e78bbe3 100644 struct ksmbd_session *ksmbd_smb2_session_create(void) { return __session_create(CIFDS_SESSION_FLAG_SMB2); -@@ -369,6 +385,10 @@ int ksmbd_acquire_tree_conn_id(struct ksmbd_session *sess) +@@ -369,6 +423,10 @@ int ksmbd_acquire_tree_conn_id(struct ksmbd_session *sess) { int id = -EINVAL; @@ -1972,7 +2439,7 @@ index 92b1603b5abe..50497e78bbe3 100644 id = ksmbd_acquire_smb2_tid(&sess->tree_conn_ida); diff --git a/fs/ksmbd/mgmt/user_session.h b/fs/ksmbd/mgmt/user_session.h -index 8934b8ee275b..e9e6162bdb3f 100644 +index 8934b8ee275b..bbe28be40feb 100644 --- a/fs/ksmbd/mgmt/user_session.h +++ b/fs/ksmbd/mgmt/user_session.h @@ -12,6 +12,9 @@ @@ -1993,7 +2460,7 @@ index 8934b8ee275b..e9e6162bdb3f 100644 }; struct preauth_session { -@@ -50,11 +52,10 @@ struct ksmbd_session { +@@ -50,17 +52,17 @@ struct ksmbd_session { char sess_key[CIFS_KEY_SIZE]; struct hlist_node hlist; @@ -2007,7 +2474,14 @@ index 8934b8ee275b..e9e6162bdb3f 100644 __u8 smb3encryptionkey[SMB3_ENC_DEC_KEY_SIZE]; __u8 smb3decryptionkey[SMB3_ENC_DEC_KEY_SIZE]; -@@ -78,6 +79,9 @@ static inline void clear_session_flag(struct ksmbd_session *sess, int bit) + __u8 smb3signingkey[SMB3_SIGN_KEY_SIZE]; + + struct ksmbd_file_table file_table; ++ unsigned long last_active; + }; + + static inline int test_session_flag(struct ksmbd_session *sess, int bit) +@@ -78,6 +80,9 @@ static inline void clear_session_flag(struct ksmbd_session *sess, int bit) sess->flags &= ~bit; } @@ -2150,7 +2624,7 @@ index 9e8afaa686e3..88b39e3b400e 100644 char *ksmbd_convert_dir_info_name(struct ksmbd_dir_info *d_info, const struct nls_table *local_nls, diff --git a/fs/ksmbd/ndr.c b/fs/ksmbd/ndr.c -index 4d9e0b54e3db..66685393a810 100644 +index 4d9e0b54e3db..16303392a043 100644 --- a/fs/ksmbd/ndr.c +++ b/fs/ksmbd/ndr.c @@ -229,8 +229,7 @@ int ndr_encode_dos_attr(struct ndr *n, struct xattr_dos_attrib *da) @@ -2163,7 +2637,18 @@ index 4d9e0b54e3db..66685393a810 100644 n->offset = 0; ret = ndr_read_string(n, hex_attr, sizeof(hex_attr)); -@@ -345,8 +344,10 @@ int ndr_encode_posix_acl(struct ndr *n, +@@ -338,15 +337,21 @@ static int ndr_encode_posix_acl_entry(struct ndr *n, struct xattr_smb_acl *acl) + } + + int ndr_encode_posix_acl(struct ndr *n, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap, ++#else + struct user_namespace *user_ns, ++#endif + struct inode *inode, + struct xattr_smb_acl *acl, + struct xattr_smb_acl *def_acl) { unsigned int ref_id = 0x00020000; int ret; @@ -2174,13 +2659,17 @@ index 4d9e0b54e3db..66685393a810 100644 n->offset = 0; n->length = 1024; -@@ -374,14 +375,33 @@ int ndr_encode_posix_acl(struct ndr *n, +@@ -374,14 +379,41 @@ int ndr_encode_posix_acl(struct ndr *n, if (ret) return ret; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ vfsuid = i_uid_into_vfsuid(idmap, inode); ++#else vfsuid = i_uid_into_vfsuid(user_ns, inode); ++#endif ret = ndr_write_int64(n, from_kuid(&init_user_ns, vfsuid_into_kuid(vfsuid))); +#else + ret = ndr_write_int64(n, from_kuid(&init_user_ns, i_uid_into_mnt(user_ns, inode))); @@ -2189,7 +2678,11 @@ index 4d9e0b54e3db..66685393a810 100644 return ret; + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ vfsgid = i_gid_into_vfsgid(idmap, inode); ++#else vfsgid = i_gid_into_vfsgid(user_ns, inode); ++#endif ret = ndr_write_int64(n, from_kgid(&init_user_ns, vfsgid_into_kgid(vfsgid))); +#else + ret = ndr_write_int64(n, from_kgid(&init_user_ns, i_gid_into_mnt(user_ns, inode))); @@ -2208,6 +2701,22 @@ index 4d9e0b54e3db..66685393a810 100644 ret = ndr_write_int32(n, inode->i_mode); if (ret) return ret; +diff --git a/fs/ksmbd/ndr.h b/fs/ksmbd/ndr.h +index 60ca265d1bb0..a300c0f6c814 100644 +--- a/fs/ksmbd/ndr.h ++++ b/fs/ksmbd/ndr.h +@@ -14,7 +14,11 @@ struct ndr { + + int ndr_encode_dos_attr(struct ndr *n, struct xattr_dos_attrib *da); + int ndr_decode_dos_attr(struct ndr *n, struct xattr_dos_attrib *da); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ndr_encode_posix_acl(struct ndr *n, struct mnt_idmap *idmap, ++#else + int ndr_encode_posix_acl(struct ndr *n, struct user_namespace *user_ns, ++#endif + struct inode *inode, struct xattr_smb_acl *acl, + struct xattr_smb_acl *def_acl); + int ndr_encode_v4_ntacl(struct ndr *n, struct xattr_ntacl *acl); diff --git a/fs/ksmbd/netmisc.c b/fs/ksmbd/netmisc.c new file mode 100644 index 000000000000..155c15a94616 @@ -2852,7 +3361,7 @@ index f13153c18b4e..adaf4c0cbe8f 100644 struct ntlmv2_resp { diff --git a/fs/ksmbd/oplock.c b/fs/ksmbd/oplock.c -index d7d47b82451d..1a12aa36e43a 100644 +index d7d47b82451d..e3299bb75b3a 100644 --- a/fs/ksmbd/oplock.c +++ b/fs/ksmbd/oplock.c @@ -10,6 +10,9 @@ @@ -2875,7 +3384,52 @@ index d7d47b82451d..1a12aa36e43a 100644 INIT_LIST_HEAD(&opinfo->op_entry); INIT_LIST_HEAD(&opinfo->interim_list); init_waitqueue_head(&opinfo->oplock_q); -@@ -229,6 +235,28 @@ int opinfo_write_to_read(struct oplock_info *opinfo) +@@ -157,13 +163,42 @@ static struct oplock_info *opinfo_get_list(struct ksmbd_inode *ci) + rcu_read_lock(); + opinfo = list_first_or_null_rcu(&ci->m_op_list, struct oplock_info, + op_entry); +- if (opinfo && !atomic_inc_not_zero(&opinfo->refcount)) +- opinfo = NULL; ++ if (opinfo) { ++ if (!atomic_inc_not_zero(&opinfo->refcount)) ++ opinfo = NULL; ++ else { ++ atomic_inc(&opinfo->conn->r_count); ++ if (ksmbd_conn_releasing(opinfo->conn)) { ++ atomic_dec(&opinfo->conn->r_count); ++ atomic_dec(&opinfo->refcount); ++ opinfo = NULL; ++ } ++ } ++ } ++ + rcu_read_unlock(); + + return opinfo; + } + ++static void opinfo_conn_put(struct oplock_info *opinfo) ++{ ++ struct ksmbd_conn *conn; ++ ++ if (!opinfo) ++ return; ++ ++ conn = opinfo->conn; ++ /* ++ * Checking waitqueue to dropping pending requests on ++ * disconnection. waitqueue_active is safe because it ++ * uses atomic operation for condition. ++ */ ++ if (!atomic_dec_return(&conn->r_count) && waitqueue_active(&conn->r_count_q)) ++ wake_up(&conn->r_count_q); ++ opinfo_put(opinfo); ++} ++ + void opinfo_put(struct oplock_info *opinfo) + { + if (!atomic_dec_and_test(&opinfo->refcount)) +@@ -229,6 +264,28 @@ int opinfo_write_to_read(struct oplock_info *opinfo) { struct lease *lease = opinfo->o_lease; @@ -2904,7 +3458,7 @@ index d7d47b82451d..1a12aa36e43a 100644 if (!(opinfo->level == SMB2_OPLOCK_LEVEL_BATCH || opinfo->level == SMB2_OPLOCK_LEVEL_EXCLUSIVE)) { pr_err("bad oplock(0x%x)\n", opinfo->level); -@@ -240,6 +268,7 @@ int opinfo_write_to_read(struct oplock_info *opinfo) +@@ -240,6 +297,7 @@ int opinfo_write_to_read(struct oplock_info *opinfo) if (opinfo->is_lease) lease->state = lease->new_state; @@ -2912,7 +3466,7 @@ index d7d47b82451d..1a12aa36e43a 100644 return 0; } -@@ -268,6 +297,27 @@ int opinfo_write_to_none(struct oplock_info *opinfo) +@@ -268,6 +326,27 @@ int opinfo_write_to_none(struct oplock_info *opinfo) { struct lease *lease = opinfo->o_lease; @@ -2940,7 +3494,7 @@ index d7d47b82451d..1a12aa36e43a 100644 if (!(opinfo->level == SMB2_OPLOCK_LEVEL_BATCH || opinfo->level == SMB2_OPLOCK_LEVEL_EXCLUSIVE)) { pr_err("bad oplock(0x%x)\n", opinfo->level); -@@ -278,6 +328,7 @@ int opinfo_write_to_none(struct oplock_info *opinfo) +@@ -278,6 +357,7 @@ int opinfo_write_to_none(struct oplock_info *opinfo) opinfo->level = SMB2_OPLOCK_LEVEL_NONE; if (opinfo->is_lease) lease->state = lease->new_state; @@ -2948,7 +3502,7 @@ index d7d47b82451d..1a12aa36e43a 100644 return 0; } -@@ -291,6 +342,25 @@ int opinfo_read_to_none(struct oplock_info *opinfo) +@@ -291,6 +371,25 @@ int opinfo_read_to_none(struct oplock_info *opinfo) { struct lease *lease = opinfo->o_lease; @@ -2974,7 +3528,7 @@ index d7d47b82451d..1a12aa36e43a 100644 if (opinfo->level != SMB2_OPLOCK_LEVEL_II) { pr_err("bad oplock(0x%x)\n", opinfo->level); if (opinfo->is_lease) -@@ -300,6 +370,7 @@ int opinfo_read_to_none(struct oplock_info *opinfo) +@@ -300,6 +399,7 @@ int opinfo_read_to_none(struct oplock_info *opinfo) opinfo->level = SMB2_OPLOCK_LEVEL_NONE; if (opinfo->is_lease) lease->state = lease->new_state; @@ -2982,7 +3536,7 @@ index d7d47b82451d..1a12aa36e43a 100644 return 0; } -@@ -403,10 +474,24 @@ static void grant_write_oplock(struct oplock_info *opinfo_new, int req_oplock, +@@ -403,10 +503,24 @@ static void grant_write_oplock(struct oplock_info *opinfo_new, int req_oplock, { struct lease *lease = opinfo_new->o_lease; @@ -3007,7 +3561,7 @@ index d7d47b82451d..1a12aa36e43a 100644 if (lctx) { lease->state = lctx->req_state; -@@ -426,7 +511,14 @@ static void grant_read_oplock(struct oplock_info *opinfo_new, +@@ -426,7 +540,14 @@ static void grant_read_oplock(struct oplock_info *opinfo_new, { struct lease *lease = opinfo_new->o_lease; @@ -3022,7 +3576,7 @@ index d7d47b82451d..1a12aa36e43a 100644 if (lctx) { lease->state = SMB2_LEASE_READ_CACHING_LE; -@@ -448,7 +540,14 @@ static void grant_none_oplock(struct oplock_info *opinfo_new, +@@ -448,7 +569,14 @@ static void grant_none_oplock(struct oplock_info *opinfo_new, { struct lease *lease = opinfo_new->o_lease; @@ -3037,7 +3591,7 @@ index d7d47b82451d..1a12aa36e43a 100644 if (lctx) { lease->state = 0; -@@ -568,7 +667,7 @@ static void wake_up_oplock_break(struct oplock_info *opinfo) +@@ -568,7 +696,7 @@ static void wake_up_oplock_break(struct oplock_info *opinfo) static int oplock_break_pending(struct oplock_info *opinfo, int req_op_level) { @@ -3046,7 +3600,7 @@ index d7d47b82451d..1a12aa36e43a 100644 wait_on_bit(&opinfo->pending_break, 0, TASK_UNINTERRUPTIBLE); /* Not immediately break to none. */ -@@ -596,6 +695,117 @@ static inline int allocate_oplock_break_buf(struct ksmbd_work *work) +@@ -596,6 +724,109 @@ static inline int allocate_oplock_break_buf(struct ksmbd_work *work) return 0; } @@ -3118,13 +3672,6 @@ index d7d47b82451d..1a12aa36e43a 100644 + + ksmbd_conn_write(work); + ksmbd_free_work_struct(work); -+ /* -+ * Checking waitqueue to dropping pending requests on -+ * disconnection. waitqueue_active is safe because it -+ * uses atomic operation for condition. -+ */ -+ if (!atomic_dec_return(&conn->r_count) && waitqueue_active(&conn->r_count_q)) -+ wake_up(&conn->r_count_q); +} + +/** @@ -3146,7 +3693,6 @@ index d7d47b82451d..1a12aa36e43a 100644 + work->request_buf = (char *)opinfo; + work->conn = conn; + -+ atomic_inc(&conn->r_count); + if (opinfo->op_state == OPLOCK_ACK_WAIT) { + INIT_WORK(&work->work, __smb1_oplock_break_noti); + ksmbd_queue_work(work); @@ -3164,7 +3710,51 @@ index d7d47b82451d..1a12aa36e43a 100644 /** * __smb2_oplock_break_noti() - send smb2 oplock break cmd from conn * to client -@@ -920,10 +1130,20 @@ static int oplock_break(struct oplock_info *brk_opinfo, int req_op_level) +@@ -666,13 +897,6 @@ static void __smb2_oplock_break_noti(struct work_struct *wk) + + out: + ksmbd_free_work_struct(work); +- /* +- * Checking waitqueue to dropping pending requests on +- * disconnection. waitqueue_active is safe because it +- * uses atomic operation for condition. +- */ +- if (!atomic_dec_return(&conn->r_count) && waitqueue_active(&conn->r_count_q)) +- wake_up(&conn->r_count_q); + } + + /** +@@ -706,7 +930,6 @@ static int smb2_oplock_break_noti(struct oplock_info *opinfo) + work->conn = conn; + work->sess = opinfo->sess; + +- atomic_inc(&conn->r_count); + if (opinfo->op_state == OPLOCK_ACK_WAIT) { + INIT_WORK(&work->work, __smb2_oplock_break_noti); + ksmbd_queue_work(work); +@@ -776,13 +999,6 @@ static void __smb2_lease_break_noti(struct work_struct *wk) + + out: + ksmbd_free_work_struct(work); +- /* +- * Checking waitqueue to dropping pending requests on +- * disconnection. waitqueue_active is safe because it +- * uses atomic operation for condition. +- */ +- if (!atomic_dec_return(&conn->r_count) && waitqueue_active(&conn->r_count_q)) +- wake_up(&conn->r_count_q); + } + + /** +@@ -822,7 +1038,6 @@ static int smb2_lease_break_noti(struct oplock_info *opinfo) + work->conn = conn; + work->sess = opinfo->sess; + +- atomic_inc(&conn->r_count); + if (opinfo->op_state == OPLOCK_ACK_WAIT) { + list_for_each_safe(tmp, t, &opinfo->interim_list) { + struct ksmbd_work *in_work; +@@ -920,10 +1135,20 @@ static int oplock_break(struct oplock_info *brk_opinfo, int req_op_level) brk_opinfo->op_state = OPLOCK_ACK_WAIT; } @@ -3185,7 +3775,7 @@ index d7d47b82451d..1a12aa36e43a 100644 ksmbd_debug(OPLOCK, "oplock granted = %d\n", brk_opinfo->level); if (brk_opinfo->op_state == OPLOCK_CLOSING) -@@ -1065,6 +1285,10 @@ static void set_oplock_level(struct oplock_info *opinfo, int level, +@@ -1065,6 +1290,10 @@ static void set_oplock_level(struct oplock_info *opinfo, int level, struct lease_ctx_info *lctx) { switch (level) { @@ -3196,15 +3786,75 @@ index d7d47b82451d..1a12aa36e43a 100644 case SMB2_OPLOCK_LEVEL_BATCH: case SMB2_OPLOCK_LEVEL_EXCLUSIVE: grant_write_oplock(opinfo, level, lctx); -@@ -1264,14 +1488,44 @@ void smb_break_all_levII_oplock(struct ksmbd_work *work, struct ksmbd_file *fp, - if (!atomic_inc_not_zero(&brk_op->refcount)) - continue; - rcu_read_unlock(); -- if (brk_op->is_lease && (brk_op->o_lease->state & -- (~(SMB2_LEASE_READ_CACHING_LE | -- SMB2_LEASE_HANDLE_CACHING_LE)))) { -+ -+#ifdef CONFIG_SMB_INSECURE_SERVER +@@ -1144,8 +1373,10 @@ int smb_grant_oplock(struct ksmbd_work *work, int req_op_level, u64 pid, + } + prev_opinfo = opinfo_get_list(ci); + if (!prev_opinfo || +- (prev_opinfo->level == SMB2_OPLOCK_LEVEL_NONE && lctx)) ++ (prev_opinfo->level == SMB2_OPLOCK_LEVEL_NONE && lctx)) { ++ opinfo_conn_put(prev_opinfo); + goto set_lev; ++ } + prev_op_has_lease = prev_opinfo->is_lease; + if (prev_op_has_lease) + prev_op_state = prev_opinfo->o_lease->state; +@@ -1153,19 +1384,19 @@ int smb_grant_oplock(struct ksmbd_work *work, int req_op_level, u64 pid, + if (share_ret < 0 && + prev_opinfo->level == SMB2_OPLOCK_LEVEL_EXCLUSIVE) { + err = share_ret; +- opinfo_put(prev_opinfo); ++ opinfo_conn_put(prev_opinfo); + goto err_out; + } + + if (prev_opinfo->level != SMB2_OPLOCK_LEVEL_BATCH && + prev_opinfo->level != SMB2_OPLOCK_LEVEL_EXCLUSIVE) { +- opinfo_put(prev_opinfo); ++ opinfo_conn_put(prev_opinfo); + goto op_break_not_needed; + } + + list_add(&work->interim_entry, &prev_opinfo->interim_list); + err = oplock_break(prev_opinfo, SMB2_OPLOCK_LEVEL_II); +- opinfo_put(prev_opinfo); ++ opinfo_conn_put(prev_opinfo); + if (err == -ENOENT) + goto set_lev; + /* Check all oplock was freed by close */ +@@ -1228,14 +1459,14 @@ static void smb_break_all_write_oplock(struct ksmbd_work *work, + return; + if (brk_opinfo->level != SMB2_OPLOCK_LEVEL_BATCH && + brk_opinfo->level != SMB2_OPLOCK_LEVEL_EXCLUSIVE) { +- opinfo_put(brk_opinfo); ++ opinfo_conn_put(brk_opinfo); + return; + } + + brk_opinfo->open_trunc = is_trunc; + list_add(&work->interim_entry, &brk_opinfo->interim_list); + oplock_break(brk_opinfo, SMB2_OPLOCK_LEVEL_II); +- opinfo_put(brk_opinfo); ++ opinfo_conn_put(brk_opinfo); + } + + /** +@@ -1263,15 +1494,52 @@ void smb_break_all_levII_oplock(struct ksmbd_work *work, struct ksmbd_file *fp, + list_for_each_entry_rcu(brk_op, &ci->m_op_list, op_entry) { + if (!atomic_inc_not_zero(&brk_op->refcount)) + continue; ++ ++ atomic_inc(&brk_op->conn->r_count); ++ if (ksmbd_conn_releasing(brk_op->conn)) { ++ atomic_dec(&brk_op->conn->r_count); ++ continue; ++ } ++ + rcu_read_unlock(); +- if (brk_op->is_lease && (brk_op->o_lease->state & +- (~(SMB2_LEASE_READ_CACHING_LE | +- SMB2_LEASE_HANDLE_CACHING_LE)))) { ++ ++#ifdef CONFIG_SMB_INSECURE_SERVER + if (brk_op->is_smb2) { + if (brk_op->is_lease && (brk_op->o_lease->state & + (~(SMB2_LEASE_READ_CACHING_LE | @@ -3246,7 +3896,7 @@ index d7d47b82451d..1a12aa36e43a 100644 ksmbd_debug(OPLOCK, "unexpected oplock(0x%x)\n", brk_op->level); goto next; -@@ -1282,6 +1536,7 @@ void smb_break_all_levII_oplock(struct ksmbd_work *work, struct ksmbd_file *fp, +@@ -1282,6 +1550,7 @@ void smb_break_all_levII_oplock(struct ksmbd_work *work, struct ksmbd_file *fp, brk_op->o_lease->new_state == SMB2_LEASE_NONE_LE && atomic_read(&brk_op->breaking_cnt)) goto next; @@ -3254,21 +3904,59 @@ index d7d47b82451d..1a12aa36e43a 100644 if (op && op->is_lease && brk_op->is_lease && !memcmp(conn->ClientGUID, brk_op->conn->ClientGUID, -@@ -1608,9 +1863,13 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp) +@@ -1292,7 +1561,7 @@ void smb_break_all_levII_oplock(struct ksmbd_work *work, struct ksmbd_file *fp, + brk_op->open_trunc = is_trunc; + oplock_break(brk_op, SMB2_OPLOCK_LEVEL_NONE); + next: +- opinfo_put(brk_op); ++ opinfo_conn_put(brk_op); + rcu_read_lock(); + } + rcu_read_unlock(); +@@ -1449,11 +1718,12 @@ struct lease_ctx_info *parse_lease_state(void *open_req) + * smb2_find_context_vals() - find a particular context info in open request + * @open_req: buffer containing smb2 file open(create) request + * @tag: context name to search for ++ * @tag_len: the length of tag + * + * Return: pointer to requested context, NULL if @str context not found + * or error pointer if name length is invalid. + */ +-struct create_context *smb2_find_context_vals(void *open_req, const char *tag) ++struct create_context *smb2_find_context_vals(void *open_req, const char *tag, int tag_len) + { + struct create_context *cc; + unsigned int next = 0; +@@ -1492,7 +1762,7 @@ struct create_context *smb2_find_context_vals(void *open_req, const char *tag) + return ERR_PTR(-EINVAL); + + name = (char *)cc + name_off; +- if (memcmp(name, tag, name_len) == 0) ++ if (name_len == tag_len && !memcmp(name, tag, name_len)) + return cc; + + remain_len -= next; +@@ -1608,9 +1878,19 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp) { struct create_posix_rsp *buf; struct inode *inode = file_inode(fp->filp); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap = file_mnt_idmap(fp->filp); ++ vfsuid_t vfsuid = i_uid_into_vfsuid(idmap, inode); ++ vfsgid_t vfsgid = i_gid_into_vfsgid(idmap, inode); ++#else +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) struct user_namespace *user_ns = file_mnt_user_ns(fp->filp); +#endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0) vfsuid_t vfsuid = i_uid_into_vfsuid(user_ns, inode); vfsgid_t vfsgid = i_gid_into_vfsgid(user_ns, inode); ++#endif +#endif buf = (struct create_posix_rsp *)cc; memset(buf, 0, sizeof(struct create_posix_rsp)); -@@ -1648,13 +1907,31 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp) +@@ -1648,13 +1928,31 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp) /* * SidBuffer(44) contain two sids(Domain sid(28), UNIX group sid(16)). * Domain sid(28) = revision(1) + num_subauth(1) + authority(6) + @@ -3303,7 +3991,7 @@ index d7d47b82451d..1a12aa36e43a 100644 } diff --git a/fs/ksmbd/oplock.h b/fs/ksmbd/oplock.h -index 09753448f779..68cdaf405e2d 100644 +index 09753448f779..94395e4804ce 100644 --- a/fs/ksmbd/oplock.h +++ b/fs/ksmbd/oplock.h @@ -11,6 +11,14 @@ @@ -3331,23 +4019,42 @@ index 09753448f779..68cdaf405e2d 100644 bool open_trunc; /* truncate on open */ struct lease *o_lease; struct list_head interim_list; +@@ -118,7 +129,7 @@ void create_durable_v2_rsp_buf(char *cc, struct ksmbd_file *fp); + void create_mxac_rsp_buf(char *cc, int maximal_access); + void create_disk_id_rsp_buf(char *cc, __u64 file_id, __u64 vol_id); + void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp); +-struct create_context *smb2_find_context_vals(void *open_req, const char *str); ++struct create_context *smb2_find_context_vals(void *open_req, const char *tag, int tag_len); + struct oplock_info *lookup_lease_in_table(struct ksmbd_conn *conn, + char *lease_key); + int find_same_lease_key(struct ksmbd_session *sess, struct ksmbd_inode *ci, diff --git a/fs/ksmbd/server.c b/fs/ksmbd/server.c -index a0d635304754..b0ff252897d1 100644 +index 651d1d01234b..a730869ac32b 100644 --- a/fs/ksmbd/server.c +++ b/fs/ksmbd/server.c -@@ -289,10 +289,7 @@ static int queue_ksmbd_work(struct ksmbd_conn *conn) - work->request_buf = conn->request_buf; - conn->request_buf = NULL; - -- if (ksmbd_init_smb_server(work)) { -- ksmbd_free_work_struct(work); -- return -EINVAL; -- } -+ ksmbd_init_smb_server(work); +@@ -93,7 +93,8 @@ static inline int check_conn_state(struct ksmbd_work *work) + { + struct smb_hdr *rsp_hdr; + +- if (ksmbd_conn_exiting(work) || ksmbd_conn_need_reconnect(work)) { ++ if (ksmbd_conn_exiting(work->conn) || ++ ksmbd_conn_need_reconnect(work->conn)) { + rsp_hdr = work->response_buf; + rsp_hdr->Status.CifsError = STATUS_CONNECTION_DISCONNECTED; + return 1; +@@ -415,7 +416,11 @@ int server_queue_ctrl_reset_work(void) + return __queue_ctrl_work(SERVER_CTRL_TYPE_RESET); + } - ksmbd_conn_enqueue_request(work); - atomic_inc(&conn->r_count); -@@ -432,11 +429,9 @@ static ssize_t stats_show(struct class *class, struct class_attribute *attr, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0) ++static ssize_t stats_show(const struct class *class, const struct class_attribute *attr, ++#else + static ssize_t stats_show(struct class *class, struct class_attribute *attr, ++#endif + char *buf) + { + /* +@@ -429,15 +434,18 @@ static ssize_t stats_show(struct class *class, struct class_attribute *attr, "reset", "shutdown" }; @@ -3361,8 +4068,29 @@ index a0d635304754..b0ff252897d1 100644 + server_conf.ipc_last_active / HZ); } ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0) ++static ssize_t kill_server_store(const struct class *class, ++ const struct class_attribute *attr, const char *buf, ++#else static ssize_t kill_server_store(struct class *class, -@@ -468,19 +463,13 @@ static ssize_t debug_show(struct class *class, struct class_attribute *attr, + struct class_attribute *attr, const char *buf, ++#endif + size_t len) + { + if (!sysfs_streq(buf, "hard")) +@@ -457,7 +465,11 @@ static const char * const debug_type_strings[] = {"smb", "auth", "vfs", + "oplock", "ipc", "conn", + "rdma"}; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0) ++static ssize_t debug_show(const struct class *class, const struct class_attribute *attr, ++#else + static ssize_t debug_show(struct class *class, struct class_attribute *attr, ++#endif + char *buf) + { + ssize_t sz = 0; +@@ -465,23 +477,21 @@ static ssize_t debug_show(struct class *class, struct class_attribute *attr, for (i = 0; i < ARRAY_SIZE(debug_type_strings); i++) { if ((ksmbd_debug_types >> i) & 1) { @@ -3385,7 +4113,25 @@ index a0d635304754..b0ff252897d1 100644 return sz; } -@@ -588,9 +577,6 @@ static int __init ksmbd_server_init(void) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0) ++static ssize_t debug_store(const struct class *class, const struct class_attribute *attr, ++#else + static ssize_t debug_store(struct class *class, struct class_attribute *attr, ++#endif + const char *buf, size_t len) + { + int i; +@@ -521,7 +531,9 @@ ATTRIBUTE_GROUPS(ksmbd_control_class); + + static struct class ksmbd_control_class = { + .name = "ksmbd-control", ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) + .owner = THIS_MODULE, ++#endif + .class_groups = ksmbd_control_class_groups, + }; + +@@ -585,9 +597,6 @@ static int __init ksmbd_server_init(void) ret = ksmbd_workqueue_init(); if (ret) goto err_crypto_destroy; @@ -3395,7 +4141,15 @@ index a0d635304754..b0ff252897d1 100644 return 0; err_crypto_destroy: -@@ -626,6 +612,7 @@ MODULE_DESCRIPTION("Linux kernel CIFS/SMB SERVER"); +@@ -614,6 +623,7 @@ static int __init ksmbd_server_init(void) + static void __exit ksmbd_server_exit(void) + { + ksmbd_server_shutdown(); ++ rcu_barrier(); + ksmbd_release_inode_hash(); + } + +@@ -623,6 +633,7 @@ MODULE_DESCRIPTION("Linux kernel CIFS/SMB SERVER"); MODULE_LICENSE("GPL"); MODULE_SOFTDEP("pre: ecb"); MODULE_SOFTDEP("pre: hmac"); @@ -3803,7 +4557,7 @@ index 000000000000..26b27b9f5ff7 +} diff --git a/fs/ksmbd/smb1pdu.c b/fs/ksmbd/smb1pdu.c new file mode 100644 -index 000000000000..880031386262 +index 000000000000..bf5817dd192b --- /dev/null +++ b/fs/ksmbd/smb1pdu.c @@ -0,0 +1,8516 @@ @@ -4062,7 +4816,7 @@ index 000000000000..880031386262 + cmd == SMB_COM_ECHO) + return 0; + -+ if (!ksmbd_conn_good(work)) ++ if (!ksmbd_conn_good(conn)) + return -EINVAL; + + if (xa_empty(&conn->sessions)) { @@ -4126,9 +4880,9 @@ index 000000000000..880031386262 + struct ksmbd_session *sess = work->sess; + + /* setting CifsExiting here may race with start_tcp_sess */ -+ ksmbd_conn_set_need_reconnect(work); ++ ksmbd_conn_set_need_reconnect(conn); + -+ ksmbd_conn_wait_idle(conn); ++ ksmbd_conn_wait_idle(conn, sess->id); + + ksmbd_tree_conn_session_logoff(sess); + xa_erase(&conn->sessions, sess->id); @@ -4136,7 +4890,7 @@ index 000000000000..880031386262 + work->sess = NULL; + + /* let start_tcp_sess free conn info now */ -+ ksmbd_conn_set_exiting(work); ++ ksmbd_conn_set_exiting(conn); + return 0; +} + @@ -4626,7 +5380,7 @@ index 000000000000..880031386262 + __u64 time; + int rc = 0; + -+ WARN_ON(ksmbd_conn_good(work)); ++ WARN_ON(ksmbd_conn_good(conn)); + + if (conn->dialect == BAD_PROT_ID) { + neg_rsp->hdr.Status.CifsError = STATUS_INVALID_LOGON_TYPE; @@ -4689,7 +5443,7 @@ index 000000000000..880031386262 + + /* Null terminated domain name in unicode */ + -+ ksmbd_conn_set_need_negotiate(work); ++ ksmbd_conn_set_need_negotiate(conn); + /* Domain name and PC name are ignored by clients, so no need to send. + * We can try sending them later + */ @@ -5073,7 +5827,7 @@ index 000000000000..880031386262 + goto out_err; + + work->sess = sess; -+ ksmbd_conn_set_good(work); ++ ksmbd_conn_set_good(conn); + return 0; + +out_err: @@ -5484,7 +6238,7 @@ index 000000000000..880031386262 + + list_del(&smb_lock->llist); + /* check locks in connections */ -+ read_lock(&conn_list_lock); ++ down_read(&conn_list_lock); + list_for_each_entry(conn, &conn_list, conns_list) { + spin_lock(&conn->llist_lock); + list_for_each_entry_safe(cmp_lock, tmp2, &conn->lock_list, clist) { @@ -5497,7 +6251,7 @@ index 000000000000..880031386262 + cmp_lock->end == smb_lock->end) { + same_zero_lock = 1; + spin_unlock(&conn->llist_lock); -+ read_unlock(&conn_list_lock); ++ up_read(&conn_list_lock); + goto out_check_cl; + } + @@ -5538,7 +6292,7 @@ index 000000000000..880031386262 + smb_lock->start >= 0xEF000000)) { + if (timeout) { + spin_unlock(&conn->llist_lock); -+ read_unlock(&conn_list_lock); ++ up_read(&conn_list_lock); + ksmbd_debug(SMB, "waiting error response for timeout : %d\n", + timeout); + msleep(timeout); @@ -5553,14 +6307,14 @@ index 000000000000..880031386262 + + if (timeout <= 0) { + spin_unlock(&conn->llist_lock); -+ read_unlock(&conn_list_lock); ++ up_read(&conn_list_lock); + } + goto out; + } + } + spin_unlock(&conn->llist_lock); + } -+ read_unlock(&conn_list_lock); ++ up_read(&conn_list_lock); + +out_check_cl: + if (same_zero_lock) @@ -5653,7 +6407,7 @@ index 000000000000..880031386262 + flock->fl_end = offset + length; + + locked = 0; -+ read_lock(&conn_list_lock); ++ up_read(&conn_list_lock); + list_for_each_entry(conn, &conn_list, conns_list) { + spin_lock(&conn->llist_lock); + list_for_each_entry(cmp_lock, &conn->lock_list, clist) { @@ -5665,13 +6419,13 @@ index 000000000000..880031386262 + cmp_lock->end == offset + length)) { + locked = 1; + spin_unlock(&conn->llist_lock); -+ read_unlock(&conn_list_lock); ++ up_read(&conn_list_lock); + goto out_check_cl_unlck; + } + } + spin_unlock(&conn->llist_lock); + } -+ read_unlock(&conn_list_lock); ++ up_read(&conn_list_lock); + +out_check_cl_unlck: + if (!locked) { @@ -13961,7 +14715,7 @@ index 000000000000..e470c8e94e68 +extern int smb_process_exit(struct ksmbd_work *work); +#endif /* __SMB1PDU_H */ diff --git a/fs/ksmbd/smb2misc.c b/fs/ksmbd/smb2misc.c -index 6e25ace36568..3fbea2164f86 100644 +index fbdde426dd01..dc09d815d3e5 100644 --- a/fs/ksmbd/smb2misc.c +++ b/fs/ksmbd/smb2misc.c @@ -6,6 +6,7 @@ @@ -13972,56 +14726,19 @@ index 6e25ace36568..3fbea2164f86 100644 #include "smb_common.h" #include "smbstatus.h" #include "mgmt/user_session.h" -@@ -149,15 +150,11 @@ static int smb2_get_data_area_len(unsigned int *off, unsigned int *len, - break; - case SMB2_LOCK: - { -- int lock_count; -+ unsigned short lock_count; - -- /* -- * smb2_lock request size is 48 included single -- * smb2_lock_element structure size. -- */ -- lock_count = le16_to_cpu(((struct smb2_lock_req *)hdr)->LockCount) - 1; -+ lock_count = le16_to_cpu(((struct smb2_lock_req *)hdr)->LockCount); - if (lock_count > 0) { -- *off = __SMB2_HEADER_STRUCTURE_SIZE + 48; -+ *off = offsetof(struct smb2_lock_req, locks); - *len = sizeof(struct smb2_lock_element) * lock_count; - } - break; -@@ -412,20 +409,19 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work) - goto validate_credit; +@@ -416,8 +417,11 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work) /* -- * windows client also pad up to 8 bytes when compounding. -- * If pad is longer than eight bytes, log the server behavior -- * (once), since may indicate a problem but allow it and -- * continue since the frame is parseable. -+ * SMB2 NEGOTIATE request will be validated when message -+ * handling proceeds. + * Allow a message that padded to 8byte boundary. ++ * Linux 4.19.217 with smb 3.0.2 are sometimes ++ * sending messages where the cls_len is exactly ++ * 8 bytes less than len. */ -- if (clc_len < len) { -- ksmbd_debug(SMB, -- "cli req padded more than expected. Length %d not %d for cmd:%d mid:%llu\n", -- len, clc_len, command, -- le64_to_cpu(hdr->MessageId)); -+ if (command == SMB2_NEGOTIATE_HE) -+ goto validate_credit; -+ -+ /* -+ * Allow a message that padded to 8byte boundary. -+ */ -+ if (clc_len < len && (len - clc_len) < 8) +- if (clc_len < len && (len - clc_len) < 8) ++ if (clc_len < len && (len - clc_len) <= 8) goto validate_credit; -- } -- ksmbd_debug(SMB, -+ pr_err_ratelimited( - "cli req too short, len %d not %d. cmd:%d mid:%llu\n", - len, clc_len, command, - le64_to_cpu(hdr->MessageId)); + pr_err_ratelimited( diff --git a/fs/ksmbd/smb2ops.c b/fs/ksmbd/smb2ops.c index ab23da2120b9..8c26b11c33bb 100644 --- a/fs/ksmbd/smb2ops.c @@ -14152,7 +14869,7 @@ index ab23da2120b9..8c26b11c33bb 100644 if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_LEASES) conn->vals->capabilities |= SMB2_GLOBAL_CAP_LEASING; diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c -index 9b16ee657b51..8560e4344af0 100644 +index 5de7b41d6404..273dd9cfd663 100644 --- a/fs/ksmbd/smb2pdu.c +++ b/fs/ksmbd/smb2pdu.c @@ -11,9 +11,15 @@ @@ -14187,17 +14904,40 @@ index 9b16ee657b51..8560e4344af0 100644 } /** -@@ -235,9 +234,6 @@ int init_smb2_neg_rsp(struct ksmbd_work *work) - struct smb2_negotiate_rsp *rsp; - struct ksmbd_conn *conn = work->conn; +@@ -254,7 +253,7 @@ int init_smb2_neg_rsp(struct ksmbd_work *work) -- if (conn->need_neg == false) -- return -EINVAL; + rsp = smb2_get_msg(work->response_buf); + +- WARN_ON(ksmbd_conn_good(work)); ++ WARN_ON(ksmbd_conn_good(conn)); + + rsp->StructureSize = cpu_to_le16(65); + ksmbd_debug(SMB, "conn->dialect 0x%x\n", conn->dialect); +@@ -284,7 +283,7 @@ int init_smb2_neg_rsp(struct ksmbd_work *work) + rsp->SecurityMode |= SMB2_NEGOTIATE_SIGNING_REQUIRED_LE; + conn->use_spnego = true; + +- ksmbd_conn_set_need_negotiate(work); ++ ksmbd_conn_set_need_negotiate(conn); + return 0; + } + +@@ -333,13 +332,9 @@ int smb2_set_rsp_credits(struct ksmbd_work *work) + if (hdr->Command == SMB2_NEGOTIATE) + aux_max = 1; + else +- aux_max = conn->vals->max_credits - credit_charge; ++ aux_max = conn->vals->max_credits - conn->total_credits; + credits_granted = min_t(unsigned short, credits_requested, aux_max); + +- if (conn->vals->max_credits - conn->total_credits < credits_granted) +- credits_granted = conn->vals->max_credits - +- conn->total_credits; - - *(__be32 *)work->response_buf = - cpu_to_be32(conn->vals->header_size); + conn->total_credits += credits_granted; + work->credits_granted += credits_granted; -@@ -505,12 +501,6 @@ int init_smb2_rsp_hdr(struct ksmbd_work *work) +@@ -502,12 +497,6 @@ int init_smb2_rsp_hdr(struct ksmbd_work *work) rsp_hdr->SessionId = rcv_hdr->SessionId; memcpy(rsp_hdr->Signature, rcv_hdr->Signature, 16); @@ -14210,7 +14950,16 @@ index 9b16ee657b51..8560e4344af0 100644 return 0; } -@@ -595,6 +585,7 @@ static void destroy_previous_session(struct ksmbd_conn *conn, +@@ -574,7 +563,7 @@ int smb2_check_user_session(struct ksmbd_work *work) + cmd == SMB2_SESSION_SETUP_HE) + return 0; + +- if (!ksmbd_conn_good(work)) ++ if (!ksmbd_conn_good(conn)) + return -EINVAL; + + sess_id = le64_to_cpu(req_hdr->SessionId); +@@ -592,6 +581,7 @@ static void destroy_previous_session(struct ksmbd_conn *conn, struct ksmbd_session *prev_sess = ksmbd_session_lookup_slowpath(id); struct ksmbd_user *prev_user; struct channel *chann; @@ -14218,15 +14967,16 @@ index 9b16ee657b51..8560e4344af0 100644 if (!prev_sess) return; -@@ -608,14 +599,13 @@ static void destroy_previous_session(struct ksmbd_conn *conn, +@@ -605,14 +595,13 @@ static void destroy_previous_session(struct ksmbd_conn *conn, return; prev_sess->state = SMB2_SESSION_EXPIRED; - write_lock(&prev_sess->chann_lock); - list_for_each_entry(chann, &prev_sess->ksmbd_chann_list, chann_list) -+ xa_for_each(&prev_sess->ksmbd_chann_list, index, chann) - chann->conn->status = KSMBD_SESS_EXITING; +- chann->conn->status = KSMBD_SESS_EXITING; - write_unlock(&prev_sess->chann_lock); ++ xa_for_each(&prev_sess->ksmbd_chann_list, index, chann) ++ ksmbd_conn_set_exiting(chann->conn); } /** @@ -14235,7 +14985,7 @@ index 9b16ee657b51..8560e4344af0 100644 * @src: source buffer * @maxlen: maxlen of source string * @local_nls: nls_table pointer -@@ -623,7 +613,8 @@ static void destroy_previous_session(struct ksmbd_conn *conn, +@@ -620,7 +609,8 @@ static void destroy_previous_session(struct ksmbd_conn *conn, * Return: matching converted filename on success, otherwise error ptr */ static char * @@ -14245,7 +14995,7 @@ index 9b16ee657b51..8560e4344af0 100644 { char *name; -@@ -652,7 +643,7 @@ int setup_async_work(struct ksmbd_work *work, void (*fn)(void **), void **arg) +@@ -649,7 +639,7 @@ int setup_async_work(struct ksmbd_work *work, void (*fn)(void **), void **arg) pr_err("Failed to alloc async message id\n"); return id; } @@ -14254,7 +15004,7 @@ index 9b16ee657b51..8560e4344af0 100644 work->async_id = id; rsp_hdr->Id.AsyncId = cpu_to_le64(id); -@@ -672,6 +663,24 @@ int setup_async_work(struct ksmbd_work *work, void (*fn)(void **), void **arg) +@@ -669,6 +659,24 @@ int setup_async_work(struct ksmbd_work *work, void (*fn)(void **), void **arg) return 0; } @@ -14279,7 +15029,7 @@ index 9b16ee657b51..8560e4344af0 100644 void smb2_send_interim_resp(struct ksmbd_work *work, __le32 status) { struct smb2_hdr *rsp_hdr; -@@ -717,17 +726,17 @@ static int smb2_get_dos_mode(struct kstat *stat, int attribute) +@@ -714,17 +722,17 @@ static int smb2_get_dos_mode(struct kstat *stat, int attribute) int attr = 0; if (S_ISDIR(stat->mode)) { @@ -14303,7 +15053,7 @@ index 9b16ee657b51..8560e4344af0 100644 } return attr; -@@ -755,19 +764,6 @@ static void build_encrypt_ctxt(struct smb2_encryption_neg_context *pneg_ctxt, +@@ -752,19 +760,6 @@ static void build_encrypt_ctxt(struct smb2_encryption_neg_context *pneg_ctxt, pneg_ctxt->Ciphers[0] = cipher_type; } @@ -14323,7 +15073,7 @@ index 9b16ee657b51..8560e4344af0 100644 static void build_sign_cap_ctxt(struct smb2_signing_capabilities *pneg_ctxt, __le16 sign_algo) { -@@ -807,7 +803,7 @@ static void assemble_neg_contexts(struct ksmbd_conn *conn, +@@ -804,7 +799,7 @@ static void assemble_neg_contexts(struct ksmbd_conn *conn, struct smb2_negotiate_rsp *rsp, void *smb2_buf_len) { @@ -14332,7 +15082,7 @@ index 9b16ee657b51..8560e4344af0 100644 le32_to_cpu(rsp->NegotiateContextOffset); int neg_ctxt_cnt = 1; int ctxt_size; -@@ -816,61 +812,46 @@ static void assemble_neg_contexts(struct ksmbd_conn *conn, +@@ -813,80 +808,61 @@ static void assemble_neg_contexts(struct ksmbd_conn *conn, "assemble SMB2_PREAUTH_INTEGRITY_CAPABILITIES context\n"); build_preauth_ctxt((struct smb2_preauth_neg_context *)pneg_ctxt, conn->preauth_info->Preauth_HashId); @@ -14407,7 +15157,34 @@ index 9b16ee657b51..8560e4344af0 100644 inc_rfc1001_len(smb2_buf_len, ctxt_size); } -@@ -903,7 +884,7 @@ static void decode_encrypt_ctxt(struct ksmbd_conn *conn, + static __le32 decode_preauth_ctxt(struct ksmbd_conn *conn, +- struct smb2_preauth_neg_context *pneg_ctxt, +- int len_of_ctxts) ++ struct smb2_preauth_neg_context *pneg_ctxt) + { +- /* +- * sizeof(smb2_preauth_neg_context) assumes SMB311_SALT_SIZE Salt, +- * which may not be present. Only check for used HashAlgorithms[1]. +- */ +- if (len_of_ctxts < MIN_PREAUTH_CTXT_DATA_LEN) +- return STATUS_INVALID_PARAMETER; ++ __le32 err = STATUS_NO_PREAUTH_INTEGRITY_HASH_OVERLAP; + +- if (pneg_ctxt->HashAlgorithms != SMB2_PREAUTH_INTEGRITY_SHA512) +- return STATUS_NO_PREAUTH_INTEGRITY_HASH_OVERLAP; ++ if (pneg_ctxt->HashAlgorithms == SMB2_PREAUTH_INTEGRITY_SHA512) { ++ conn->preauth_info->Preauth_HashId = ++ SMB2_PREAUTH_INTEGRITY_SHA512; ++ err = STATUS_SUCCESS; ++ } + +- conn->preauth_info->Preauth_HashId = SMB2_PREAUTH_INTEGRITY_SHA512; +- return STATUS_SUCCESS; ++ return err; + } + + static void decode_encrypt_ctxt(struct ksmbd_conn *conn, +@@ -904,7 +880,7 @@ static void decode_encrypt_ctxt(struct ksmbd_conn *conn, return; } @@ -14416,7 +15193,7 @@ index 9b16ee657b51..8560e4344af0 100644 return; for (i = 0; i < cph_cnt; i++) { -@@ -939,7 +920,7 @@ bool smb3_encryption_negotiated(struct ksmbd_conn *conn) +@@ -940,7 +916,7 @@ bool smb3_encryption_negotiated(struct ksmbd_conn *conn) } static void decode_compress_ctxt(struct ksmbd_conn *conn, @@ -14425,7 +15202,7 @@ index 9b16ee657b51..8560e4344af0 100644 { conn->compress_algorithm = SMB3_COMPRESS_NONE; } -@@ -960,8 +941,8 @@ static void decode_sign_cap_ctxt(struct ksmbd_conn *conn, +@@ -961,8 +937,8 @@ static void decode_sign_cap_ctxt(struct ksmbd_conn *conn, } for (i = 0; i < sign_algo_cnt; i++) { @@ -14436,7 +15213,17 @@ index 9b16ee657b51..8560e4344af0 100644 ksmbd_debug(SMB, "Signing Algorithm ID = 0x%x\n", pneg_ctxt->SigningAlgorithms[i]); conn->signing_negotiated = true; -@@ -1032,7 +1013,7 @@ static __le32 deassemble_neg_contexts(struct ksmbd_conn *conn, +@@ -1014,8 +990,7 @@ static __le32 deassemble_neg_contexts(struct ksmbd_conn *conn, + break; + + status = decode_preauth_ctxt(conn, +- (struct smb2_preauth_neg_context *)pctx, +- len_of_ctxts); ++ (struct smb2_preauth_neg_context *)pctx); + if (status != STATUS_SUCCESS) + break; + } else if (pctx->ContextType == SMB2_ENCRYPTION_CAPABILITIES) { +@@ -1034,7 +1009,7 @@ static __le32 deassemble_neg_contexts(struct ksmbd_conn *conn, break; decode_compress_ctxt(conn, @@ -14445,7 +15232,16 @@ index 9b16ee657b51..8560e4344af0 100644 } else if (pctx->ContextType == SMB2_NETNAME_NEGOTIATE_CONTEXT_ID) { ksmbd_debug(SMB, "deassemble SMB2_NETNAME_NEGOTIATE_CONTEXT_ID context\n"); -@@ -1172,6 +1153,13 @@ int smb2_handle_negotiate(struct ksmbd_work *work) +@@ -1075,7 +1050,7 @@ int smb2_handle_negotiate(struct ksmbd_work *work) + + ksmbd_debug(SMB, "Received negotiate request\n"); + conn->need_neg = false; +- if (ksmbd_conn_good(work)) { ++ if (ksmbd_conn_good(conn)) { + pr_err("conn->tcp_status is already in CifsGood State\n"); + work->send_no_response = 1; + return rc; +@@ -1174,6 +1149,13 @@ int smb2_handle_negotiate(struct ksmbd_work *work) case SMB21_PROT_ID: init_smb2_1_server(conn); break; @@ -14459,7 +15255,7 @@ index 9b16ee657b51..8560e4344af0 100644 case SMB2X_PROT_ID: case BAD_PROT_ID: default: -@@ -1190,9 +1178,11 @@ int smb2_handle_negotiate(struct ksmbd_work *work) +@@ -1192,9 +1174,11 @@ int smb2_handle_negotiate(struct ksmbd_work *work) rsp->MaxReadSize = cpu_to_le32(conn->vals->max_read_size); rsp->MaxWriteSize = cpu_to_le32(conn->vals->max_write_size); @@ -14474,7 +15270,54 @@ index 9b16ee657b51..8560e4344af0 100644 rsp->StructureSize = cpu_to_le16(65); rsp->DialectRevision = cpu_to_le16(conn->dialect); -@@ -1508,7 +1498,8 @@ static int ntlm_authenticate(struct ksmbd_work *work) +@@ -1230,7 +1214,7 @@ int smb2_handle_negotiate(struct ksmbd_work *work) + } + + conn->srv_sec_mode = le16_to_cpu(rsp->SecurityMode); +- ksmbd_conn_set_need_negotiate(work); ++ ksmbd_conn_set_need_negotiate(conn); + + err_out: + if (rc < 0) +@@ -1381,7 +1365,7 @@ static struct ksmbd_user *session_user(struct ksmbd_conn *conn, + struct authenticate_message *authblob; + struct ksmbd_user *user; + char *name; +- unsigned int auth_msg_len, name_off, name_len, secbuf_len; ++ unsigned int name_off, name_len, secbuf_len; + + secbuf_len = le16_to_cpu(req->SecurityBufferLength); + if (secbuf_len < sizeof(struct authenticate_message)) { +@@ -1391,9 +1375,8 @@ static struct ksmbd_user *session_user(struct ksmbd_conn *conn, + authblob = user_authblob(conn, req); + name_off = le32_to_cpu(authblob->UserName.BufferOffset); + name_len = le16_to_cpu(authblob->UserName.Length); +- auth_msg_len = le16_to_cpu(req->SecurityBufferOffset) + secbuf_len; + +- if (auth_msg_len < (u64)name_off + name_len) ++ if (secbuf_len < (u64)name_off + name_len) + return NULL; + + name = smb_strndup_from_utf16((const char *)authblob + name_off, +@@ -1456,7 +1439,7 @@ static int ntlm_authenticate(struct ksmbd_work *work) + * Reuse session if anonymous try to connect + * on reauthetication. + */ +- if (ksmbd_anonymous_user(user)) { ++ if (conn->binding == false && ksmbd_anonymous_user(user)) { + ksmbd_free_user(user); + return 0; + } +@@ -1470,7 +1453,7 @@ static int ntlm_authenticate(struct ksmbd_work *work) + sess->user = user; + } + +- if (user_guest(sess->user)) { ++ if (conn->binding == false && user_guest(sess->user)) { + rsp->SessionFlags = SMB2_SESSION_FLAG_IS_GUEST_LE; + } else { + struct authenticate_message *authblob; +@@ -1510,7 +1493,8 @@ static int ntlm_authenticate(struct ksmbd_work *work) return -EINVAL; } sess->enc = true; @@ -14484,7 +15327,7 @@ index 9b16ee657b51..8560e4344af0 100644 /* * signing is disable if encryption is enable * on this session -@@ -1518,19 +1509,14 @@ static int ntlm_authenticate(struct ksmbd_work *work) +@@ -1520,19 +1504,14 @@ static int ntlm_authenticate(struct ksmbd_work *work) binding_session: if (conn->dialect >= SMB30_PROT_ID) { @@ -14505,7 +15348,7 @@ index 9b16ee657b51..8560e4344af0 100644 } } -@@ -1542,9 +1528,11 @@ static int ntlm_authenticate(struct ksmbd_work *work) +@@ -1544,9 +1523,11 @@ static int ntlm_authenticate(struct ksmbd_work *work) } } @@ -14520,7 +15363,7 @@ index 9b16ee657b51..8560e4344af0 100644 } return 0; } -@@ -1599,24 +1587,20 @@ static int krb5_authenticate(struct ksmbd_work *work) +@@ -1601,24 +1582,20 @@ static int krb5_authenticate(struct ksmbd_work *work) return -EINVAL; } sess->enc = true; @@ -14548,7 +15391,7 @@ index 9b16ee657b51..8560e4344af0 100644 } } -@@ -1628,9 +1612,11 @@ static int krb5_authenticate(struct ksmbd_work *work) +@@ -1630,9 +1607,11 @@ static int krb5_authenticate(struct ksmbd_work *work) } } @@ -14563,7 +15406,187 @@ index 9b16ee657b51..8560e4344af0 100644 } return 0; } -@@ -2141,7 +2127,7 @@ static noinline int create_smb2_pipe(struct ksmbd_work *work) +@@ -1661,6 +1640,7 @@ int smb2_sess_setup(struct ksmbd_work *work) + rsp->SecurityBufferLength = 0; + inc_rfc1001_len(work->response_buf, 9); + ++ ksmbd_conn_lock(conn); + if (!req->hdr.SessionId) { + sess = ksmbd_smb2_session_create(); + if (!sess) { +@@ -1708,11 +1688,22 @@ int smb2_sess_setup(struct ksmbd_work *work) + goto out_err; + } + ++ if (ksmbd_conn_need_reconnect(conn)) { ++ rc = -EFAULT; ++ sess = NULL; ++ goto out_err; ++ } ++ + if (ksmbd_session_lookup(conn, sess_id)) { + rc = -EACCES; + goto out_err; + } + ++ if (user_guest(sess->user)) { ++ rc = -EOPNOTSUPP; ++ goto out_err; ++ } ++ + conn->binding = true; + } else if ((conn->dialect < SMB30_PROT_ID || + server_conf.flags & KSMBD_GLOBAL_FLAG_SMB3_MULTICHANNEL) && +@@ -1727,12 +1718,20 @@ int smb2_sess_setup(struct ksmbd_work *work) + rc = -ENOENT; + goto out_err; + } ++ ++ if (sess->state == SMB2_SESSION_EXPIRED) { ++ rc = -EFAULT; ++ goto out_err; ++ } ++ ++ if (ksmbd_conn_need_reconnect(conn)) { ++ rc = -EFAULT; ++ sess = NULL; ++ goto out_err; ++ } + } + work->sess = sess; + +- if (sess->state == SMB2_SESSION_EXPIRED) +- sess->state = SMB2_SESSION_IN_PROGRESS; +- + negblob_off = le16_to_cpu(req->SecurityBufferOffset); + negblob_len = le16_to_cpu(req->SecurityBufferLength); + if (negblob_off < offsetof(struct smb2_sess_setup_req, Buffer) || +@@ -1762,8 +1761,10 @@ int smb2_sess_setup(struct ksmbd_work *work) + goto out_err; + } + +- ksmbd_conn_set_good(work); +- sess->state = SMB2_SESSION_VALID; ++ if (!ksmbd_conn_need_reconnect(conn)) { ++ ksmbd_conn_set_good(conn); ++ sess->state = SMB2_SESSION_VALID; ++ } + kfree(sess->Preauth_HashValue); + sess->Preauth_HashValue = NULL; + } else if (conn->preferred_auth_mech == KSMBD_AUTH_NTLMSSP) { +@@ -1785,8 +1786,10 @@ int smb2_sess_setup(struct ksmbd_work *work) + if (rc) + goto out_err; + +- ksmbd_conn_set_good(work); +- sess->state = SMB2_SESSION_VALID; ++ if (!ksmbd_conn_need_reconnect(conn)) { ++ ksmbd_conn_set_good(conn); ++ sess->state = SMB2_SESSION_VALID; ++ } + if (conn->binding) { + struct preauth_session *preauth_sess; + +@@ -1799,6 +1802,10 @@ int smb2_sess_setup(struct ksmbd_work *work) + } + kfree(sess->Preauth_HashValue); + sess->Preauth_HashValue = NULL; ++ } else { ++ pr_info_ratelimited("Unknown NTLMSSP message type : 0x%x\n", ++ le32_to_cpu(negblob->MessageType)); ++ rc = -EINVAL; + } + } else { + /* TODO: need one more negotiation */ +@@ -1821,6 +1828,8 @@ int smb2_sess_setup(struct ksmbd_work *work) + rsp->hdr.Status = STATUS_NETWORK_SESSION_EXPIRED; + else if (rc == -ENOMEM) + rsp->hdr.Status = STATUS_INSUFFICIENT_RESOURCES; ++ else if (rc == -EOPNOTSUPP) ++ rsp->hdr.Status = STATUS_NOT_SUPPORTED; + else if (rc) + rsp->hdr.Status = STATUS_LOGON_FAILURE; + +@@ -1848,14 +1857,17 @@ int smb2_sess_setup(struct ksmbd_work *work) + if (sess->user && sess->user->flags & KSMBD_USER_FLAG_DELAY_SESSION) + try_delay = true; + +- xa_erase(&conn->sessions, sess->id); +- ksmbd_session_destroy(sess); +- work->sess = NULL; +- if (try_delay) ++ sess->last_active = jiffies; ++ sess->state = SMB2_SESSION_EXPIRED; ++ if (try_delay) { ++ ksmbd_conn_set_need_reconnect(conn); + ssleep(5); ++ ksmbd_conn_set_need_negotiate(conn); ++ } + } + } + ++ ksmbd_conn_unlock(conn); + return rc; + } + +@@ -2053,11 +2065,12 @@ int smb2_tree_disconnect(struct ksmbd_work *work) + + ksmbd_debug(SMB, "request\n"); + +- if (!tcon) { ++ if (!tcon || test_and_set_bit(TREE_CONN_EXPIRE, &tcon->status)) { + struct smb2_tree_disconnect_req *req = + smb2_get_msg(work->request_buf); + + ksmbd_debug(SMB, "Invalid tid %d\n", req->hdr.Id.SyncId.TreeId); ++ + rsp->hdr.Status = STATUS_NETWORK_NAME_DELETED; + smb2_set_err_rsp(work); + return 0; +@@ -2079,21 +2092,25 @@ int smb2_session_logoff(struct ksmbd_work *work) + { + struct ksmbd_conn *conn = work->conn; + struct smb2_logoff_rsp *rsp = smb2_get_msg(work->response_buf); +- struct ksmbd_session *sess = work->sess; ++ struct ksmbd_session *sess; ++ struct smb2_logoff_req *req = smb2_get_msg(work->request_buf); ++ u64 sess_id = le64_to_cpu(req->hdr.SessionId); + + rsp->StructureSize = cpu_to_le16(4); + inc_rfc1001_len(work->response_buf, 4); + + ksmbd_debug(SMB, "request\n"); + +- /* setting CifsExiting here may race with start_tcp_sess */ +- ksmbd_conn_set_need_reconnect(work); ++ ksmbd_all_conn_set_status(sess_id, KSMBD_SESS_NEED_RECONNECT); + ksmbd_close_session_fds(work); +- ksmbd_conn_wait_idle(conn); ++ ksmbd_conn_wait_idle(conn, sess_id); + ++ /* ++ * Re-lookup session to validate if session is deleted ++ * while waiting request complete ++ */ ++ sess = ksmbd_session_lookup_all(conn, sess_id); + if (ksmbd_tree_conn_session_logoff(sess)) { +- struct smb2_logoff_req *req = smb2_get_msg(work->request_buf); +- + ksmbd_debug(SMB, "Invalid tid %d\n", req->hdr.Id.SyncId.TreeId); + rsp->hdr.Status = STATUS_NETWORK_NAME_DELETED; + smb2_set_err_rsp(work); +@@ -2105,9 +2122,7 @@ int smb2_session_logoff(struct ksmbd_work *work) + + ksmbd_free_user(sess->user); + sess->user = NULL; +- +- /* let start_tcp_sess free connection info now */ +- ksmbd_conn_set_need_negotiate(work); ++ ksmbd_all_conn_set_status(sess_id, KSMBD_SESS_NEED_NEGOTIATE); + return 0; + } + +@@ -2143,7 +2158,7 @@ static noinline int create_smb2_pipe(struct ksmbd_work *work) rsp->hdr.Status = STATUS_SUCCESS; rsp->StructureSize = cpu_to_le16(89); rsp->OplockLevel = SMB2_OPLOCK_LEVEL_NONE; @@ -14572,7 +15595,7 @@ index 9b16ee657b51..8560e4344af0 100644 rsp->CreateAction = cpu_to_le32(FILE_OPENED); rsp->CreationTime = cpu_to_le64(0); -@@ -2149,7 +2135,7 @@ static noinline int create_smb2_pipe(struct ksmbd_work *work) +@@ -2151,7 +2166,7 @@ static noinline int create_smb2_pipe(struct ksmbd_work *work) rsp->ChangeTime = cpu_to_le64(0); rsp->AllocationSize = cpu_to_le64(0); rsp->EndofFile = cpu_to_le64(0); @@ -14581,7 +15604,131 @@ index 9b16ee657b51..8560e4344af0 100644 rsp->Reserved2 = 0; rsp->VolatileFileId = id; rsp->PersistentFileId = 0; -@@ -2395,7 +2381,7 @@ static void smb2_update_xattrs(struct ksmbd_tree_connect *tcon, +@@ -2192,7 +2207,11 @@ static noinline int create_smb2_pipe(struct ksmbd_work *work) + static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len, + const struct path *path) + { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap = mnt_idmap(path->mnt); ++#else + struct user_namespace *user_ns = mnt_user_ns(path->mnt); ++#endif + char *attr_name = NULL, *value; + int rc = 0; + unsigned int next = 0; +@@ -2228,7 +2247,11 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len, + value = (char *)&eabuf->name + eabuf->EaNameLength + 1; + + if (!eabuf->EaValueLength) { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = ksmbd_vfs_casexattr_len(idmap, ++#else + rc = ksmbd_vfs_casexattr_len(user_ns, ++#endif + path->dentry, + attr_name, + XATTR_USER_PREFIX_LEN + +@@ -2236,7 +2259,11 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len, + + /* delete the EA only when it exits */ + if (rc > 0) { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = ksmbd_vfs_remove_xattr(idmap, ++#else + rc = ksmbd_vfs_remove_xattr(user_ns, ++#endif + path->dentry, + attr_name); + +@@ -2251,7 +2278,11 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len, + /* if the EA doesn't exist, just do nothing. */ + rc = 0; + } else { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = ksmbd_vfs_setxattr(idmap, ++#else + rc = ksmbd_vfs_setxattr(user_ns, ++#endif + path->dentry, attr_name, value, + le16_to_cpu(eabuf->EaValueLength), 0); + if (rc < 0) { +@@ -2281,7 +2312,11 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path, + struct ksmbd_file *fp, + char *stream_name, int s_type) + { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap = mnt_idmap(path->mnt); ++#else + struct user_namespace *user_ns = mnt_user_ns(path->mnt); ++#endif + size_t xattr_stream_size; + char *xattr_stream_name; + int rc; +@@ -2297,7 +2332,11 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path, + fp->stream.size = xattr_stream_size; + + /* Check if there is stream prefix in xattr space */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = ksmbd_vfs_casexattr_len(idmap, ++#else + rc = ksmbd_vfs_casexattr_len(user_ns, ++#endif + path->dentry, + xattr_stream_name, + xattr_stream_size); +@@ -2309,7 +2348,11 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path, + return -EBADF; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = ksmbd_vfs_setxattr(idmap, path->dentry, ++#else + rc = ksmbd_vfs_setxattr(user_ns, path->dentry, ++#endif + xattr_stream_name, NULL, 0, 0); + if (rc < 0) + pr_err("Failed to store XATTR stream name :%d\n", rc); +@@ -2318,7 +2361,11 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path, + + static int smb2_remove_smb_xattrs(const struct path *path) + { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap = mnt_idmap(path->mnt); ++#else + struct user_namespace *user_ns = mnt_user_ns(path->mnt); ++#endif + char *name, *xattr_list = NULL; + ssize_t xattr_list_len; + int err = 0; +@@ -2338,8 +2385,13 @@ static int smb2_remove_smb_xattrs(const struct path *path) + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) && + !strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX, + STREAM_PREFIX_LEN)) { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ err = ksmbd_vfs_remove_xattr(idmap, path->dentry, ++ name); ++#else + err = ksmbd_vfs_remove_xattr(user_ns, path->dentry, + name); ++#endif + if (err) + ksmbd_debug(SMB, "remove xattr failed : %s\n", + name); +@@ -2385,8 +2437,13 @@ static void smb2_new_xattrs(struct ksmbd_tree_connect *tcon, const struct path * + da.flags = XATTR_DOSINFO_ATTRIB | XATTR_DOSINFO_CREATE_TIME | + XATTR_DOSINFO_ITIME; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = ksmbd_vfs_set_dos_attrib_xattr(mnt_idmap(path->mnt), ++ path->dentry, &da); ++#else + rc = ksmbd_vfs_set_dos_attrib_xattr(mnt_user_ns(path->mnt), + path->dentry, &da); ++#endif + if (rc) + ksmbd_debug(SMB, "failed to store file attribute into xattr\n"); + } +@@ -2397,15 +2454,20 @@ static void smb2_update_xattrs(struct ksmbd_tree_connect *tcon, struct xattr_dos_attrib da; int rc; @@ -14590,14 +15737,48 @@ index 9b16ee657b51..8560e4344af0 100644 /* get FileAttributes from XATTR_NAME_DOS_ATTRIBUTE */ if (!test_share_config_flag(tcon->share_conf, -@@ -2480,19 +2466,37 @@ static void ksmbd_acls_fattr(struct smb_fattr *fattr, + KSMBD_SHARE_FLAG_STORE_DOS_ATTRS)) + return; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = ksmbd_vfs_get_dos_attrib_xattr(mnt_idmap(path->mnt), ++ path->dentry, &da); ++#else + rc = ksmbd_vfs_get_dos_attrib_xattr(mnt_user_ns(path->mnt), + path->dentry, &da); ++#endif + if (rc > 0) { + fp->f_ci->m_fattr = cpu_to_le32(da.attr); + fp->create_time = da.create_time; +@@ -2461,7 +2523,7 @@ static int smb2_create_sd_buffer(struct ksmbd_work *work, + return -ENOENT; + + /* Parse SD BUFFER create contexts */ +- context = smb2_find_context_vals(req, SMB2_CREATE_SD_BUFFER); ++ context = smb2_find_context_vals(req, SMB2_CREATE_SD_BUFFER, 4); + if (!context) + return -ENOENT; + else if (IS_ERR(context)) +@@ -2479,22 +2541,49 @@ static int smb2_create_sd_buffer(struct ksmbd_work *work, + } + + static void ksmbd_acls_fattr(struct smb_fattr *fattr, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap, ++#else struct user_namespace *mnt_userns, ++#endif struct inode *inode) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ vfsuid_t vfsuid = i_uid_into_vfsuid(idmap, inode); ++ vfsgid_t vfsgid = i_gid_into_vfsgid(idmap, inode); ++#else vfsuid_t vfsuid = i_uid_into_vfsuid(mnt_userns, inode); vfsgid_t vfsgid = i_gid_into_vfsgid(mnt_userns, inode); ++#endif fattr->cf_uid = vfsuid_into_kuid(vfsuid); fattr->cf_gid = vfsgid_into_kgid(vfsgid); @@ -14628,7 +15809,19 @@ index 9b16ee657b51..8560e4344af0 100644 } } -@@ -2557,7 +2561,8 @@ int smb2_open(struct ksmbd_work *work) +@@ -2515,7 +2604,11 @@ int smb2_open(struct ksmbd_work *work) + struct ksmbd_share_config *share = tcon->share_conf; + struct ksmbd_file *fp = NULL; + struct file *filp = NULL; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap = NULL; ++#else + struct user_namespace *user_ns = NULL; ++#endif + struct kstat stat; + struct create_context *context; + struct lease_ctx_info *lc = NULL; +@@ -2559,7 +2652,8 @@ int smb2_open(struct ksmbd_work *work) goto err_out1; } @@ -14638,7 +15831,7 @@ index 9b16ee657b51..8560e4344af0 100644 le16_to_cpu(req->NameLength), work->conn->local_nls); if (IS_ERR(name)) { -@@ -2602,7 +2607,7 @@ int smb2_open(struct ksmbd_work *work) +@@ -2604,7 +2698,7 @@ int smb2_open(struct ksmbd_work *work) if (req_op_level == SMB2_OPLOCK_LEVEL_LEASE) lc = parse_lease_state(req); @@ -14647,7 +15840,7 @@ index 9b16ee657b51..8560e4344af0 100644 pr_err("Invalid impersonationlevel : 0x%x\n", le32_to_cpu(req->ImpersonationLevel)); rc = -EIO; -@@ -2610,7 +2615,7 @@ int smb2_open(struct ksmbd_work *work) +@@ -2612,7 +2706,7 @@ int smb2_open(struct ksmbd_work *work) goto err_out1; } @@ -14656,7 +15849,7 @@ index 9b16ee657b51..8560e4344af0 100644 pr_err("Invalid create options : 0x%x\n", le32_to_cpu(req->CreateOptions)); rc = -EINVAL; -@@ -2652,7 +2657,7 @@ int smb2_open(struct ksmbd_work *work) +@@ -2654,7 +2748,7 @@ int smb2_open(struct ksmbd_work *work) goto err_out1; } @@ -14665,19 +15858,59 @@ index 9b16ee657b51..8560e4344af0 100644 pr_err("Invalid file attribute : 0x%x\n", le32_to_cpu(req->FileAttributes)); rc = -EINVAL; -@@ -2766,7 +2771,11 @@ int smb2_open(struct ksmbd_work *work) +@@ -2663,7 +2757,7 @@ int smb2_open(struct ksmbd_work *work) + + if (req->CreateContextsOffset) { + /* Parse non-durable handle create contexts */ +- context = smb2_find_context_vals(req, SMB2_CREATE_EA_BUFFER); ++ context = smb2_find_context_vals(req, SMB2_CREATE_EA_BUFFER, 4); + if (IS_ERR(context)) { + rc = PTR_ERR(context); + goto err_out1; +@@ -2683,7 +2777,7 @@ int smb2_open(struct ksmbd_work *work) + } + + context = smb2_find_context_vals(req, +- SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST); ++ SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST, 4); + if (IS_ERR(context)) { + rc = PTR_ERR(context); + goto err_out1; +@@ -2694,7 +2788,7 @@ int smb2_open(struct ksmbd_work *work) + } + + context = smb2_find_context_vals(req, +- SMB2_CREATE_TIMEWARP_REQUEST); ++ SMB2_CREATE_TIMEWARP_REQUEST, 4); + if (IS_ERR(context)) { + rc = PTR_ERR(context); + goto err_out1; +@@ -2706,7 +2800,7 @@ int smb2_open(struct ksmbd_work *work) + + if (tcon->posix_extensions) { + context = smb2_find_context_vals(req, +- SMB2_CREATE_TAG_POSIX); ++ SMB2_CREATE_TAG_POSIX, 16); + if (IS_ERR(context)) { + rc = PTR_ERR(context); + goto err_out1; +@@ -2768,7 +2862,15 @@ int smb2_open(struct ksmbd_work *work) rc = 0; } else { file_present = true; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ idmap = mnt_idmap(path.mnt); ++#else user_ns = mnt_user_ns(path.mnt); ++#endif +#else + user_ns = NULL; +#endif } if (stream_name) { if (req->CreateOptions & FILE_DIRECTORY_FILE_LE) { -@@ -2783,7 +2792,7 @@ int smb2_open(struct ksmbd_work *work) +@@ -2785,7 +2887,7 @@ int smb2_open(struct ksmbd_work *work) } if (req->CreateOptions & FILE_DIRECTORY_FILE_LE && @@ -14686,12 +15919,40 @@ index 9b16ee657b51..8560e4344af0 100644 rsp->hdr.Status = STATUS_NOT_A_DIRECTORY; rc = -EIO; } -@@ -2887,9 +2896,13 @@ int smb2_open(struct ksmbd_work *work) +@@ -2831,7 +2933,11 @@ int smb2_open(struct ksmbd_work *work) + if (!file_present) { + daccess = cpu_to_le32(GENERIC_ALL_FLAGS); + } else { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = ksmbd_vfs_query_maximal_access(idmap, ++#else + rc = ksmbd_vfs_query_maximal_access(user_ns, ++#endif + path.dentry, + &daccess); + if (rc) +@@ -2867,7 +2973,11 @@ int smb2_open(struct ksmbd_work *work) + } + + created = true; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ idmap = mnt_idmap(path.mnt); ++#else + user_ns = mnt_user_ns(path.mnt); ++#endif + if (ea_buf) { + if (le32_to_cpu(ea_buf->ccontext.DataLength) < + sizeof(struct smb2_ea_info)) { +@@ -2889,15 +2999,27 @@ int smb2_open(struct ksmbd_work *work) * is already granted. */ if (daccess & ~(FILE_READ_ATTRIBUTES_LE | FILE_READ_CONTROL_LE)) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = inode_permission(idmap, ++#else rc = inode_permission(user_ns, ++#endif d_inode(path.dentry), may_flags); +#else @@ -14700,38 +15961,103 @@ index 9b16ee657b51..8560e4344af0 100644 if (rc) goto err_out; -@@ -2959,7 +2972,7 @@ int smb2_open(struct ksmbd_work *work) + if ((daccess & FILE_DELETE_LE) || + (req->CreateOptions & FILE_DELETE_ON_CLOSE_LE)) { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = ksmbd_vfs_may_delete(idmap, ++#else + rc = ksmbd_vfs_may_delete(user_ns, ++#endif + path.dentry); + if (rc) + goto err_out; +@@ -2960,9 +3082,15 @@ int smb2_open(struct ksmbd_work *work) + int posix_acl_rc; struct inode *inode = d_inode(path.dentry); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ posix_acl_rc = ksmbd_vfs_inherit_posix_acl(idmap, ++ path.dentry, ++ d_inode(path.dentry->d_parent)); ++#else posix_acl_rc = ksmbd_vfs_inherit_posix_acl(user_ns, - inode, + path.dentry, d_inode(path.dentry->d_parent)); ++#endif if (posix_acl_rc) ksmbd_debug(SMB, "inherit posix acl failed : %d\n", posix_acl_rc); -@@ -2975,7 +2988,7 @@ int smb2_open(struct ksmbd_work *work) + +@@ -2976,8 +3104,13 @@ int smb2_open(struct ksmbd_work *work) + rc = smb2_create_sd_buffer(work, req, &path); if (rc) { if (posix_acl_rc) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ ksmbd_vfs_set_init_posix_acl(idmap, ++ path.dentry); ++#else ksmbd_vfs_set_init_posix_acl(user_ns, - inode); + path.dentry); ++#endif if (test_share_config_flag(work->tcon->share_conf, KSMBD_SHARE_FLAG_ACL_XATTR)) { -@@ -2994,8 +3007,11 @@ int smb2_open(struct ksmbd_work *work) - sizeof(struct smb_acl) + - sizeof(struct smb_ace) * ace_num * 2, - GFP_KERNEL); -- if (!pntsd) -+ if (!pntsd) { -+ posix_acl_release(fattr.cf_acls); -+ posix_acl_release(fattr.cf_dacls); +@@ -2985,7 +3118,11 @@ int smb2_open(struct ksmbd_work *work) + struct smb_ntsd *pntsd; + int pntsd_size, ace_num = 0; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ ksmbd_acls_fattr(&fattr, idmap, inode); ++#else + ksmbd_acls_fattr(&fattr, user_ns, inode); ++#endif + if (fattr.cf_acls) + ace_num = fattr.cf_acls->a_count; + if (fattr.cf_dacls) +@@ -3002,7 +3139,11 @@ int smb2_open(struct ksmbd_work *work) goto err_out; -+ } + } ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = build_sec_desc(idmap, ++#else rc = build_sec_desc(user_ns, ++#endif pntsd, NULL, 0, -@@ -3161,7 +3177,7 @@ int smb2_open(struct ksmbd_work *work) + OWNER_SECINFO | + GROUP_SECINFO | +@@ -3016,7 +3157,11 @@ int smb2_open(struct ksmbd_work *work) + } + + rc = ksmbd_vfs_set_sd_xattr(conn, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ idmap, ++#else + user_ns, ++#endif + path.dentry, + pntsd, + pntsd_size); +@@ -3105,7 +3250,7 @@ int smb2_open(struct ksmbd_work *work) + struct create_alloc_size_req *az_req; + + az_req = (struct create_alloc_size_req *)smb2_find_context_vals(req, +- SMB2_CREATE_ALLOCATION_SIZE); ++ SMB2_CREATE_ALLOCATION_SIZE, 4); + if (IS_ERR(az_req)) { + rc = PTR_ERR(az_req); + goto err_out; +@@ -3132,7 +3277,7 @@ int smb2_open(struct ksmbd_work *work) + err); + } + +- context = smb2_find_context_vals(req, SMB2_CREATE_QUERY_ON_DISK_ID); ++ context = smb2_find_context_vals(req, SMB2_CREATE_QUERY_ON_DISK_ID, 4); + if (IS_ERR(context)) { + rc = PTR_ERR(context); + goto err_out; +@@ -3166,7 +3311,7 @@ int smb2_open(struct ksmbd_work *work) opinfo = rcu_dereference(fp->f_opinfo); rsp->OplockLevel = opinfo != NULL ? opinfo->level : 0; rcu_read_unlock(); @@ -14740,7 +16066,19 @@ index 9b16ee657b51..8560e4344af0 100644 rsp->CreateAction = cpu_to_le32(file_info); rsp->CreationTime = cpu_to_le64(fp->create_time); time = ksmbd_UnixTimeToNT(stat.atime); -@@ -3441,7 +3457,7 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level, +@@ -3212,7 +3357,11 @@ int smb2_open(struct ksmbd_work *work) + struct create_context *mxac_ccontext; + + if (maximal_access == 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ ksmbd_vfs_query_maximal_access(idmap, ++#else + ksmbd_vfs_query_maximal_access(user_ns, ++#endif + path.dentry, + &maximal_access); + mxac_ccontext = (struct create_context *)(rsp->Buffer + +@@ -3446,7 +3595,7 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level, goto free_conv_name; } @@ -14749,7 +16087,7 @@ index 9b16ee657b51..8560e4344af0 100644 next_entry_offset = ALIGN(struct_sz, KSMBD_DIR_INFO_ALIGNMENT); d_info->last_entry_off_align = next_entry_offset - struct_sz; -@@ -3465,9 +3481,9 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level, +@@ -3470,9 +3619,9 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level, ffdinfo->EaSize = smb2_get_reparse_tag_special_file(ksmbd_kstat->kstat->mode); if (ffdinfo->EaSize) @@ -14761,7 +16099,7 @@ index 9b16ee657b51..8560e4344af0 100644 memcpy(ffdinfo->FileName, conv_name, conv_len); ffdinfo->NextEntryOffset = cpu_to_le32(next_entry_offset); break; -@@ -3481,11 +3497,11 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level, +@@ -3486,11 +3635,11 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level, fbdinfo->EaSize = smb2_get_reparse_tag_special_file(ksmbd_kstat->kstat->mode); if (fbdinfo->EaSize) @@ -14775,7 +16113,7 @@ index 9b16ee657b51..8560e4344af0 100644 memcpy(fbdinfo->FileName, conv_name, conv_len); fbdinfo->NextEntryOffset = cpu_to_le32(next_entry_offset); break; -@@ -3497,7 +3513,7 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level, +@@ -3502,7 +3651,7 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level, fdinfo = (struct file_directory_info *)kstat; fdinfo->FileNameLength = cpu_to_le32(conv_len); if (d_info->hide_dot_file && d_info->name[0] == '.') @@ -14784,7 +16122,7 @@ index 9b16ee657b51..8560e4344af0 100644 memcpy(fdinfo->FileName, conv_name, conv_len); fdinfo->NextEntryOffset = cpu_to_le32(next_entry_offset); break; -@@ -3521,11 +3537,11 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level, +@@ -3526,11 +3675,11 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level, dinfo->EaSize = smb2_get_reparse_tag_special_file(ksmbd_kstat->kstat->mode); if (dinfo->EaSize) @@ -14798,7 +16136,7 @@ index 9b16ee657b51..8560e4344af0 100644 memcpy(dinfo->FileName, conv_name, conv_len); dinfo->NextEntryOffset = cpu_to_le32(next_entry_offset); break; -@@ -3539,13 +3555,13 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level, +@@ -3544,13 +3693,13 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level, fibdinfo->EaSize = smb2_get_reparse_tag_special_file(ksmbd_kstat->kstat->mode); if (fibdinfo->EaSize) @@ -14814,7 +16152,7 @@ index 9b16ee657b51..8560e4344af0 100644 memcpy(fibdinfo->FileName, conv_name, conv_len); fibdinfo->NextEntryOffset = cpu_to_le32(next_entry_offset); break; -@@ -3571,14 +3587,13 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level, +@@ -3576,14 +3725,13 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level, posix_info->Mode = cpu_to_le32(ksmbd_kstat->kstat->mode & 0777); posix_info->Inode = cpu_to_le64(ksmbd_kstat->kstat->ino); posix_info->DosAttributes = @@ -14832,12 +16170,28 @@ index 9b16ee657b51..8560e4344af0 100644 */ id_to_sid(from_kuid_munged(&init_user_ns, ksmbd_kstat->kstat->uid), SIDUNIX_USER, (struct smb_sid *)&posix_info->SidBuffer[0]); -@@ -3645,9 +3660,15 @@ static int process_query_dir_entries(struct smb2_query_dir_private *priv) +@@ -3637,7 +3785,11 @@ static void unlock_dir(struct ksmbd_file *dir_fp) + + static int process_query_dir_entries(struct smb2_query_dir_private *priv) + { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap = file_mnt_idmap(priv->dir_fp->filp); ++#else + struct user_namespace *user_ns = file_mnt_user_ns(priv->dir_fp->filp); ++#endif + struct kstat kstat; + struct ksmbd_kstat ksmbd_kstat; + int rc; +@@ -3650,9 +3802,19 @@ static int process_query_dir_entries(struct smb2_query_dir_private *priv) return -EINVAL; lock_dir(priv->dir_fp); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ dent = lookup_one(idmap, priv->d_info->name, ++#else dent = lookup_one(user_ns, priv->d_info->name, ++#endif priv->dir_fp->filp->f_path.dentry, priv->d_info->name_len); +#else @@ -14848,7 +16202,20 @@ index 9b16ee657b51..8560e4344af0 100644 unlock_dir(priv->dir_fp); if (IS_ERR(dent)) { -@@ -3693,7 +3714,7 @@ static int reserve_populate_dentry(struct ksmbd_dir_info *d_info, +@@ -3671,7 +3833,12 @@ static int process_query_dir_entries(struct smb2_query_dir_private *priv) + ksmbd_kstat.kstat = &kstat; + if (priv->info_level != FILE_NAMES_INFORMATION) + ksmbd_vfs_fill_dentry_attrs(priv->work, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ idmap, ++#else + user_ns, ++#endif ++ + dent, + &ksmbd_kstat); + +@@ -3698,7 +3865,7 @@ static int reserve_populate_dentry(struct ksmbd_dir_info *d_info, return -EOPNOTSUPP; conv_len = (d_info->name_len + 1) * 2; @@ -14857,7 +16224,7 @@ index 9b16ee657b51..8560e4344af0 100644 KSMBD_DIR_INFO_ALIGNMENT); if (next_entry_offset > d_info->out_buf_len) { -@@ -3788,7 +3809,11 @@ static int reserve_populate_dentry(struct ksmbd_dir_info *d_info, +@@ -3793,7 +3960,11 @@ static int reserve_populate_dentry(struct ksmbd_dir_info *d_info, return 0; } @@ -14869,7 +16236,7 @@ index 9b16ee657b51..8560e4344af0 100644 loff_t offset, u64 ino, unsigned int d_type) { struct ksmbd_readdir_data *buf; -@@ -3802,20 +3827,46 @@ static bool __query_dir(struct dir_context *ctx, const char *name, int namlen, +@@ -3807,20 +3978,46 @@ static bool __query_dir(struct dir_context *ctx, const char *name, int namlen, /* dot and dotdot entries are already reserved */ if (!strcmp(".", name) || !strcmp("..", name)) @@ -14917,13 +16284,17 @@ index 9b16ee657b51..8560e4344af0 100644 } static int verify_info_level(int info_level) -@@ -3895,10 +3946,15 @@ int smb2_query_dir(struct ksmbd_work *work) +@@ -3900,10 +4097,19 @@ int smb2_query_dir(struct ksmbd_work *work) goto err_out2; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) if (!(dir_fp->daccess & FILE_LIST_DIRECTORY_LE) || ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ inode_permission(file_mnt_idmap(dir_fp->filp), ++#else inode_permission(file_mnt_user_ns(dir_fp->filp), ++#endif file_inode(dir_fp->filp), MAY_READ | MAY_EXEC)) { +#else @@ -14933,115 +16304,171 @@ index 9b16ee657b51..8560e4344af0 100644 pr_err("no right to enumerate directory (%pD)\n", dir_fp->filp); rc = -EACCES; goto err_out2; -@@ -4332,8 +4388,11 @@ static int get_file_basic_info(struct smb2_query_info_rsp *rsp, +@@ -4167,7 +4373,11 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp, + ssize_t buf_free_len, alignment_bytes, next_offset, rsp_data_cnt = 0; + struct smb2_ea_info_req *ea_req = NULL; + const struct path *path; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap = file_mnt_idmap(fp->filp); ++#else + struct user_namespace *user_ns = file_mnt_user_ns(fp->filp); ++#endif + + if (!(fp->daccess & FILE_READ_EA_LE)) { + pr_err("Not permitted to read ext attr : 0x%x\n", +@@ -4247,7 +4457,11 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp, + buf_free_len -= (offsetof(struct smb2_ea_info, name) + + name_len + 1); + /* bailout if xattr can't fit in buf_free_len */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ value_len = ksmbd_vfs_getxattr(idmap, path->dentry, ++#else + value_len = ksmbd_vfs_getxattr(user_ns, path->dentry, ++#endif + name, &buf); + if (value_len <= 0) { + rc = -ENOENT; +@@ -4337,8 +4551,17 @@ static int get_file_basic_info(struct smb2_query_info_rsp *rsp, } basic_info = (struct smb2_file_basic_info *)rsp->Buffer; -- generic_fillattr(file_mnt_user_ns(fp->filp), file_inode(fp->filp), -- &stat); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) -+ generic_fillattr(file_mnt_user_ns(fp->filp), file_inode(fp->filp), &stat); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ generic_fillattr(file_mnt_idmap(fp->filp), file_inode(fp->filp), ++ &stat); ++#else + generic_fillattr(file_mnt_user_ns(fp->filp), file_inode(fp->filp), + &stat); ++#endif +#else + generic_fillattr(file_inode(fp->filp), &stat); +#endif basic_info->CreationTime = cpu_to_le64(fp->create_time); time = ksmbd_UnixTimeToNT(stat.atime); basic_info->LastAccessTime = cpu_to_le64(time); -@@ -4373,7 +4432,11 @@ static void get_file_standard_info(struct smb2_query_info_rsp *rsp, +@@ -4378,7 +4601,15 @@ static void get_file_standard_info(struct smb2_query_info_rsp *rsp, struct kstat stat; inode = file_inode(fp->filp); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ generic_fillattr(file_mnt_idmap(fp->filp), inode, &stat); ++#else generic_fillattr(file_mnt_user_ns(fp->filp), inode, &stat); ++#endif +#else + generic_fillattr(inode, &stat); +#endif sinfo = (struct smb2_file_standard_info *)rsp->Buffer; delete_pending = ksmbd_inode_pending_delete(fp); -@@ -4427,7 +4490,11 @@ static int get_file_all_info(struct ksmbd_work *work, +@@ -4432,7 +4663,15 @@ static int get_file_all_info(struct ksmbd_work *work, return PTR_ERR(filename); inode = file_inode(fp->filp); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ generic_fillattr(file_mnt_idmap(fp->filp), inode, &stat); ++#else generic_fillattr(file_mnt_user_ns(fp->filp), inode, &stat); ++#endif +#else + generic_fillattr(inode, &stat); +#endif ksmbd_debug(SMB, "filename = %s\n", filename); delete_pending = ksmbd_inode_pending_delete(fp); -@@ -4504,8 +4571,11 @@ static void get_file_stream_info(struct ksmbd_work *work, +@@ -4509,8 +4748,17 @@ static void get_file_stream_info(struct ksmbd_work *work, int buf_free_len; struct smb2_query_info_req *req = ksmbd_req_buf_next(work); -- generic_fillattr(file_mnt_user_ns(fp->filp), file_inode(fp->filp), -- &stat); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) -+ generic_fillattr(file_mnt_user_ns(fp->filp), file_inode(fp->filp), &stat); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ generic_fillattr(file_mnt_idmap(fp->filp), file_inode(fp->filp), ++ &stat); ++#else + generic_fillattr(file_mnt_user_ns(fp->filp), file_inode(fp->filp), + &stat); ++#endif +#else + generic_fillattr(file_inode(fp->filp), &stat); +#endif file_info = (struct smb2_file_stream_info *)rsp->Buffer; buf_free_len = -@@ -4595,8 +4665,11 @@ static void get_file_internal_info(struct smb2_query_info_rsp *rsp, +@@ -4600,8 +4848,17 @@ static void get_file_internal_info(struct smb2_query_info_rsp *rsp, struct smb2_file_internal_info *file_info; struct kstat stat; -- generic_fillattr(file_mnt_user_ns(fp->filp), file_inode(fp->filp), -- &stat); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) -+ generic_fillattr(file_mnt_user_ns(fp->filp), file_inode(fp->filp), &stat); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ generic_fillattr(file_mnt_idmap(fp->filp), file_inode(fp->filp), ++ &stat); ++#else + generic_fillattr(file_mnt_user_ns(fp->filp), file_inode(fp->filp), + &stat); ++#endif +#else + generic_fillattr(file_inode(fp->filp), &stat); +#endif file_info = (struct smb2_file_internal_info *)rsp->Buffer; file_info->IndexNumber = cpu_to_le64(stat.ino); rsp->OutputBufferLength = -@@ -4621,7 +4694,11 @@ static int get_file_network_open_info(struct smb2_query_info_rsp *rsp, +@@ -4626,7 +4883,15 @@ static int get_file_network_open_info(struct smb2_query_info_rsp *rsp, file_info = (struct smb2_file_ntwrk_info *)rsp->Buffer; inode = file_inode(fp->filp); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ generic_fillattr(file_mnt_idmap(fp->filp), inode, &stat); ++#else generic_fillattr(file_mnt_user_ns(fp->filp), inode, &stat); ++#endif +#else + generic_fillattr(inode, &stat); +#endif file_info->CreationTime = cpu_to_le64(fp->create_time); time = ksmbd_UnixTimeToNT(stat.atime); -@@ -4682,8 +4759,11 @@ static void get_file_compression_info(struct smb2_query_info_rsp *rsp, +@@ -4687,8 +4952,17 @@ static void get_file_compression_info(struct smb2_query_info_rsp *rsp, struct smb2_file_comp_info *file_info; struct kstat stat; -- generic_fillattr(file_mnt_user_ns(fp->filp), file_inode(fp->filp), -- &stat); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) -+ generic_fillattr(file_mnt_user_ns(fp->filp), file_inode(fp->filp), &stat); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ generic_fillattr(file_mnt_idmap(fp->filp), file_inode(fp->filp), ++ &stat); ++#else + generic_fillattr(file_mnt_user_ns(fp->filp), file_inode(fp->filp), + &stat); ++#endif +#else + generic_fillattr(file_inode(fp->filp), &stat); +#endif file_info = (struct smb2_file_comp_info *)rsp->Buffer; file_info->CompressedFileSize = cpu_to_le64(stat.blocks << 9); -@@ -4723,10 +4803,14 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp, +@@ -4728,9 +5002,19 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp, { struct smb311_posix_qinfo *file_info; struct inode *inode = file_inode(fp->filp); -+ u64 time; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap = file_mnt_idmap(fp->filp); ++ vfsuid_t vfsuid = i_uid_into_vfsuid(idmap, inode); ++ vfsgid_t vfsgid = i_gid_into_vfsgid(idmap, inode); ++#else +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) struct user_namespace *user_ns = file_mnt_user_ns(fp->filp); +#endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0) vfsuid_t vfsuid = i_uid_into_vfsuid(user_ns, inode); vfsgid_t vfsgid = i_gid_into_vfsgid(user_ns, inode); -- u64 time; +#endif ++#endif + u64 time; int out_buf_len = sizeof(struct smb311_posix_qinfo) + 32; - file_info = (struct smb311_posix_qinfo *)rsp->Buffer; -@@ -4744,15 +4828,32 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp, +@@ -4749,15 +5033,32 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp, file_info->HardLinks = cpu_to_le32(inode->i_nlink); file_info->Mode = cpu_to_le32(inode->i_mode & 0777); file_info->DeviceId = cpu_to_le32(inode->i_rdev); @@ -15075,18 +16502,77 @@ index 9b16ee657b51..8560e4344af0 100644 SIDUNIX_GROUP, (struct smb_sid *)&file_info->Sids[16]); rsp->OutputBufferLength = cpu_to_le32(out_buf_len); -@@ -4951,6 +5052,10 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work, - - info->Attributes |= cpu_to_le32(server_conf.share_fake_fscaps); +@@ -4912,6 +5213,9 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work, + int rc = 0, len; + int fs_infoclass_size = 0; -+ if (test_share_config_flag(work->tcon->share_conf, -+ KSMBD_SHARE_FLAG_STREAMS)) -+ info->Attributes |= cpu_to_le32(FILE_NAMED_STREAMS); ++ if (!share->path) ++ return -EIO; + - info->MaxPathNameComponentLength = cpu_to_le32(stfs.f_namelen); - len = smbConvertToUTF16((__le16 *)info->FileSystemName, - "NTFS", PATH_MAX, conn->local_nls, 0); -@@ -5445,7 +5550,8 @@ static int smb2_rename(struct ksmbd_work *work, + rc = kern_path(share->path, LOOKUP_NO_SYMLINKS, &path); + if (rc) { + pr_err("cannot create vfs path\n"); +@@ -5134,7 +5438,11 @@ static int smb2_get_info_sec(struct ksmbd_work *work, + struct smb2_query_info_rsp *rsp) + { + struct ksmbd_file *fp; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap; ++#else + struct user_namespace *user_ns; ++#endif + struct smb_ntsd *pntsd = (struct smb_ntsd *)rsp->Buffer, *ppntsd = NULL; + struct smb_fattr fattr = {{0}}; + struct inode *inode; +@@ -5181,19 +5489,35 @@ static int smb2_get_info_sec(struct ksmbd_work *work, + if (!fp) + return -ENOENT; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ idmap = file_mnt_idmap(fp->filp); ++#else + user_ns = file_mnt_user_ns(fp->filp); ++#endif + inode = file_inode(fp->filp); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ ksmbd_acls_fattr(&fattr, idmap, inode); ++#else + ksmbd_acls_fattr(&fattr, user_ns, inode); ++#endif + + if (test_share_config_flag(work->tcon->share_conf, + KSMBD_SHARE_FLAG_ACL_XATTR)) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ ppntsd_size = ksmbd_vfs_get_sd_xattr(work->conn, idmap, ++#else + ppntsd_size = ksmbd_vfs_get_sd_xattr(work->conn, user_ns, ++#endif + fp->filp->f_path.dentry, + &ppntsd); + + /* Check if sd buffer size exceeds response buffer size */ + if (smb2_resp_buf_len(work, 8) > ppntsd_size) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = build_sec_desc(idmap, pntsd, ppntsd, ppntsd_size, ++#else + rc = build_sec_desc(user_ns, pntsd, ppntsd, ppntsd_size, ++#endif + addition_info, &secdesclen, &fattr); + posix_acl_release(fattr.cf_acls); + posix_acl_release(fattr.cf_dacls); +@@ -5423,7 +5747,11 @@ int smb2_echo(struct ksmbd_work *work) + + static int smb2_rename(struct ksmbd_work *work, + struct ksmbd_file *fp, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap, ++#else + struct user_namespace *user_ns, ++#endif + struct smb2_file_rename_info *file_info, + struct nls_table *local_nls) + { +@@ -5454,7 +5782,8 @@ static int smb2_rename(struct ksmbd_work *work, goto out; } @@ -15096,7 +16582,19 @@ index 9b16ee657b51..8560e4344af0 100644 le32_to_cpu(file_info->FileNameLength), local_nls); if (IS_ERR(new_name)) { -@@ -5556,7 +5662,8 @@ static int smb2_create_link(struct ksmbd_work *work, +@@ -5486,7 +5815,11 @@ static int smb2_rename(struct ksmbd_work *work, + if (rc) + goto out; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = ksmbd_vfs_setxattr(idmap, ++#else + rc = ksmbd_vfs_setxattr(user_ns, ++#endif + fp->filp->f_path.dentry, + xattr_stream_name, + NULL, 0, 0); +@@ -5565,7 +5898,8 @@ static int smb2_create_link(struct ksmbd_work *work, if (!pathname) return -ENOMEM; @@ -15106,7 +16604,31 @@ index 9b16ee657b51..8560e4344af0 100644 le32_to_cpu(file_info->FileNameLength), local_nls); if (IS_ERR(link_name) || S_ISDIR(file_inode(filp)->i_mode)) { -@@ -5648,14 +5755,14 @@ static int set_file_basic_info(struct ksmbd_file *fp, +@@ -5625,7 +5959,11 @@ static int set_file_basic_info(struct ksmbd_file *fp, + struct iattr attrs; + struct file *filp; + struct inode *inode; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap; ++#else + struct user_namespace *user_ns; ++#endif + int rc = 0; + + if (!(fp->daccess & FILE_WRITE_ATTRIBUTES_LE)) +@@ -5634,7 +5972,11 @@ static int set_file_basic_info(struct ksmbd_file *fp, + attrs.ia_valid = 0; + filp = fp->filp; + inode = file_inode(filp); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ idmap = file_mnt_idmap(filp); ++#else + user_ns = file_mnt_user_ns(filp); ++#endif + + if (file_info->CreationTime) + fp->create_time = le64_to_cpu(file_info->CreationTime); +@@ -5657,14 +5999,14 @@ static int set_file_basic_info(struct ksmbd_file *fp, if (file_info->Attributes) { if (!S_ISDIR(inode->i_mode) && @@ -15124,12 +16646,28 @@ index 9b16ee657b51..8560e4344af0 100644 } if (test_share_config_flag(share, KSMBD_SHARE_FLAG_STORE_DOS_ATTRS) && -@@ -5687,8 +5794,14 @@ static int set_file_basic_info(struct ksmbd_file *fp, +@@ -5678,7 +6020,11 @@ static int set_file_basic_info(struct ksmbd_file *fp, + da.flags = XATTR_DOSINFO_ATTRIB | XATTR_DOSINFO_CREATE_TIME | + XATTR_DOSINFO_ITIME; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = ksmbd_vfs_set_dos_attrib_xattr(idmap, ++#else + rc = ksmbd_vfs_set_dos_attrib_xattr(user_ns, ++#endif + filp->f_path.dentry, &da); + if (rc) + ksmbd_debug(SMB, +@@ -5696,8 +6042,18 @@ static int set_file_basic_info(struct ksmbd_file *fp, inode_lock(inode); inode->i_ctime = attrs.ia_ctime; attrs.ia_valid &= ~ATTR_CTIME; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = notify_change(idmap, dentry, &attrs, NULL); ++#else rc = notify_change(user_ns, dentry, &attrs, NULL); ++#endif +#else + rc = notify_change(dentry, &attrs, NULL); +#endif @@ -15139,7 +16677,52 @@ index 9b16ee657b51..8560e4344af0 100644 } return rc; } -@@ -5875,7 +5988,9 @@ static int set_file_mode_info(struct ksmbd_file *fp, +@@ -5789,7 +6145,11 @@ static int set_rename_info(struct ksmbd_work *work, struct ksmbd_file *fp, + struct smb2_file_rename_info *rename_info, + unsigned int buf_len) + { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap; ++#else + struct user_namespace *user_ns; ++#endif + struct ksmbd_file *parent_fp; + struct dentry *parent; + struct dentry *dentry = fp->filp->f_path.dentry; +@@ -5804,12 +6164,20 @@ static int set_rename_info(struct ksmbd_work *work, struct ksmbd_file *fp, + le32_to_cpu(rename_info->FileNameLength)) + return -EINVAL; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ idmap = file_mnt_idmap(fp->filp); ++#else + user_ns = file_mnt_user_ns(fp->filp); ++#endif + if (ksmbd_stream_fd(fp)) + goto next; + + parent = dget_parent(dentry); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ ret = ksmbd_vfs_lock_parent(idmap, parent, dentry); ++#else + ret = ksmbd_vfs_lock_parent(user_ns, parent, dentry); ++#endif + if (ret) { + dput(parent); + return ret; +@@ -5828,7 +6196,11 @@ static int set_rename_info(struct ksmbd_work *work, struct ksmbd_file *fp, + ksmbd_fd_put(work, parent_fp); + } + next: ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ return smb2_rename(work, fp, idmap, rename_info, ++#else + return smb2_rename(work, fp, user_ns, rename_info, ++#endif + work->conn->local_nls); + } + +@@ -5884,7 +6256,9 @@ static int set_file_mode_info(struct ksmbd_file *fp, mode = file_info->Mode; @@ -15150,7 +16733,7 @@ index 9b16ee657b51..8560e4344af0 100644 pr_err("Mode is not valid : 0x%x\n", le32_to_cpu(mode)); return -EINVAL; } -@@ -6154,7 +6269,7 @@ static noinline int smb2_read_pipe(struct ksmbd_work *work) +@@ -6163,7 +6537,7 @@ static noinline int smb2_read_pipe(struct ksmbd_work *work) rsp->Reserved = 0; rsp->DataLength = cpu_to_le32(nbytes); rsp->DataRemaining = 0; @@ -15159,7 +16742,7 @@ index 9b16ee657b51..8560e4344af0 100644 inc_rfc1001_len(work->response_buf, nbytes); return 0; -@@ -6330,7 +6445,7 @@ int smb2_read(struct ksmbd_work *work) +@@ -6339,7 +6713,7 @@ int smb2_read(struct ksmbd_work *work) rsp->Reserved = 0; rsp->DataLength = cpu_to_le32(nbytes); rsp->DataRemaining = cpu_to_le32(remain_bytes); @@ -15168,47 +16751,7 @@ index 9b16ee657b51..8560e4344af0 100644 inc_rfc1001_len(work->response_buf, 16); work->resp_hdr_sz = get_rfc1002_len(work->response_buf) + 4; work->aux_payload_sz = nbytes; -@@ -6642,7 +6757,7 @@ int smb2_cancel(struct ksmbd_work *work) - struct ksmbd_conn *conn = work->conn; - struct smb2_hdr *hdr = smb2_get_msg(work->request_buf); - struct smb2_hdr *chdr; -- struct ksmbd_work *cancel_work = NULL, *iter; -+ struct ksmbd_work *iter; - struct list_head *command_list; - - ksmbd_debug(SMB, "smb2 cancel called on mid %llu, async flags 0x%x\n", -@@ -6664,7 +6779,9 @@ int smb2_cancel(struct ksmbd_work *work) - "smb2 with AsyncId %llu cancelled command = 0x%x\n", - le64_to_cpu(hdr->Id.AsyncId), - le16_to_cpu(chdr->Command)); -- cancel_work = iter; -+ iter->state = KSMBD_WORK_CANCELLED; -+ if (iter->cancel_fn) -+ iter->cancel_fn(iter->cancel_argv); - break; - } - spin_unlock(&conn->request_lock); -@@ -6683,18 +6800,12 @@ int smb2_cancel(struct ksmbd_work *work) - "smb2 with mid %llu cancelled command = 0x%x\n", - le64_to_cpu(hdr->MessageId), - le16_to_cpu(chdr->Command)); -- cancel_work = iter; -+ iter->state = KSMBD_WORK_CANCELLED; - break; - } - spin_unlock(&conn->request_lock); - } - -- if (cancel_work) { -- cancel_work->state = KSMBD_WORK_CANCELLED; -- if (cancel_work->cancel_fn) -- cancel_work->cancel_fn(cancel_work->cancel_argv); -- } -- - /* For SMB2_CANCEL command itself send no response*/ - work->send_no_response = 1; - return 0; -@@ -6754,7 +6865,7 @@ static int smb2_set_flock_flags(struct file_lock *flock, int flags) +@@ -6759,7 +7133,7 @@ static int smb2_set_flock_flags(struct file_lock *flock, int flags) case SMB2_LOCKFLAG_UNLOCK: ksmbd_debug(SMB, "received unlock request\n"); flock->fl_type = F_UNLCK; @@ -15217,7 +16760,7 @@ index 9b16ee657b51..8560e4344af0 100644 break; } -@@ -6858,6 +6969,7 @@ int smb2_lock(struct ksmbd_work *work) +@@ -6863,6 +7237,7 @@ int smb2_lock(struct ksmbd_work *work) if (lock_start > U64_MAX - lock_length) { pr_err("Invalid lock range requested\n"); rsp->hdr.Status = STATUS_INVALID_LOCK_RANGE; @@ -15225,7 +16768,7 @@ index 9b16ee657b51..8560e4344af0 100644 goto out; } -@@ -6877,6 +6989,7 @@ int smb2_lock(struct ksmbd_work *work) +@@ -6882,6 +7257,7 @@ int smb2_lock(struct ksmbd_work *work) "the end offset(%llx) is smaller than the start offset(%llx)\n", flock->fl_end, flock->fl_start); rsp->hdr.Status = STATUS_INVALID_LOCK_RANGE; @@ -15233,7 +16776,7 @@ index 9b16ee657b51..8560e4344af0 100644 goto out; } -@@ -6888,6 +7001,7 @@ int smb2_lock(struct ksmbd_work *work) +@@ -6893,6 +7269,7 @@ int smb2_lock(struct ksmbd_work *work) flock->fl_type != F_UNLCK) { pr_err("conflict two locks in one request\n"); err = -EINVAL; @@ -15241,7 +16784,7 @@ index 9b16ee657b51..8560e4344af0 100644 goto out; } } -@@ -6896,6 +7010,7 @@ int smb2_lock(struct ksmbd_work *work) +@@ -6901,6 +7278,7 @@ int smb2_lock(struct ksmbd_work *work) smb_lock = smb2_lock_init(flock, cmd, flags, &lock_list); if (!smb_lock) { err = -EINVAL; @@ -15249,28 +16792,74 @@ index 9b16ee657b51..8560e4344af0 100644 goto out; } } -@@ -7055,6 +7170,10 @@ int smb2_lock(struct ksmbd_work *work) +@@ -6932,7 +7310,7 @@ int smb2_lock(struct ksmbd_work *work) + + nolock = 1; + /* check locks in connection list */ +- read_lock(&conn_list_lock); ++ down_read(&conn_list_lock); + list_for_each_entry(conn, &conn_list, conns_list) { + spin_lock(&conn->llist_lock); + list_for_each_entry_safe(cmp_lock, tmp2, &conn->lock_list, clist) { +@@ -6949,7 +7327,7 @@ int smb2_lock(struct ksmbd_work *work) + list_del(&cmp_lock->flist); + list_del(&cmp_lock->clist); + spin_unlock(&conn->llist_lock); +- read_unlock(&conn_list_lock); ++ up_read(&conn_list_lock); + + locks_free_lock(cmp_lock->fl); + kfree(cmp_lock); +@@ -6971,7 +7349,7 @@ int smb2_lock(struct ksmbd_work *work) + cmp_lock->start > smb_lock->start && + cmp_lock->start < smb_lock->end) { + spin_unlock(&conn->llist_lock); +- read_unlock(&conn_list_lock); ++ up_read(&conn_list_lock); + pr_err("previous lock conflict with zero byte lock range\n"); + goto out; + } +@@ -6980,7 +7358,7 @@ int smb2_lock(struct ksmbd_work *work) + smb_lock->start > cmp_lock->start && + smb_lock->start < cmp_lock->end) { + spin_unlock(&conn->llist_lock); +- read_unlock(&conn_list_lock); ++ up_read(&conn_list_lock); + pr_err("current lock conflict with zero byte lock range\n"); + goto out; + } +@@ -6991,14 +7369,14 @@ int smb2_lock(struct ksmbd_work *work) + cmp_lock->end >= smb_lock->end)) && + !cmp_lock->zero_len && !smb_lock->zero_len) { + spin_unlock(&conn->llist_lock); +- read_unlock(&conn_list_lock); ++ up_read(&conn_list_lock); + pr_err("Not allow lock operation on exclusive lock range\n"); + goto out; + } + } + spin_unlock(&conn->llist_lock); + } +- read_unlock(&conn_list_lock); ++ up_read(&conn_list_lock); + out_check_cl: + if (smb_lock->fl->fl_type == F_UNLCK && nolock) { + pr_err("Try to unlock nolocked range\n"); +@@ -7060,13 +7438,9 @@ int smb2_lock(struct ksmbd_work *work) ksmbd_vfs_posix_lock_wait(flock); -+ spin_lock(&fp->f_lock); -+ list_del(&work->fp_entry); -+ spin_unlock(&fp->f_lock); -+ +- spin_lock(&work->conn->request_lock); + spin_lock(&fp->f_lock); + list_del(&work->fp_entry); +- work->cancel_fn = NULL; +- kfree(argv); + spin_unlock(&fp->f_lock); +- spin_unlock(&work->conn->request_lock); + if (work->state != KSMBD_WORK_ACTIVE) { list_del(&smb_lock->llist); - spin_lock(&work->conn->llist_lock); -@@ -7063,9 +7182,6 @@ int smb2_lock(struct ksmbd_work *work) - locks_free_lock(flock); - - if (work->state == KSMBD_WORK_CANCELLED) { -- spin_lock(&fp->f_lock); -- list_del(&work->fp_entry); -- spin_unlock(&fp->f_lock); - rsp->hdr.Status = - STATUS_CANCELLED; - kfree(smb_lock); -@@ -7074,6 +7190,7 @@ int smb2_lock(struct ksmbd_work *work) +@@ -7084,6 +7458,7 @@ int smb2_lock(struct ksmbd_work *work) work->send_no_response = 1; goto out; } @@ -15278,19 +16867,16 @@ index 9b16ee657b51..8560e4344af0 100644 init_smb2_rsp_hdr(work); smb2_set_err_rsp(work); rsp->hdr.Status = -@@ -7086,10 +7203,7 @@ int smb2_lock(struct ksmbd_work *work) +@@ -7096,7 +7471,7 @@ int smb2_lock(struct ksmbd_work *work) spin_lock(&work->conn->llist_lock); list_del(&smb_lock->clist); spin_unlock(&work->conn->llist_lock); - -- spin_lock(&fp->f_lock); -- list_del(&work->fp_entry); -- spin_unlock(&fp->f_lock); + release_async_work(work); goto retry; } else if (!rc) { spin_lock(&work->conn->llist_lock); -@@ -7132,7 +7246,7 @@ int smb2_lock(struct ksmbd_work *work) +@@ -7139,7 +7514,7 @@ int smb2_lock(struct ksmbd_work *work) rlock->fl_start = smb_lock->start; rlock->fl_end = smb_lock->end; @@ -15299,27 +16885,26 @@ index 9b16ee657b51..8560e4344af0 100644 if (rc) pr_err("rollback unlock fail : %d\n", rc); -@@ -7459,13 +7573,16 @@ static int fsctl_query_allocated_ranges(struct ksmbd_work *work, u64 id, - if (in_count == 0) - return -EINVAL; +@@ -7534,33 +7909,49 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id, + struct file_sparse *sparse) + { + struct ksmbd_file *fp; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap; ++#else + struct user_namespace *user_ns; ++#endif + int ret = 0; + __le32 old_fattr; -+ start = le64_to_cpu(qar_req->file_offset); -+ length = le64_to_cpu(qar_req->length); -+ -+ if (start < 0 || length < 0) -+ return -EINVAL; -+ fp = ksmbd_lookup_fd_fast(work, id); if (!fp) return -ENOENT; - -- start = le64_to_cpu(qar_req->file_offset); -- length = le64_to_cpu(qar_req->length); -- - ret = ksmbd_vfs_fqar_lseek(fp, start, length, - qar_rsp, in_count, out_count); - if (ret && ret != -E2BIG) -@@ -7535,9 +7652,9 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ idmap = file_mnt_idmap(fp->filp); ++#else + user_ns = file_mnt_user_ns(fp->filp); ++#endif old_fattr = fp->f_ci->m_fattr; if (sparse->SetSparse) @@ -15331,7 +16916,28 @@ index 9b16ee657b51..8560e4344af0 100644 if (fp->f_ci->m_fattr != old_fattr && test_share_config_flag(work->tcon->share_conf, -@@ -7615,7 +7732,7 @@ int smb2_ioctl(struct ksmbd_work *work) + KSMBD_SHARE_FLAG_STORE_DOS_ATTRS)) { + struct xattr_dos_attrib da; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ ret = ksmbd_vfs_get_dos_attrib_xattr(idmap, ++#else + ret = ksmbd_vfs_get_dos_attrib_xattr(user_ns, ++#endif + fp->filp->f_path.dentry, &da); + if (ret <= 0) + goto out; + + da.attr = le32_to_cpu(fp->f_ci->m_fattr); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ ret = ksmbd_vfs_set_dos_attrib_xattr(idmap, ++#else + ret = ksmbd_vfs_set_dos_attrib_xattr(user_ns, ++#endif + fp->filp->f_path.dentry, &da); + if (ret) + fp->f_ci->m_fattr = old_fattr; +@@ -7625,7 +8016,7 @@ int smb2_ioctl(struct ksmbd_work *work) goto out; } @@ -15340,7 +16946,7 @@ index 9b16ee657b51..8560e4344af0 100644 ret = smb2_calc_max_out_buf_len(work, 48, le32_to_cpu(req->MaxOutputResponse)); if (ret < 0) { -@@ -7726,7 +7843,7 @@ int smb2_ioctl(struct ksmbd_work *work) +@@ -7736,7 +8127,7 @@ int smb2_ioctl(struct ksmbd_work *work) rsp->PersistentFileId = req->PersistentFileId; fsctl_copychunk(work, (struct copychunk_ioctl_req *)&req->Buffer[0], @@ -15349,16 +16955,7 @@ index 9b16ee657b51..8560e4344af0 100644 le32_to_cpu(req->InputCount), req->VolatileFileId, req->PersistentFileId, -@@ -7766,7 +7883,7 @@ int smb2_ioctl(struct ksmbd_work *work) - - off = le64_to_cpu(zero_data->FileOffset); - bfz = le64_to_cpu(zero_data->BeyondFinalZero); -- if (off > bfz) { -+ if (off < 0 || bfz < 0 || off > bfz) { - ret = -EINVAL; - goto out; - } -@@ -7897,7 +8014,7 @@ int smb2_ioctl(struct ksmbd_work *work) +@@ -7907,7 +8298,7 @@ int smb2_ioctl(struct ksmbd_work *work) goto out; } @@ -15367,7 +16964,7 @@ index 9b16ee657b51..8560e4344af0 100644 rsp->InputCount = cpu_to_le32(0); rsp->InputOffset = cpu_to_le32(112); rsp->OutputOffset = cpu_to_le32(112); -@@ -8239,8 +8356,8 @@ int smb2_oplock_break(struct ksmbd_work *work) +@@ -8249,8 +8640,8 @@ int smb2_oplock_break(struct ksmbd_work *work) */ int smb2_notify(struct ksmbd_work *work) { @@ -15378,7 +16975,7 @@ index 9b16ee657b51..8560e4344af0 100644 WORK_BUFFERS(work, req, rsp); -@@ -8403,14 +8520,11 @@ int smb3_check_sign_req(struct ksmbd_work *work) +@@ -8413,14 +8804,11 @@ int smb3_check_sign_req(struct ksmbd_work *work) if (le16_to_cpu(hdr->Command) == SMB2_SESSION_SETUP_HE) { signing_key = work->sess->smb3signingkey; } else { @@ -15393,7 +16990,7 @@ index 9b16ee657b51..8560e4344af0 100644 } if (!signing_key) { -@@ -8470,14 +8584,11 @@ void smb3_set_sign_rsp(struct ksmbd_work *work) +@@ -8480,14 +8868,11 @@ void smb3_set_sign_rsp(struct ksmbd_work *work) le16_to_cpu(hdr->Command) == SMB2_SESSION_SETUP_HE) { signing_key = work->sess->smb3signingkey; } else { @@ -15408,7 +17005,7 @@ index 9b16ee657b51..8560e4344af0 100644 } if (!signing_key) -@@ -8548,10 +8659,10 @@ static void fill_transform_hdr(void *tr_buf, char *old_buf, __le16 cipher_type) +@@ -8558,10 +8943,10 @@ static void fill_transform_hdr(void *tr_buf, char *old_buf, __le16 cipher_type) struct smb2_hdr *hdr = smb2_get_msg(old_buf); unsigned int orig_len = get_rfc1002_len(old_buf); @@ -15422,7 +17019,7 @@ index 9b16ee657b51..8560e4344af0 100644 cipher_type == SMB2_ENCRYPTION_AES256_GCM) get_random_bytes(&tr_hdr->Nonce, SMB3_AES_GCM_NONCE); diff --git a/fs/ksmbd/smb2pdu.h b/fs/ksmbd/smb2pdu.h -index f4baa9800f6e..de32dadd97ca 100644 +index f4baa9800f6e..1719b0cc171c 100644 --- a/fs/ksmbd/smb2pdu.h +++ b/fs/ksmbd/smb2pdu.h @@ -10,24 +10,175 @@ @@ -15663,7 +17260,7 @@ index f4baa9800f6e..de32dadd97ca 100644 }; /* offset is sizeof smb2_negotiate_rsp but rounded up to 8 bytes. */ -@@ -57,10 +257,368 @@ struct preauth_integrity_info { +@@ -57,10 +257,370 @@ struct preauth_integrity_info { #define OFFSET_OF_NEG_CONTEXT 0xd0 #endif @@ -15776,6 +17373,8 @@ index f4baa9800f6e..de32dadd97ca 100644 #define SMB2_SESSION_IN_PROGRESS BIT(0) #define SMB2_SESSION_VALID BIT(1) ++#define SMB2_SESSION_TIMEOUT (10 * HZ) ++ +/* Flags */ +#define SMB2_SESSION_REQ_FLAG_BINDING 0x01 +#define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04 @@ -16032,7 +17631,7 @@ index f4baa9800f6e..de32dadd97ca 100644 struct create_durable_req_v2 { struct create_context ccontext; __u8 Name[8]; -@@ -121,6 +679,13 @@ struct create_alloc_size_req { +@@ -121,6 +681,13 @@ struct create_alloc_size_req { __le64 AllocationSize; } __packed; @@ -16046,7 +17645,7 @@ index f4baa9800f6e..de32dadd97ca 100644 struct create_durable_rsp { struct create_context ccontext; __u8 Name[8]; -@@ -163,14 +728,212 @@ struct create_posix_rsp { +@@ -163,14 +730,212 @@ struct create_posix_rsp { u8 SidBuffer[44]; } __packed; @@ -16259,7 +17858,7 @@ index f4baa9800f6e..de32dadd97ca 100644 struct smb_sockaddr_in { __be16 Port; __be32 IPv4address; -@@ -244,6 +1007,204 @@ struct file_sparse { +@@ -244,6 +1009,204 @@ struct file_sparse { __u8 SetSparse; } __packed; @@ -16464,7 +18063,7 @@ index f4baa9800f6e..de32dadd97ca 100644 /* FILE Info response size */ #define FILE_DIRECTORY_INFORMATION_SIZE 1 #define FILE_FULL_DIRECTORY_INFORMATION_SIZE 2 -@@ -299,11 +1260,145 @@ struct fs_type_info { +@@ -299,11 +1262,145 @@ struct fs_type_info { long magic_number; } __packed; @@ -16611,7 +18210,7 @@ index f4baa9800f6e..de32dadd97ca 100644 struct smb2_file_access_info { __le32 AccessFlags; } __packed; -@@ -312,6 +1407,56 @@ struct smb2_file_alignment_info { +@@ -312,6 +1409,56 @@ struct smb2_file_alignment_info { __le32 AlignmentRequirement; } __packed; @@ -16668,7 +18267,7 @@ index f4baa9800f6e..de32dadd97ca 100644 struct smb2_file_basic_info { /* data block encoding of response to level 18 */ __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */ __le64 LastAccessTime; -@@ -323,7 +1468,7 @@ struct smb2_file_basic_info { /* data block encoding of response to level 18 */ +@@ -323,7 +1470,7 @@ struct smb2_file_basic_info { /* data block encoding of response to level 18 */ struct smb2_file_alt_name_info { __le32 FileNameLength; @@ -16677,7 +18276,7 @@ index f4baa9800f6e..de32dadd97ca 100644 } __packed; struct smb2_file_stream_info { -@@ -331,9 +1476,13 @@ struct smb2_file_stream_info { +@@ -331,9 +1478,13 @@ struct smb2_file_stream_info { __le32 StreamNameLength; __le64 StreamSize; __le64 StreamAllocationSize; @@ -16692,7 +18291,7 @@ index f4baa9800f6e..de32dadd97ca 100644 struct smb2_file_ntwrk_info { __le64 CreationTime; __le64 LastAccessTime; -@@ -370,7 +1519,7 @@ struct smb2_file_pos_info { +@@ -370,7 +1521,7 @@ struct smb2_file_pos_info { __le64 CurrentByteOffset; } __packed; @@ -16701,7 +18300,7 @@ index f4baa9800f6e..de32dadd97ca 100644 struct smb2_file_mode_info { __le32 Mode; -@@ -424,6 +1573,34 @@ struct create_sd_buf_req { +@@ -424,6 +1575,34 @@ struct create_sd_buf_req { struct smb_ntsd ntsd; } __packed; @@ -16736,7 +18335,7 @@ index f4baa9800f6e..de32dadd97ca 100644 struct smb2_posix_info { __le32 NextEntryOffset; __u32 Ignored; -@@ -444,7 +1621,7 @@ struct smb2_posix_info { +@@ -444,7 +1623,7 @@ struct smb2_posix_info { /* SidBuffer contain two sids (UNIX user sid(16), UNIX group sid(16)) */ u8 SidBuffer[32]; __le32 name_len; @@ -16745,7 +18344,7 @@ index f4baa9800f6e..de32dadd97ca 100644 /* * var sized owner SID * var sized group SID -@@ -454,6 +1631,7 @@ struct smb2_posix_info { +@@ -454,6 +1633,7 @@ struct smb2_posix_info { } __packed; /* functions */ @@ -16753,7 +18352,7 @@ index f4baa9800f6e..de32dadd97ca 100644 void init_smb2_1_server(struct ksmbd_conn *conn); void init_smb3_0_server(struct ksmbd_conn *conn); void init_smb3_02_server(struct ksmbd_conn *conn); -@@ -486,6 +1664,7 @@ int find_matching_smb2_dialect(int start_index, __le16 *cli_dialects, +@@ -486,6 +1666,7 @@ int find_matching_smb2_dialect(int start_index, __le16 *cli_dialects, struct file_lock *smb_flock_init(struct file *f); int setup_async_work(struct ksmbd_work *work, void (*fn)(void **), void **arg); @@ -16762,7 +18361,7 @@ index f4baa9800f6e..de32dadd97ca 100644 struct channel *lookup_chann_list(struct ksmbd_session *sess, struct ksmbd_conn *conn); diff --git a/fs/ksmbd/smb_common.c b/fs/ksmbd/smb_common.c -index d96da872d70a..767892ab4f83 100644 +index 95afb6b23a91..c6bd9f2b298f 100644 --- a/fs/ksmbd/smb_common.c +++ b/fs/ksmbd/smb_common.c @@ -7,6 +7,7 @@ @@ -16800,13 +18399,13 @@ index d96da872d70a..767892ab4f83 100644 + "\2NT LM 0.12", + "NT1", + SMB10_PROT_ID - }, ++ }, + { + SMB2_PROT, + "\2SMB 2.002", + "SMB2_02", + SMB20_PROT_ID -+ }, + }, +#endif { SMB2X_PROT, @@ -16868,142 +18467,58 @@ index d96da872d70a..767892ab4f83 100644 } /** -@@ -283,20 +319,123 @@ static int ksmbd_negotiate_smb_dialect(void *buf) +@@ -283,6 +319,7 @@ static int ksmbd_negotiate_smb_dialect(void *buf) return BAD_PROT_ID; } --int ksmbd_init_smb_server(struct ksmbd_work *work) +#ifndef CONFIG_SMB_INSECURE_SERVER -+#define SMB_COM_NEGOTIATE_EX 0x0 -+ -+/** -+ * get_smb1_cmd_val() - get smb command value from smb header -+ * @work: smb work containing smb header -+ * -+ * Return: smb command value -+ */ -+static u16 get_smb1_cmd_val(struct ksmbd_work *work) - { -- struct ksmbd_conn *conn = work->conn; -+ return SMB_COM_NEGOTIATE_EX; -+} + #define SMB_COM_NEGOTIATE_EX 0x0 -- if (conn->need_neg == false) -+/** -+ * init_smb1_rsp_hdr() - initialize smb negotiate response header -+ * @work: smb work containing smb request -+ * -+ * Return: 0 on success, otherwise -EINVAL -+ */ -+static int init_smb1_rsp_hdr(struct ksmbd_work *work) -+{ -+ struct smb_hdr *rsp_hdr = (struct smb_hdr *)work->response_buf; -+ struct smb_hdr *rcv_hdr = (struct smb_hdr *)work->request_buf; -+ -+ /* -+ * Remove 4 byte direct TCP header. -+ */ -+ *(__be32 *)work->response_buf = -+ cpu_to_be32(sizeof(struct smb_hdr) - 4); -+ -+ rsp_hdr->Command = SMB_COM_NEGOTIATE; -+ *(__le32 *)rsp_hdr->Protocol = SMB1_PROTO_NUMBER; -+ rsp_hdr->Flags = SMBFLG_RESPONSE; -+ rsp_hdr->Flags2 = SMBFLG2_UNICODE | SMBFLG2_ERR_STATUS | -+ SMBFLG2_EXT_SEC | SMBFLG2_IS_LONG_NAME; -+ rsp_hdr->Pid = rcv_hdr->Pid; -+ rsp_hdr->Mid = rcv_hdr->Mid; -+ return 0; -+} -+ -+/** -+ * smb1_check_user_session() - check for valid session for a user -+ * @work: smb work containing smb request buffer -+ * -+ * Return: 0 on success, otherwise error -+ */ -+static int smb1_check_user_session(struct ksmbd_work *work) -+{ -+ unsigned int cmd = work->conn->ops->get_cmd_val(work); -+ -+ if (cmd == SMB_COM_NEGOTIATE_EX) - return 0; + /** +@@ -347,8 +384,8 @@ static int smb1_check_user_session(struct ksmbd_work *work) + */ + static int smb1_allocate_rsp_buf(struct ksmbd_work *work) + { +- work->response_buf = kmalloc(MAX_CIFS_SMALL_BUFFER_SIZE, +- GFP_KERNEL | __GFP_ZERO); ++ work->response_buf = kzalloc(MAX_CIFS_SMALL_BUFFER_SIZE, ++ GFP_KERNEL); + work->response_sz = MAX_CIFS_SMALL_BUFFER_SIZE; + + if (!work->response_buf) { +@@ -382,6 +419,7 @@ static void init_smb1_server(struct ksmbd_conn *conn) + conn->cmds = smb1_server_cmds; + conn->max_cmds = ARRAY_SIZE(smb1_server_cmds); + } ++#endif -- init_smb3_11_server(conn); -+ return -EINVAL; -+} -+ -+/** -+ * smb1_allocate_rsp_buf() - allocate response buffer for a command -+ * @work: smb work containing smb request -+ * -+ * Return: 0 on success, otherwise -ENOMEM -+ */ -+static int smb1_allocate_rsp_buf(struct ksmbd_work *work) -+{ -+ work->response_buf = kmalloc(MAX_CIFS_SMALL_BUFFER_SIZE, -+ GFP_KERNEL | __GFP_ZERO); -+ work->response_sz = MAX_CIFS_SMALL_BUFFER_SIZE; -+ -+ if (!work->response_buf) { -+ pr_err("Failed to allocate %u bytes buffer\n", -+ MAX_CIFS_SMALL_BUFFER_SIZE); -+ return -ENOMEM; -+ } + void ksmbd_init_smb_server(struct ksmbd_work *work) + { +@@ -408,7 +446,11 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level, + { + int i, rc = 0; + struct ksmbd_conn *conn = work->conn; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap = file_mnt_idmap(dir->filp); ++#else + struct user_namespace *user_ns = file_mnt_user_ns(dir->filp); ++#endif -- if (conn->ops->get_cmd_val(work) != SMB_COM_NEGOTIATE) -- conn->need_neg = false; - return 0; - } + for (i = 0; i < 2; i++) { + struct kstat kstat; +@@ -434,7 +476,11 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level, -+static struct smb_version_ops smb1_server_ops = { -+ .get_cmd_val = get_smb1_cmd_val, -+ .init_rsp_hdr = init_smb1_rsp_hdr, -+ .allocate_rsp_buf = smb1_allocate_rsp_buf, -+ .check_user_session = smb1_check_user_session, -+}; -+ -+static int smb1_negotiate(struct ksmbd_work *work) -+{ -+ return ksmbd_smb_negotiate_common(work, SMB_COM_NEGOTIATE); -+} -+ -+static struct smb_version_cmds smb1_server_cmds[1] = { -+ [SMB_COM_NEGOTIATE_EX] = { .proc = smb1_negotiate, }, -+}; -+ -+static void init_smb1_server(struct ksmbd_conn *conn) -+{ -+ conn->ops = &smb1_server_ops; -+ conn->cmds = smb1_server_cmds; -+ conn->max_cmds = ARRAY_SIZE(smb1_server_cmds); -+} + ksmbd_kstat.kstat = &kstat; + ksmbd_vfs_fill_dentry_attrs(work, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ idmap, ++#else + user_ns, +#endif -+ -+void ksmbd_init_smb_server(struct ksmbd_work *work) -+{ -+ struct ksmbd_conn *conn = work->conn; -+ __le32 proto; -+ -+ if (conn->need_neg == false) -+ return; -+ -+ proto = *(__le32 *)((struct smb_hdr *)work->request_buf)->Protocol; -+ if (proto == SMB1_PROTO_NUMBER) -+ init_smb1_server(conn); -+ else -+ init_smb3_11_server(conn); -+} -+ - int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level, - struct ksmbd_file *dir, - struct ksmbd_dir_info *d_info, -@@ -434,18 +573,27 @@ int ksmbd_extract_shortname(struct ksmbd_conn *conn, const char *longname, - - static int __smb2_negotiate(struct ksmbd_conn *conn) - { -- return (conn->dialect >= SMB21_PROT_ID && -+ return (conn->dialect >= SMB20_PROT_ID && + dentry, + &ksmbd_kstat); + rc = fn(conn, info_level, d_info, &ksmbd_kstat); +@@ -539,6 +585,7 @@ static int __smb2_negotiate(struct ksmbd_conn *conn) conn->dialect <= SMB311_PROT_ID); } @@ -17011,50 +18526,15 @@ index d96da872d70a..767892ab4f83 100644 static int smb_handle_negotiate(struct ksmbd_work *work) { struct smb_negotiate_rsp *neg_rsp = work->response_buf; - -- ksmbd_debug(SMB, "Unsupported SMB protocol\n"); -- neg_rsp->hdr.Status.CifsError = STATUS_INVALID_LOGON_TYPE; -- return -EINVAL; -+ ksmbd_debug(SMB, "Unsupported SMB1 protocol\n"); -+ -+ /* Add 2 byte bcc and 2 byte DialectIndex. */ -+ inc_rfc1001_len(work->response_buf, 4); -+ neg_rsp->hdr.Status.CifsError = STATUS_SUCCESS; -+ -+ neg_rsp->hdr.WordCount = 1; -+ neg_rsp->DialectIndex = cpu_to_le16(work->conn->dialect); -+ neg_rsp->ByteCount = 0; -+ return 0; +@@ -554,6 +601,7 @@ static int smb_handle_negotiate(struct ksmbd_work *work) + neg_rsp->ByteCount = 0; + return 0; } +#endif int ksmbd_smb_negotiate_common(struct ksmbd_work *work, unsigned int command) { -@@ -457,23 +605,12 @@ int ksmbd_smb_negotiate_common(struct ksmbd_work *work, unsigned int command) - ksmbd_debug(SMB, "conn->dialect 0x%x\n", conn->dialect); - - if (command == SMB2_NEGOTIATE_HE) { -- struct smb2_hdr *smb2_hdr = smb2_get_msg(work->request_buf); -- -- if (smb2_hdr->ProtocolId != SMB2_PROTO_NUMBER) { -- ksmbd_debug(SMB, "Downgrade to SMB1 negotiation\n"); -- command = SMB_COM_NEGOTIATE; -- } -- } -- -- if (command == SMB2_NEGOTIATE_HE && __smb2_negotiate(conn)) { - ret = smb2_handle_negotiate(work); -- init_smb2_neg_rsp(work); - return ret; - } - - if (command == SMB_COM_NEGOTIATE) { - if (__smb2_negotiate(conn)) { -- conn->need_neg = true; - init_smb3_11_server(conn); - init_smb2_neg_rsp(work); - ksmbd_debug(SMB, "Upgrade to SMB2 negotiation\n"); -@@ -623,7 +760,7 @@ int ksmbd_override_fsids(struct ksmbd_work *work) +@@ -720,7 +768,7 @@ int ksmbd_override_fsids(struct ksmbd_work *work) if (share->force_gid != KSMBD_SHARE_INVALID_GID) gid = share->force_gid; @@ -17064,7 +18544,7 @@ index d96da872d70a..767892ab4f83 100644 return -ENOMEM; diff --git a/fs/ksmbd/smb_common.h b/fs/ksmbd/smb_common.h -index 318c16fa81da..81e6702a9245 100644 +index 78c44978a906..81e6702a9245 100644 --- a/fs/ksmbd/smb_common.h +++ b/fs/ksmbd/smb_common.h @@ -10,7 +10,6 @@ @@ -17161,7 +18641,24 @@ index 318c16fa81da..81e6702a9245 100644 #define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \ | FILE_READ_ATTRIBUTES \ | DELETE | READ_CONTROL | WRITE_DAC \ -@@ -196,31 +246,10 @@ struct smb_negotiate_req { +@@ -158,15 +208,8 @@ + + #define SMB1_PROTO_NUMBER cpu_to_le32(0x424d53ff) + #define SMB_COM_NEGOTIATE 0x72 +-#define SMB1_CLIENT_GUID_SIZE (16) +- +-#define SMBFLG_RESPONSE 0x80 /* this PDU is a response from server */ +- +-#define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40) +-#define SMBFLG2_EXT_SEC cpu_to_le16(0x800) +-#define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000) +-#define SMBFLG2_UNICODE cpu_to_le16(0x8000) + ++#define SMB1_CLIENT_GUID_SIZE (16) + struct smb_hdr { + __be32 smb_buf_length; + __u8 Protocol[4]; +@@ -203,7 +246,7 @@ struct smb_negotiate_req { unsigned char DialectsArray[1]; } __packed; @@ -17169,32 +18666,8 @@ index 318c16fa81da..81e6702a9245 100644 +struct smb_negotiate_unsupported_rsp { struct smb_hdr hdr; /* wct = 17 */ __le16 DialectIndex; /* 0xFFFF = no dialect acceptable */ -- __u8 SecurityMode; -- __le16 MaxMpxCount; -- __le16 MaxNumberVcs; -- __le32 MaxBufferSize; -- __le32 MaxRawSize; -- __le32 SessionKey; -- __le32 Capabilities; /* see below */ -- __le32 SystemTimeLow; -- __le32 SystemTimeHigh; -- __le16 ServerTimeZone; -- __u8 EncryptionKeyLength; __le16 ByteCount; -- union { -- unsigned char EncryptionKey[8]; /* cap extended security off */ -- /* followed by Domain name - if extended security is off */ -- /* followed by 16 bytes of server GUID */ -- /* then security blob if cap_extended_security negotiated */ -- struct { -- unsigned char GUID[SMB1_CLIENT_GUID_SIZE]; -- unsigned char SecurityBlob[1]; -- } __packed extended_response; -- } __packed u; - } __packed; - - struct filesystem_attribute_info { -@@ -277,14 +306,14 @@ struct file_directory_info { +@@ -263,14 +306,14 @@ struct file_directory_info { __le64 AllocationSize; __le32 ExtFileAttributes; __le32 FileNameLength; @@ -17211,7 +18684,7 @@ index 318c16fa81da..81e6702a9245 100644 } __packed; /* level 0xc FF resp data */ struct file_full_directory_info { -@@ -299,7 +328,7 @@ struct file_full_directory_info { +@@ -285,7 +328,7 @@ struct file_full_directory_info { __le32 ExtFileAttributes; __le32 FileNameLength; __le32 EaSize; @@ -17220,7 +18693,7 @@ index 318c16fa81da..81e6702a9245 100644 } __packed; /* level 0x102 FF resp */ struct file_both_directory_info { -@@ -317,7 +346,7 @@ struct file_both_directory_info { +@@ -303,7 +346,7 @@ struct file_both_directory_info { __u8 ShortNameLength; __u8 Reserved; __u8 ShortName[24]; @@ -17229,7 +18702,7 @@ index 318c16fa81da..81e6702a9245 100644 } __packed; /* level 0x104 FFrsp data */ struct file_id_both_directory_info { -@@ -337,7 +366,7 @@ struct file_id_both_directory_info { +@@ -323,7 +366,7 @@ struct file_id_both_directory_info { __u8 ShortName[24]; __le16 Reserved2; __le64 UniqueId; @@ -17238,7 +18711,7 @@ index 318c16fa81da..81e6702a9245 100644 } __packed; struct file_id_full_dir_info { -@@ -354,7 +383,7 @@ struct file_id_full_dir_info { +@@ -340,7 +383,7 @@ struct file_id_full_dir_info { __le32 EaSize; /* EA size */ __le32 Reserved; __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/ @@ -17247,19 +18720,17 @@ index 318c16fa81da..81e6702a9245 100644 } __packed; /* level 0x105 FF rsp data */ struct smb_version_values { -@@ -441,7 +470,9 @@ bool ksmbd_smb_request(struct ksmbd_conn *conn); +@@ -429,6 +472,8 @@ int ksmbd_lookup_dialect_by_id(__le16 *cli_dialects, __le16 dialects_count); - int ksmbd_lookup_dialect_by_id(__le16 *cli_dialects, __le16 dialects_count); + void ksmbd_init_smb_server(struct ksmbd_work *work); --int ksmbd_init_smb_server(struct ksmbd_work *work); -+void ksmbd_init_smb_server(struct ksmbd_work *work); -+ +bool ksmbd_pdu_size_has_room(unsigned int pdu); - ++ struct ksmbd_kstat; int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, + int info_level, diff --git a/fs/ksmbd/smbacl.c b/fs/ksmbd/smbacl.c -index b05ff9b146b5..3d7f5a09e26a 100644 +index b05ff9b146b5..dce69bb245a3 100644 --- a/fs/ksmbd/smbacl.c +++ b/fs/ksmbd/smbacl.c @@ -6,10 +6,13 @@ @@ -17276,7 +18747,19 @@ index b05ff9b146b5..3d7f5a09e26a 100644 #include "smbacl.h" #include "smb_common.h" -@@ -270,13 +273,34 @@ static int sid_to_id(struct user_namespace *user_ns, +@@ -254,7 +257,11 @@ void id_to_sid(unsigned int cid, uint sidtype, struct smb_sid *ssid) + ssid->num_subauth++; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++static int sid_to_id(struct mnt_idmap *idmap, ++#else + static int sid_to_id(struct user_namespace *user_ns, ++#endif + struct smb_sid *psid, uint sidtype, + struct smb_fattr *fattr) + { +@@ -270,13 +277,38 @@ static int sid_to_id(struct user_namespace *user_ns, return -EIO; } @@ -17292,7 +18775,11 @@ index b05ff9b146b5..3d7f5a09e26a 100644 + (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 52) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0)) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0) uid = KUIDT_INIT(id); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ uid = from_vfsuid(idmap, &init_user_ns, VFSUIDT_INIT(uid)); ++#else uid = from_vfsuid(user_ns, &init_user_ns, VFSUIDT_INIT(uid)); ++#endif +#else + uid = mapped_kuid_user(user_ns, &init_user_ns, KUIDT_INIT(id)); +#endif @@ -17311,7 +18798,7 @@ index b05ff9b146b5..3d7f5a09e26a 100644 if (uid_valid(uid)) { fattr->cf_uid = uid; rc = 0; -@@ -286,8 +310,26 @@ static int sid_to_id(struct user_namespace *user_ns, +@@ -286,8 +318,30 @@ static int sid_to_id(struct user_namespace *user_ns, gid_t id; id = le32_to_cpu(psid->sub_auth[psid->num_subauth - 1]); @@ -17319,7 +18806,11 @@ index b05ff9b146b5..3d7f5a09e26a 100644 + (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 52) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0)) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0) gid = KGIDT_INIT(id); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ gid = from_vfsgid(idmap, &init_user_ns, VFSGIDT_INIT(gid)); ++#else gid = from_vfsgid(user_ns, &init_user_ns, VFSGIDT_INIT(gid)); ++#endif +#else + gid = mapped_kgid_user(user_ns, &init_user_ns, KGIDT_INIT(id)); +#endif @@ -17338,7 +18829,275 @@ index b05ff9b146b5..3d7f5a09e26a 100644 if (gid_valid(gid)) { fattr->cf_gid = gid; rc = 0; -@@ -1289,7 +1331,11 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path, +@@ -362,7 +416,11 @@ void free_acl_state(struct posix_acl_state *state) + kfree(state->groups); + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++static void parse_dacl(struct mnt_idmap *idmap, ++#else + static void parse_dacl(struct user_namespace *user_ns, ++#endif + struct smb_acl *pdacl, char *end_of_acl, + struct smb_sid *pownersid, struct smb_sid *pgrpsid, + struct smb_fattr *fattr) +@@ -489,7 +547,11 @@ static void parse_dacl(struct user_namespace *user_ns, + acl_mode = access_flags_to_mode(fattr, ppace[i]->access_req, + ppace[i]->type); + temp_fattr.cf_uid = INVALID_UID; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ ret = sid_to_id(idmap, &ppace[i]->sid, SIDOWNER, &temp_fattr); ++#else + ret = sid_to_id(user_ns, &ppace[i]->sid, SIDOWNER, &temp_fattr); ++#endif + if (ret || uid_eq(temp_fattr.cf_uid, INVALID_UID)) { + pr_err("%s: Error %d mapping Owner SID to uid\n", + __func__, ret); +@@ -575,7 +637,11 @@ static void parse_dacl(struct user_namespace *user_ns, + free_acl_state(&default_acl_state); + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++static void set_posix_acl_entries_dacl(struct mnt_idmap *idmap, ++#else + static void set_posix_acl_entries_dacl(struct user_namespace *user_ns, ++#endif + struct smb_ace *pndace, + struct smb_fattr *fattr, u32 *num_aces, + u16 *size, u32 nt_aces_num) +@@ -600,14 +666,22 @@ static void set_posix_acl_entries_dacl(struct user_namespace *user_ns, + uid_t uid; + unsigned int sid_type = SIDOWNER; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ uid = posix_acl_uid_translate(idmap, pace); ++#else + uid = posix_acl_uid_translate(user_ns, pace); ++#endif + if (!uid) + sid_type = SIDUNIX_USER; + id_to_sid(uid, sid_type, sid); + } else if (pace->e_tag == ACL_GROUP) { + gid_t gid; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ gid = posix_acl_gid_translate(idmap, pace); ++#else + gid = posix_acl_gid_translate(user_ns, pace); ++#endif + id_to_sid(gid, SIDUNIX_GROUP, sid); + } else if (pace->e_tag == ACL_OTHER && !nt_aces_num) { + smb_copy_sid(sid, &sid_everyone); +@@ -666,12 +740,20 @@ static void set_posix_acl_entries_dacl(struct user_namespace *user_ns, + if (pace->e_tag == ACL_USER) { + uid_t uid; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ uid = posix_acl_uid_translate(idmap, pace); ++#else + uid = posix_acl_uid_translate(user_ns, pace); ++#endif + id_to_sid(uid, SIDCREATOR_OWNER, sid); + } else if (pace->e_tag == ACL_GROUP) { + gid_t gid; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ gid = posix_acl_gid_translate(idmap, pace); ++#else + gid = posix_acl_gid_translate(user_ns, pace); ++#endif + id_to_sid(gid, SIDCREATOR_GROUP, sid); + } else { + kfree(sid); +@@ -689,7 +771,11 @@ static void set_posix_acl_entries_dacl(struct user_namespace *user_ns, + } + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++static void set_ntacl_dacl(struct mnt_idmap *idmap, ++#else + static void set_ntacl_dacl(struct user_namespace *user_ns, ++#endif + struct smb_acl *pndacl, + struct smb_acl *nt_dacl, + unsigned int aces_size, +@@ -723,13 +809,21 @@ static void set_ntacl_dacl(struct user_namespace *user_ns, + } + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ set_posix_acl_entries_dacl(idmap, pndace, fattr, ++#else + set_posix_acl_entries_dacl(user_ns, pndace, fattr, ++#endif + &num_aces, &size, nt_num_aces); + pndacl->num_aces = cpu_to_le32(num_aces); + pndacl->size = cpu_to_le16(le16_to_cpu(pndacl->size) + size); + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++static void set_mode_dacl(struct mnt_idmap *idmap, ++#else + static void set_mode_dacl(struct user_namespace *user_ns, ++#endif + struct smb_acl *pndacl, struct smb_fattr *fattr) + { + struct smb_ace *pace, *pndace; +@@ -741,7 +835,11 @@ static void set_mode_dacl(struct user_namespace *user_ns, + pace = pndace = (struct smb_ace *)((char *)pndacl + sizeof(struct smb_acl)); + + if (fattr->cf_acls) { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ set_posix_acl_entries_dacl(idmap, pndace, fattr, ++#else + set_posix_acl_entries_dacl(user_ns, pndace, fattr, ++#endif + &num_aces, &size, num_aces); + goto out; + } +@@ -808,7 +906,11 @@ static int parse_sid(struct smb_sid *psid, char *end_of_acl) + } + + /* Convert CIFS ACL to POSIX form */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int parse_sec_desc(struct mnt_idmap *idmap, struct smb_ntsd *pntsd, ++#else + int parse_sec_desc(struct user_namespace *user_ns, struct smb_ntsd *pntsd, ++#endif + int acl_len, struct smb_fattr *fattr) + { + int rc = 0; +@@ -851,7 +953,11 @@ int parse_sec_desc(struct user_namespace *user_ns, struct smb_ntsd *pntsd, + return rc; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = sid_to_id(idmap, owner_sid_ptr, SIDOWNER, fattr); ++#else + rc = sid_to_id(user_ns, owner_sid_ptr, SIDOWNER, fattr); ++#endif + if (rc) { + pr_err("%s: Error %d mapping Owner SID to uid\n", + __func__, rc); +@@ -866,7 +972,11 @@ int parse_sec_desc(struct user_namespace *user_ns, struct smb_ntsd *pntsd, + __func__, rc); + return rc; + } ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = sid_to_id(idmap, group_sid_ptr, SIDUNIX_GROUP, fattr); ++#else + rc = sid_to_id(user_ns, group_sid_ptr, SIDUNIX_GROUP, fattr); ++#endif + if (rc) { + pr_err("%s: Error %d mapping Group SID to gid\n", + __func__, rc); +@@ -881,7 +991,11 @@ int parse_sec_desc(struct user_namespace *user_ns, struct smb_ntsd *pntsd, + pntsd->type |= cpu_to_le16(DACL_PROTECTED); + + if (dacloffset) { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ parse_dacl(idmap, dacl_ptr, end_of_acl, ++#else + parse_dacl(user_ns, dacl_ptr, end_of_acl, ++#endif + owner_sid_ptr, group_sid_ptr, fattr); + } + +@@ -889,7 +1003,11 @@ int parse_sec_desc(struct user_namespace *user_ns, struct smb_ntsd *pntsd, + } + + /* Convert permission bits from mode to equivalent CIFS ACL */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int build_sec_desc(struct mnt_idmap *idmap, ++#else + int build_sec_desc(struct user_namespace *user_ns, ++#endif + struct smb_ntsd *pntsd, struct smb_ntsd *ppntsd, + int ppntsd_size, int addition_info, __u32 *secdesclen, + struct smb_fattr *fattr) +@@ -950,7 +1068,11 @@ int build_sec_desc(struct user_namespace *user_ns, + dacl_ptr->num_aces = 0; + + if (!ppntsd) { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ set_mode_dacl(idmap, dacl_ptr, fattr); ++#else + set_mode_dacl(user_ns, dacl_ptr, fattr); ++#endif + } else { + struct smb_acl *ppdacl_ptr; + unsigned int dacl_offset = le32_to_cpu(ppntsd->dacloffset); +@@ -966,7 +1088,11 @@ int build_sec_desc(struct user_namespace *user_ns, + ppdacl_size < sizeof(struct smb_acl)) + goto out; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ set_ntacl_dacl(idmap, dacl_ptr, ppdacl_ptr, ++#else + set_ntacl_dacl(user_ns, dacl_ptr, ppdacl_ptr, ++#endif + ntacl_size - sizeof(struct smb_acl), + nowner_sid_ptr, ngroup_sid_ptr, + fattr); +@@ -1002,13 +1128,21 @@ int smb_inherit_dacl(struct ksmbd_conn *conn, + struct smb_ntsd *parent_pntsd = NULL; + struct smb_sid owner_sid, group_sid; + struct dentry *parent = path->dentry->d_parent; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap = mnt_idmap(path->mnt); ++#else + struct user_namespace *user_ns = mnt_user_ns(path->mnt); ++#endif + int inherited_flags = 0, flags = 0, i, ace_cnt = 0, nt_size = 0, pdacl_size; + int rc = 0, num_aces, dacloffset, pntsd_type, pntsd_size, acl_len, aces_size; + char *aces_base; + bool is_dir = S_ISDIR(d_inode(path->dentry)->i_mode); + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ pntsd_size = ksmbd_vfs_get_sd_xattr(conn, idmap, ++#else + pntsd_size = ksmbd_vfs_get_sd_xattr(conn, user_ns, ++#endif + parent, &parent_pntsd); + if (pntsd_size <= 0) + return -ENOENT; +@@ -1162,7 +1296,11 @@ int smb_inherit_dacl(struct ksmbd_conn *conn, + pntsd_size += sizeof(struct smb_acl) + nt_size; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ ksmbd_vfs_set_sd_xattr(conn, idmap, ++#else + ksmbd_vfs_set_sd_xattr(conn, user_ns, ++#endif + path->dentry, pntsd, pntsd_size); + kfree(pntsd); + } +@@ -1190,7 +1328,11 @@ bool smb_inherit_flags(int flags, bool is_dir) + int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path, + __le32 *pdaccess, int uid) + { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap = mnt_idmap(path->mnt); ++#else + struct user_namespace *user_ns = mnt_user_ns(path->mnt); ++#endif + struct smb_ntsd *pntsd = NULL; + struct smb_acl *pdacl; + struct posix_acl *posix_acls; +@@ -1206,7 +1348,11 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path, + unsigned short ace_size; + + ksmbd_debug(SMB, "check permission using windows acl\n"); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ pntsd_size = ksmbd_vfs_get_sd_xattr(conn, idmap, ++#else + pntsd_size = ksmbd_vfs_get_sd_xattr(conn, user_ns, ++#endif + path->dentry, &pntsd); + if (pntsd_size <= 0 || !pntsd) + goto err_out; +@@ -1289,16 +1435,28 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path, } if (IS_ENABLED(CONFIG_FS_POSIX_ACL)) { @@ -17350,7 +19109,47 @@ index b05ff9b146b5..3d7f5a09e26a 100644 if (posix_acls && !found) { unsigned int id = -1; -@@ -1377,6 +1423,7 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon, + pa_entry = posix_acls->a_entries; + for (i = 0; i < posix_acls->a_count; i++, pa_entry++) { + if (pa_entry->e_tag == ACL_USER) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ id = posix_acl_uid_translate(idmap, pa_entry); ++#else + id = posix_acl_uid_translate(user_ns, pa_entry); ++#endif + else if (pa_entry->e_tag == ACL_GROUP) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ id = posix_acl_gid_translate(idmap, pa_entry); ++#else + id = posix_acl_gid_translate(user_ns, pa_entry); ++#endif + else + continue; + +@@ -1360,14 +1518,22 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon, + int rc; + struct smb_fattr fattr = {{0}}; + struct inode *inode = d_inode(path->dentry); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap = mnt_idmap(path->mnt); ++#else + struct user_namespace *user_ns = mnt_user_ns(path->mnt); ++#endif + struct iattr newattrs; + + fattr.cf_uid = INVALID_UID; + fattr.cf_gid = INVALID_GID; + fattr.cf_mode = inode->i_mode; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = parse_sec_desc(idmap, pntsd, ntsd_len, &fattr); ++#else + rc = parse_sec_desc(user_ns, pntsd, ntsd_len, &fattr); ++#endif + if (rc) + goto out; + +@@ -1377,24 +1543,55 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon, newattrs.ia_uid = fattr.cf_uid; } if (!gid_eq(fattr.cf_gid, INVALID_GID)) { @@ -17358,13 +19157,23 @@ index b05ff9b146b5..3d7f5a09e26a 100644 newattrs.ia_valid |= ATTR_GID; newattrs.ia_gid = fattr.cf_gid; } -@@ -1386,15 +1433,33 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon, + newattrs.ia_valid |= ATTR_MODE; + newattrs.ia_mode = (inode->i_mode & ~0777) | (fattr.cf_mode & 0777); + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ ksmbd_vfs_remove_acl_xattrs(idmap, path->dentry); ++#else ksmbd_vfs_remove_acl_xattrs(user_ns, path->dentry); ++#endif /* Update posix acls */ if (IS_ENABLED(CONFIG_FS_POSIX_ACL) && fattr.cf_dacls) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 2, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = set_posix_acl(idmap, path->dentry, ++#else + rc = set_posix_acl(user_ns, path->dentry, ++#endif +#else rc = set_posix_acl(user_ns, inode, - ACL_TYPE_ACCESS, fattr.cf_acls); @@ -17381,7 +19190,11 @@ index b05ff9b146b5..3d7f5a09e26a 100644 if (S_ISDIR(inode->i_mode) && fattr.cf_dacls) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 2, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = set_posix_acl(idmap, path->dentry, ++#else + rc = set_posix_acl(user_ns, path->dentry, ++#endif +#else rc = set_posix_acl(user_ns, inode, +#endif @@ -17393,20 +19206,38 @@ index b05ff9b146b5..3d7f5a09e26a 100644 if (rc) ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_DEFAULT) failed, rc : %d\n", -@@ -1403,7 +1468,11 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon, +@@ -1403,7 +1600,15 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon, } inode_lock(inode); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = notify_change(idmap, path->dentry, &newattrs, NULL); ++#else rc = notify_change(user_ns, path->dentry, &newattrs, NULL); ++#endif +#else + rc = notify_change(path->dentry, &newattrs, NULL); +#endif inode_unlock(inode); if (rc) goto out; +@@ -1414,8 +1619,13 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon, + + if (test_share_config_flag(tcon->share_conf, KSMBD_SHARE_FLAG_ACL_XATTR)) { + /* Update WinACL in xattr */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ ksmbd_vfs_remove_sd_xattrs(idmap, path->dentry); ++ ksmbd_vfs_set_sd_xattr(conn, idmap, ++#else + ksmbd_vfs_remove_sd_xattrs(user_ns, path->dentry); + ksmbd_vfs_set_sd_xattr(conn, user_ns, ++#endif + path->dentry, pntsd, ntsd_len); + } + diff --git a/fs/ksmbd/smbacl.h b/fs/ksmbd/smbacl.h -index 618f2e0236b3..d153aab64e6b 100644 +index 618f2e0236b3..4e000665bce5 100644 --- a/fs/ksmbd/smbacl.h +++ b/fs/ksmbd/smbacl.h @@ -8,10 +8,13 @@ @@ -17423,8 +19254,33 @@ index 618f2e0236b3..d153aab64e6b 100644 #include "mgmt/tree_connect.h" -@@ -214,25 +217,67 @@ void ksmbd_init_domain(u32 *sub_auth); +@@ -190,9 +193,17 @@ struct posix_acl_state { + struct posix_ace_state_array *groups; + }; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int parse_sec_desc(struct mnt_idmap *idmap, struct smb_ntsd *pntsd, ++#else + int parse_sec_desc(struct user_namespace *user_ns, struct smb_ntsd *pntsd, ++#endif + int acl_len, struct smb_fattr *fattr); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int build_sec_desc(struct mnt_idmap *idmap, struct smb_ntsd *pntsd, ++#else + int build_sec_desc(struct user_namespace *user_ns, struct smb_ntsd *pntsd, ++#endif + struct smb_ntsd *ppntsd, int ppntsd_size, int addition_info, + __u32 *secdesclen, struct smb_fattr *fattr); + int init_acl_state(struct posix_acl_state *state, int cnt); +@@ -211,28 +222,86 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon, + void id_to_sid(unsigned int cid, uint sidtype, struct smb_sid *ssid); + void ksmbd_init_domain(u32 *sub_auth); + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++static inline uid_t posix_acl_uid_translate(struct mnt_idmap *idmap, ++#else static inline uid_t posix_acl_uid_translate(struct user_namespace *mnt_userns, ++#endif struct posix_acl_entry *pace) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) @@ -17438,7 +19294,11 @@ index 618f2e0236b3..d153aab64e6b 100644 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) || \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 52) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0)) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ vfsuid = make_vfsuid(idmap, &init_user_ns, pace->e_uid); ++#else vfsuid = make_vfsuid(mnt_userns, &init_user_ns, pace->e_uid); ++#endif +#else + kuid = mapped_kuid_fs(mnt_userns, &init_user_ns, pace->e_uid); +#endif @@ -17457,7 +19317,11 @@ index 618f2e0236b3..d153aab64e6b 100644 +#endif } ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++static inline gid_t posix_acl_gid_translate(struct mnt_idmap *idmap, ++#else static inline gid_t posix_acl_gid_translate(struct user_namespace *mnt_userns, ++#endif struct posix_acl_entry *pace) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) @@ -17471,7 +19335,11 @@ index 618f2e0236b3..d153aab64e6b 100644 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) || \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 52) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0)) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ vfsgid = make_vfsgid(idmap, &init_user_ns, pace->e_gid); ++#else vfsgid = make_vfsgid(mnt_userns, &init_user_ns, pace->e_gid); ++#endif +#else + kgid = mapped_kgid_fs(mnt_userns, &init_user_ns, pace->e_gid); +#endif @@ -17755,7 +19623,7 @@ index 40c721f9227e..d5a871da3a7d 100644 ipc_msg_handle_free(req->handle); ipc_msg_free(msg); diff --git a/fs/ksmbd/transport_rdma.c b/fs/ksmbd/transport_rdma.c -index 096eda9ef873..6ca0be788386 100644 +index c06efc020bd9..6ca0be788386 100644 --- a/fs/ksmbd/transport_rdma.c +++ b/fs/ksmbd/transport_rdma.c @@ -201,7 +201,7 @@ struct smb_direct_rdma_rw_msg { @@ -17778,15 +19646,6 @@ index 096eda9ef873..6ca0be788386 100644 } static void smb_direct_destroy_pools(struct smb_direct_transport *transport); -@@ -670,7 +670,7 @@ static int smb_direct_post_recv(struct smb_direct_transport *t, - } - - static int smb_direct_read(struct ksmbd_transport *t, char *buf, -- unsigned int size) -+ unsigned int size, int unused) - { - struct smb_direct_recvmsg *recvmsg; - struct smb_direct_data_transfer *data_transfer; @@ -1703,11 +1703,11 @@ static int smb_direct_init_params(struct smb_direct_transport *t, int max_send_sges, max_rw_wrs, max_send_wrs; unsigned int max_sge_per_wr, wrs_per_credit; @@ -17900,7 +19759,7 @@ index 096eda9ef873..6ca0be788386 100644 static void smb_direct_ib_client_remove(struct ib_device *ib_dev, diff --git a/fs/ksmbd/transport_tcp.c b/fs/ksmbd/transport_tcp.c -index 603893fd87f5..95d96a4353fa 100644 +index 20e85e2701f2..b5db6b4652a2 100644 --- a/fs/ksmbd/transport_tcp.c +++ b/fs/ksmbd/transport_tcp.c @@ -48,27 +48,55 @@ static struct interface *alloc_iface(char *ifname); @@ -17973,85 +19832,16 @@ index 603893fd87f5..95d96a4353fa 100644 KSMBD_TRANS(t)->handler = kthread_run(ksmbd_conn_handler_loop, KSMBD_TRANS(t)->conn, "ksmbd:%u", -@@ -291,16 +319,18 @@ static int ksmbd_tcp_run_kthread(struct interface *iface) - - /** - * ksmbd_tcp_readv() - read data from socket in given iovec -- * @t: TCP transport instance -- * @iov_orig: base IO vector -- * @nr_segs: number of segments in base iov -- * @to_read: number of bytes to read from socket -+ * @t: TCP transport instance -+ * @iov_orig: base IO vector -+ * @nr_segs: number of segments in base iov -+ * @to_read: number of bytes to read from socket -+ * @max_retries: maximum retry count - * - * Return: on success return number of bytes read from socket, - * otherwise return error number - */ - static int ksmbd_tcp_readv(struct tcp_transport *t, struct kvec *iov_orig, -- unsigned int nr_segs, unsigned int to_read) -+ unsigned int nr_segs, unsigned int to_read, -+ int max_retries) - { - int length = 0; - int total_read; -@@ -308,7 +338,6 @@ static int ksmbd_tcp_readv(struct tcp_transport *t, struct kvec *iov_orig, - struct msghdr ksmbd_msg; - struct kvec *iov; - struct ksmbd_conn *conn = KSMBD_TRANS(t)->conn; -- int max_retry = 2; - - iov = get_conn_iovec(t, nr_segs); - if (!iov) -@@ -335,14 +364,23 @@ static int ksmbd_tcp_readv(struct tcp_transport *t, struct kvec *iov_orig, - } else if (conn->status == KSMBD_SESS_NEED_RECONNECT) { - total_read = -EAGAIN; +@@ -333,7 +361,7 @@ static int ksmbd_tcp_readv(struct tcp_transport *t, struct kvec *iov_orig, + if (length == -EINTR) { + total_read = -ESHUTDOWN; break; -- } else if ((length == -ERESTARTSYS || length == -EAGAIN) && -- max_retry) { -+ } else if (length == -ERESTARTSYS || length == -EAGAIN) { -+ /* -+ * If max_retries is negative, Allow unlimited -+ * retries to keep connection with inactive sessions. -+ */ -+ if (max_retries == 0) { -+ total_read = length; -+ break; -+ } else if (max_retries > 0) { -+ max_retries--; -+ } -+ - usleep_range(1000, 2000); - length = 0; -- max_retry--; - continue; - } else if (length <= 0) { -- total_read = -EAGAIN; -+ total_read = length; +- } else if (conn->status == KSMBD_SESS_NEED_RECONNECT) { ++ } else if (ksmbd_conn_need_reconnect(conn)) { + total_read = -EAGAIN; break; - } - } -@@ -358,14 +396,15 @@ static int ksmbd_tcp_readv(struct tcp_transport *t, struct kvec *iov_orig, - * Return: on success return number of bytes read from socket, - * otherwise return error number - */ --static int ksmbd_tcp_read(struct ksmbd_transport *t, char *buf, unsigned int to_read) -+static int ksmbd_tcp_read(struct ksmbd_transport *t, char *buf, -+ unsigned int to_read, int max_retries) - { - struct kvec iov; - - iov.iov_base = buf; - iov.iov_len = to_read; - -- return ksmbd_tcp_readv(TCP_TRANS(t), &iov, 1, to_read); -+ return ksmbd_tcp_readv(TCP_TRANS(t), &iov, 1, to_read, max_retries); - } - - static int ksmbd_tcp_writev(struct ksmbd_transport *t, struct kvec *iov, -@@ -439,11 +478,23 @@ static int create_socket(struct interface *iface) + } else if (length == -ERESTARTSYS || length == -EAGAIN) { +@@ -450,11 +478,23 @@ static int create_socket(struct interface *iface) ksmbd_tcp_nodelay(ksmbd_socket); ksmbd_tcp_reuseaddr(ksmbd_socket); @@ -18075,7 +19865,7 @@ index 603893fd87f5..95d96a4353fa 100644 if (ret != -ENODEV && ret < 0) { pr_err("Failed to set SO_BINDTODEVICE: %d\n", ret); goto out_error; -@@ -495,7 +546,7 @@ static int ksmbd_netdev_event(struct notifier_block *nb, unsigned long event, +@@ -506,7 +546,7 @@ static int ksmbd_netdev_event(struct notifier_block *nb, unsigned long event, switch (event) { case NETDEV_UP: @@ -18084,7 +19874,7 @@ index 603893fd87f5..95d96a4353fa 100644 return NOTIFY_OK; list_for_each_entry(iface, &iface_list, entry) { -@@ -604,7 +655,7 @@ int ksmbd_tcp_set_interfaces(char *ifc_list, int ifc_list_sz) +@@ -615,7 +655,7 @@ int ksmbd_tcp_set_interfaces(char *ifc_list, int ifc_list_sz) rtnl_lock(); for_each_netdev(&init_net, netdev) { @@ -18137,7 +19927,7 @@ index 076f6034a789..9252b68f35bb 100644 const struct nls_table *codepage); char *smb_strndup_from_utf16(const char *src, const int maxlen, diff --git a/fs/ksmbd/vfs.c b/fs/ksmbd/vfs.c -index 94b8ed4ef870..2fc7c6ac112f 100644 +index 94b8ed4ef870..04f4bb983302 100644 --- a/fs/ksmbd/vfs.c +++ b/fs/ksmbd/vfs.c @@ -6,19 +6,24 @@ @@ -18180,12 +19970,27 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 static char *extract_last_component(char *path) { char *p = strrchr(path, '/'); -@@ -76,8 +86,13 @@ int ksmbd_vfs_lock_parent(struct user_namespace *user_ns, struct dentry *parent, +@@ -69,15 +79,28 @@ static void ksmbd_vfs_inherit_owner(struct ksmbd_work *work, + * + * the reference count of @parent isn't incremented. + */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_lock_parent(struct mnt_idmap *idmap, struct dentry *parent, ++#else + int ksmbd_vfs_lock_parent(struct user_namespace *user_ns, struct dentry *parent, ++#endif + struct dentry *child) + { + struct dentry *dentry; int ret = 0; inode_lock_nested(d_inode(parent), I_MUTEX_PARENT); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ dentry = lookup_one(idmap, child->d_name.name, parent, ++#else dentry = lookup_one(user_ns, child->d_name.name, parent, ++#endif child->d_name.len); +#else + dentry = lookup_one_len(child->d_name.name, parent, @@ -18194,12 +19999,37 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 if (IS_ERR(dentry)) { ret = PTR_ERR(dentry); goto out_err; -@@ -109,8 +124,12 @@ int ksmbd_vfs_may_delete(struct user_namespace *user_ns, +@@ -96,28 +119,48 @@ int ksmbd_vfs_lock_parent(struct user_namespace *user_ns, struct dentry *parent, + return ret; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_may_delete(struct mnt_idmap *idmap, ++#else + int ksmbd_vfs_may_delete(struct user_namespace *user_ns, ++#endif + struct dentry *dentry) + { + struct dentry *parent; + int ret; + + parent = dget_parent(dentry); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ ret = ksmbd_vfs_lock_parent(idmap, parent, dentry); ++#else + ret = ksmbd_vfs_lock_parent(user_ns, parent, dentry); ++#endif + if (ret) { + dput(parent); return ret; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ ret = inode_permission(idmap, d_inode(parent), ++#else ret = inode_permission(user_ns, d_inode(parent), ++#endif MAY_EXEC | MAY_WRITE); +#else + ret = inode_permission(d_inode(parent), MAY_EXEC | MAY_WRITE); @@ -18207,12 +20037,27 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 inode_unlock(d_inode(parent)); dput(parent); -@@ -125,16 +144,28 @@ int ksmbd_vfs_query_maximal_access(struct user_namespace *user_ns, + return ret; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_query_maximal_access(struct mnt_idmap *idmap, ++#else + int ksmbd_vfs_query_maximal_access(struct user_namespace *user_ns, ++#endif + struct dentry *dentry, __le32 *daccess) + { + struct dentry *parent; +@@ -125,26 +168,62 @@ int ksmbd_vfs_query_maximal_access(struct user_namespace *user_ns, *daccess = cpu_to_le32(FILE_READ_ATTRIBUTES | READ_CONTROL); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ if (!inode_permission(idmap, d_inode(dentry), MAY_OPEN | MAY_WRITE)) ++#else if (!inode_permission(user_ns, d_inode(dentry), MAY_OPEN | MAY_WRITE)) ++#endif +#else + if (!inode_permission(d_inode(dentry), MAY_OPEN | MAY_WRITE)) +#endif @@ -18222,52 +20067,96 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 FILE_DELETE_CHILD); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ if (!inode_permission(idmap, d_inode(dentry), MAY_OPEN | MAY_READ)) ++#else if (!inode_permission(user_ns, d_inode(dentry), MAY_OPEN | MAY_READ)) ++#endif +#else + if (!inode_permission(d_inode(dentry), MAY_OPEN | MAY_READ)) +#endif *daccess |= FILE_READ_DATA_LE | FILE_READ_EA_LE; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ if (!inode_permission(idmap, d_inode(dentry), MAY_OPEN | MAY_EXEC)) ++#else if (!inode_permission(user_ns, d_inode(dentry), MAY_OPEN | MAY_EXEC)) ++#endif +#else + if (!inode_permission(d_inode(dentry), MAY_OPEN | MAY_EXEC)) +#endif *daccess |= FILE_EXECUTE_LE; parent = dget_parent(dentry); -@@ -144,7 +175,11 @@ int ksmbd_vfs_query_maximal_access(struct user_namespace *user_ns, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ ret = ksmbd_vfs_lock_parent(idmap, parent, dentry); ++#else + ret = ksmbd_vfs_lock_parent(user_ns, parent, dentry); ++#endif + if (ret) { + dput(parent); return ret; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ if (!inode_permission(idmap, d_inode(parent), MAY_EXEC | MAY_WRITE)) ++#else if (!inode_permission(user_ns, d_inode(parent), MAY_EXEC | MAY_WRITE)) ++#endif +#else + if (!inode_permission(d_inode(parent), MAY_EXEC | MAY_WRITE)) +#endif *daccess |= FILE_DELETE_LE; inode_unlock(d_inode(parent)); -@@ -177,8 +212,11 @@ int ksmbd_vfs_create(struct ksmbd_work *work, const char *name, umode_t mode) +@@ -177,8 +256,17 @@ int ksmbd_vfs_create(struct ksmbd_work *work, const char *name, umode_t mode) } mode |= S_IFREG; -- err = vfs_create(mnt_user_ns(path.mnt), d_inode(path.dentry), -- dentry, mode, true); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) -+ err = vfs_create(mnt_user_ns(path.mnt), d_inode(path.dentry), dentry, mode, true); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ err = vfs_create(mnt_idmap(path.mnt), d_inode(path.dentry), ++ dentry, mode, true); ++#else + err = vfs_create(mnt_user_ns(path.mnt), d_inode(path.dentry), + dentry, mode, true); ++#endif +#else + err = vfs_create(d_inode(path.dentry), dentry, mode, true); +#endif if (!err) { ksmbd_vfs_inherit_owner(work, d_inode(path.dentry), d_inode(dentry)); -@@ -217,14 +255,23 @@ int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode) +@@ -199,7 +287,11 @@ int ksmbd_vfs_create(struct ksmbd_work *work, const char *name, umode_t mode) + */ + int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode) + { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap; ++#else + struct user_namespace *user_ns; ++#endif + struct path path; + struct dentry *dentry; + int err; +@@ -215,16 +307,37 @@ int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode) + return err; + } ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ idmap = mnt_idmap(path.mnt); ++#else user_ns = mnt_user_ns(path.mnt); ++#endif mode |= S_IFDIR; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ err = vfs_mkdir(idmap, d_inode(path.dentry), dentry, mode); ++#else err = vfs_mkdir(user_ns, d_inode(path.dentry), dentry, mode); ++#endif +#else + err = vfs_mkdir(d_inode(path.dentry), dentry, mode); +#endif @@ -18277,7 +20166,11 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 struct dentry *d; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ d = lookup_one(idmap, dentry->d_name.name, dentry->d_parent, ++#else d = lookup_one(user_ns, dentry->d_name.name, dentry->d_parent, ++#endif dentry->d_name.len); +#else + d = lookup_one_len(dentry->d_name.name, dentry->d_parent, @@ -18286,7 +20179,43 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 if (IS_ERR(d)) { err = PTR_ERR(d); goto out; -@@ -321,7 +368,11 @@ static int check_lock_range(struct file *filp, loff_t start, loff_t end, +@@ -245,7 +358,11 @@ int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode) + return err; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++static ssize_t ksmbd_vfs_getcasexattr(struct mnt_idmap *idmap, ++#else + static ssize_t ksmbd_vfs_getcasexattr(struct user_namespace *user_ns, ++#endif + struct dentry *dentry, char *attr_name, + int attr_name_len, char **attr_value) + { +@@ -262,7 +379,11 @@ static ssize_t ksmbd_vfs_getcasexattr(struct user_namespace *user_ns, + if (strncasecmp(attr_name, name, attr_name_len)) + continue; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ value_len = ksmbd_vfs_getxattr(idmap, ++#else + value_len = ksmbd_vfs_getxattr(user_ns, ++#endif + dentry, + name, + attr_value); +@@ -285,7 +406,11 @@ static int ksmbd_vfs_stream_read(struct ksmbd_file *fp, char *buf, loff_t *pos, + ksmbd_debug(VFS, "read stream data pos : %llu, count : %zd\n", + *pos, count); + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ v_len = ksmbd_vfs_getcasexattr(file_mnt_idmap(fp->filp), ++#else + v_len = ksmbd_vfs_getcasexattr(file_mnt_user_ns(fp->filp), ++#endif + fp->filp->f_path.dentry, + fp->stream.name, + fp->stream.size, +@@ -321,7 +446,11 @@ static int check_lock_range(struct file *filp, loff_t start, loff_t end, unsigned char type) { struct file_lock *flock; @@ -18298,7 +20227,43 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 int error = 0; if (!ctx || list_empty_careful(&ctx->flc_posix)) -@@ -551,6 +602,269 @@ int ksmbd_vfs_getattr(const struct path *path, struct kstat *stat) +@@ -409,7 +538,11 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos, + size_t count) + { + char *stream_buf = NULL, *wbuf; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap = file_mnt_idmap(fp->filp); ++#else + struct user_namespace *user_ns = file_mnt_user_ns(fp->filp); ++#endif + size_t size, v_len; + int err = 0; + +@@ -422,7 +555,11 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos, + count = (*pos + count) - XATTR_SIZE_MAX; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ v_len = ksmbd_vfs_getcasexattr(idmap, ++#else + v_len = ksmbd_vfs_getcasexattr(user_ns, ++#endif + fp->filp->f_path.dentry, + fp->stream.name, + fp->stream.size, +@@ -448,7 +585,11 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos, + + memcpy(&stream_buf[*pos], buf, count); + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ err = ksmbd_vfs_setxattr(idmap, ++#else + err = ksmbd_vfs_setxattr(user_ns, ++#endif + fp->filp->f_path.dentry, + fp->stream.name, + (void *)stream_buf, +@@ -551,6 +692,269 @@ int ksmbd_vfs_getattr(const struct path *path, struct kstat *stat) return err; } @@ -18568,12 +20533,46 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 /** * ksmbd_vfs_fsync() - vfs helper for smb fsync * @work: work -@@ -614,12 +928,20 @@ int ksmbd_vfs_remove_file(struct ksmbd_work *work, char *name) +@@ -583,7 +987,11 @@ int ksmbd_vfs_fsync(struct ksmbd_work *work, u64 fid, u64 p_id) + */ + int ksmbd_vfs_remove_file(struct ksmbd_work *work, char *name) + { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap; ++#else + struct user_namespace *user_ns; ++#endif + struct path path; + struct dentry *parent; + int err; +@@ -598,9 +1006,17 @@ int ksmbd_vfs_remove_file(struct ksmbd_work *work, char *name) + return err; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ idmap = mnt_idmap(path.mnt); ++#else + user_ns = mnt_user_ns(path.mnt); ++#endif + parent = dget_parent(path.dentry); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ err = ksmbd_vfs_lock_parent(idmap, parent, path.dentry); ++#else + err = ksmbd_vfs_lock_parent(user_ns, parent, path.dentry); ++#endif + if (err) { + dput(parent); + path_put(&path); +@@ -614,12 +1030,28 @@ int ksmbd_vfs_remove_file(struct ksmbd_work *work, char *name) } if (S_ISDIR(d_inode(path.dentry)->i_mode)) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ err = vfs_rmdir(idmap, d_inode(parent), path.dentry); ++#else err = vfs_rmdir(user_ns, d_inode(parent), path.dentry); ++#endif +#else + err = vfs_rmdir(d_inode(parent), path.dentry); +#endif @@ -18582,34 +20581,74 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 err); } else { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ err = vfs_unlink(idmap, d_inode(parent), path.dentry, NULL); ++#else err = vfs_unlink(user_ns, d_inode(parent), path.dentry, NULL); ++#endif +#else + err = vfs_unlink(d_inode(parent), path.dentry, NULL); +#endif if (err) ksmbd_debug(VFS, "%s: unlink failed, err %d\n", name, err); -@@ -672,9 +994,13 @@ int ksmbd_vfs_link(struct ksmbd_work *work, const char *oldname, +@@ -672,9 +1104,19 @@ int ksmbd_vfs_link(struct ksmbd_work *work, const char *oldname, goto out3; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ err = vfs_link(oldpath.dentry, mnt_idmap(newpath.mnt), ++ d_inode(newpath.dentry), ++ dentry, NULL); ++#else err = vfs_link(oldpath.dentry, mnt_user_ns(newpath.mnt), d_inode(newpath.dentry), dentry, NULL); ++#endif +#else + err = vfs_link(oldpath.dentry, d_inode(newpath.dentry), dentry, NULL); +#endif if (err) ksmbd_debug(VFS, "vfs_link failed err %d\n", err); -@@ -740,8 +1066,13 @@ static int __ksmbd_vfs_rename(struct ksmbd_work *work, +@@ -710,6 +1152,16 @@ static int ksmbd_validate_entry_in_use(struct dentry *src_dent) + return 0; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++static int __ksmbd_vfs_rename(struct ksmbd_work *work, ++ struct mnt_idmap *src_idmap, ++ struct dentry *src_dent_parent, ++ struct dentry *src_dent, ++ struct mnt_idmap *dst_idmap, ++ struct dentry *dst_dent_parent, ++ struct dentry *trap_dent, ++ char *dst_name) ++#else + static int __ksmbd_vfs_rename(struct ksmbd_work *work, + struct user_namespace *src_user_ns, + struct dentry *src_dent_parent, +@@ -718,6 +1170,7 @@ static int __ksmbd_vfs_rename(struct ksmbd_work *work, + struct dentry *dst_dent_parent, + struct dentry *trap_dent, + char *dst_name) ++#endif + { + struct dentry *dst_dent; + int err; +@@ -740,8 +1193,18 @@ static int __ksmbd_vfs_rename(struct ksmbd_work *work, if (ksmbd_override_fsids(work)) return -ENOMEM; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ dst_dent = lookup_one(dst_idmap, dst_name, ++ dst_dent_parent, strlen(dst_name)); ++#else dst_dent = lookup_one(dst_user_ns, dst_name, dst_dent_parent, strlen(dst_name)); ++#endif +#else + dst_dent = lookup_one_len(dst_name, dst_dent_parent, + strlen(dst_name)); @@ -18617,17 +20656,29 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 err = PTR_ERR(dst_dent); if (IS_ERR(dst_dent)) { pr_err("lookup failed %s [%d]\n", dst_name, err); -@@ -750,6 +1081,7 @@ static int __ksmbd_vfs_rename(struct ksmbd_work *work, +@@ -750,6 +1213,17 @@ static int __ksmbd_vfs_rename(struct ksmbd_work *work, err = -ENOTEMPTY; if (dst_dent != trap_dent && !d_really_is_positive(dst_dent)) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct renamedata rd = { ++ .old_mnt_idmap = src_idmap, ++ .old_dir = d_inode(src_dent_parent), ++ .old_dentry = src_dent, ++ .new_mnt_idmap = dst_idmap, ++ .new_dir = d_inode(dst_dent_parent), ++ .new_dentry = dst_dent, ++ }; ++#else struct renamedata rd = { .old_mnt_userns = src_user_ns, .old_dir = d_inode(src_dent_parent), -@@ -759,6 +1091,14 @@ static int __ksmbd_vfs_rename(struct ksmbd_work *work, +@@ -758,7 +1232,16 @@ static int __ksmbd_vfs_rename(struct ksmbd_work *work, + .new_dir = d_inode(dst_dent_parent), .new_dentry = dst_dent, }; ++#endif err = vfs_rename(&rd); +#else + err = vfs_rename(d_inode(src_dent_parent), @@ -18640,12 +20691,33 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 } if (err) pr_err("vfs_rename failed err %d\n", err); -@@ -801,8 +1141,13 @@ int ksmbd_vfs_fp_rename(struct ksmbd_work *work, struct ksmbd_file *fp, +@@ -772,7 +1255,11 @@ static int __ksmbd_vfs_rename(struct ksmbd_work *work, + int ksmbd_vfs_fp_rename(struct ksmbd_work *work, struct ksmbd_file *fp, + char *newname) + { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap; ++#else + struct user_namespace *user_ns; ++#endif + struct path dst_path; + struct dentry *src_dent_parent, *dst_dent_parent; + struct dentry *src_dent, *trap_dent, *src_child; +@@ -800,9 +1287,22 @@ int ksmbd_vfs_fp_rename(struct ksmbd_work *work, struct ksmbd_file *fp, + trap_dent = lock_rename(src_dent_parent, dst_dent_parent); dget(src_dent); dget(dst_dent_parent); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ idmap = file_mnt_idmap(fp->filp); ++#else user_ns = file_mnt_user_ns(fp->filp); ++#endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ src_child = lookup_one(idmap, src_dent->d_name.name, src_dent_parent, ++#else src_child = lookup_one(user_ns, src_dent->d_name.name, src_dent_parent, ++#endif src_dent->d_name.len); +#else + src_child = lookup_one_len(src_dent->d_name.name, src_dent_parent, @@ -18654,7 +20726,32 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 if (IS_ERR(src_child)) { err = PTR_ERR(src_child); goto out_lock; -@@ -836,6 +1181,7 @@ int ksmbd_vfs_fp_rename(struct ksmbd_work *work, struct ksmbd_file *fp, +@@ -815,6 +1315,16 @@ int ksmbd_vfs_fp_rename(struct ksmbd_work *work, struct ksmbd_file *fp, + } + dput(src_child); + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ err = __ksmbd_vfs_rename(work, ++ idmap, ++ src_dent_parent, ++ src_dent, ++ mnt_idmap(dst_path.mnt), ++ dst_dent_parent, ++ trap_dent, ++ dst_name); ++#else + err = __ksmbd_vfs_rename(work, + user_ns, + src_dent_parent, +@@ -823,6 +1333,7 @@ int ksmbd_vfs_fp_rename(struct ksmbd_work *work, struct ksmbd_file *fp, + dst_dent_parent, + trap_dent, + dst_name); ++#endif + out_lock: + dput(src_dent); + dput(dst_dent_parent); +@@ -836,6 +1347,7 @@ int ksmbd_vfs_fp_rename(struct ksmbd_work *work, struct ksmbd_file *fp, /** * ksmbd_vfs_truncate() - vfs helper for smb file truncate * @work: work @@ -18662,7 +20759,7 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 * @fid: file id of old file * @size: truncate to given size * -@@ -847,6 +1193,9 @@ int ksmbd_vfs_truncate(struct ksmbd_work *work, +@@ -847,6 +1359,9 @@ int ksmbd_vfs_truncate(struct ksmbd_work *work, int err = 0; struct file *filp; @@ -18672,12 +20769,23 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 filp = fp->filp; /* Do we need to break any of a levelII oplock? */ -@@ -910,12 +1259,16 @@ ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list) +@@ -907,22 +1422,42 @@ ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list) + return size; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++static ssize_t ksmbd_vfs_xattr_len(struct mnt_idmap *idmap, ++#else static ssize_t ksmbd_vfs_xattr_len(struct user_namespace *user_ns, ++#endif struct dentry *dentry, char *xattr_name) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ return vfs_getxattr(idmap, dentry, xattr_name, NULL, 0); ++#else return vfs_getxattr(user_ns, dentry, xattr_name, NULL, 0); ++#endif +#else + return vfs_getxattr(dentry, xattr_name, NULL, 0); +#endif @@ -18686,26 +20794,75 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 /** * ksmbd_vfs_getxattr() - vfs helper for smb get extended attributes value - * @user_ns: user namespace ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) +++ @idmap: idmap ++#else ++ @user_ns: user namespace ++#endif * @dentry: dentry of file for getting xattrs * @xattr_name: name of xattr name to query * @xattr_buf: destination buffer xattr value -@@ -938,8 +1291,12 @@ ssize_t ksmbd_vfs_getxattr(struct user_namespace *user_ns, + * + * Return: read xattr value length on success, otherwise error + */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ssize_t ksmbd_vfs_getxattr(struct mnt_idmap *idmap, ++#else + ssize_t ksmbd_vfs_getxattr(struct user_namespace *user_ns, ++#endif + struct dentry *dentry, + char *xattr_name, char **xattr_buf) + { +@@ -930,7 +1465,11 @@ ssize_t ksmbd_vfs_getxattr(struct user_namespace *user_ns, + char *buf; + + *xattr_buf = NULL; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ xattr_len = ksmbd_vfs_xattr_len(idmap, dentry, xattr_name); ++#else + xattr_len = ksmbd_vfs_xattr_len(user_ns, dentry, xattr_name); ++#endif + if (xattr_len < 0) + return xattr_len; + +@@ -938,8 +1477,16 @@ ssize_t ksmbd_vfs_getxattr(struct user_namespace *user_ns, if (!buf) return -ENOMEM; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ xattr_len = vfs_getxattr(idmap, dentry, xattr_name, ++#else xattr_len = vfs_getxattr(user_ns, dentry, xattr_name, ++#endif (void *)buf, xattr_len); +#else + xattr_len = vfs_getxattr(dentry, xattr_name, (void *)buf, xattr_len); +#endif - if (xattr_len > 0) - *xattr_buf = buf; - else -@@ -960,12 +1317,20 @@ ssize_t ksmbd_vfs_getxattr(struct user_namespace *user_ns, + if (xattr_len > 0) + *xattr_buf = buf; + else +@@ -949,7 +1496,11 @@ ssize_t ksmbd_vfs_getxattr(struct user_namespace *user_ns, + + /** + * ksmbd_vfs_setxattr() - vfs helper for smb set extended attributes value ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ * @idmap: idmap of the relevant mount ++#else + * @user_ns: user namespace ++#endif + * @dentry: dentry to set XATTR at + * @name: xattr name for setxattr + * @value: xattr value to set +@@ -958,14 +1509,30 @@ ssize_t ksmbd_vfs_getxattr(struct user_namespace *user_ns, + * + * Return: 0 on success, otherwise error */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_setxattr(struct mnt_idmap *idmap, ++#else int ksmbd_vfs_setxattr(struct user_namespace *user_ns, ++#endif struct dentry *dentry, const char *attr_name, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0) void *attr_value, size_t attr_size, int flags) @@ -18716,7 +20873,11 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 int err; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ err = vfs_setxattr(idmap, ++#else err = vfs_setxattr(user_ns, ++#endif dentry, +#else + err = vfs_setxattr(dentry, @@ -18724,7 +20885,7 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 attr_name, attr_value, attr_size, -@@ -975,90 +1340,470 @@ int ksmbd_vfs_setxattr(struct user_namespace *user_ns, +@@ -975,71 +1542,536 @@ int ksmbd_vfs_setxattr(struct user_namespace *user_ns, return err; } @@ -18816,29 +20977,25 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 -int ksmbd_vfs_fqar_lseek(struct ksmbd_file *fp, loff_t start, loff_t length, - struct file_allocated_range_buffer *ranges, - unsigned int in_count, unsigned int *out_count) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_remove_acl_xattrs(struct mnt_idmap *idmap, ++ struct dentry *dentry) ++#else +int ksmbd_vfs_remove_acl_xattrs(struct user_namespace *user_ns, + struct dentry *dentry) ++#endif { - struct file *f = fp->filp; - struct inode *inode = file_inode(fp->filp); - loff_t maxbytes = (u64)inode->i_sb->s_maxbytes, end; - loff_t extent_start, extent_end; - int ret = 0; -- -- if (start > maxbytes) -- return -EFBIG; -- -- if (!in_count) -- return 0; + char *name, *xattr_list = NULL; + ssize_t xattr_list_len; + int err = 0; -- /* -- * Shrink request scope to what the fs can actually handle. -- */ -- if (length > maxbytes || (maxbytes - length) < start) -- length = maxbytes - start; +- if (start > maxbytes) +- return -EFBIG; + xattr_list_len = ksmbd_vfs_listxattr(dentry, &xattr_list); + if (xattr_list_len < 0) { + goto out; @@ -18847,52 +21004,52 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 + goto out; + } -- if (start + length > inode->i_size) -- length = inode->i_size - start; +- if (!in_count) +- return 0; + for (name = xattr_list; name - xattr_list < xattr_list_len; + name += strlen(name) + 1) { + ksmbd_debug(SMB, "%s, len %zd\n", name, strlen(name)); -- *out_count = 0; -- end = start + length; -- while (start < end && *out_count < in_count) { -- extent_start = vfs_llseek(f, start, SEEK_DATA); -- if (extent_start < 0) { -- if (extent_start != -ENXIO) -- ret = (int)extent_start; -- break; +- /* +- * Shrink request scope to what the fs can actually handle. +- */ +- if (length > maxbytes || (maxbytes - length) < start) +- length = maxbytes - start; + if (!strncmp(name, XATTR_NAME_POSIX_ACL_ACCESS, + sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1) || + !strncmp(name, XATTR_NAME_POSIX_ACL_DEFAULT, + sizeof(XATTR_NAME_POSIX_ACL_DEFAULT) - 1)) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 2, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ err = vfs_remove_acl(idmap, dentry, name); ++#else + err = vfs_remove_acl(user_ns, dentry, name); ++#endif +#else + err = ksmbd_vfs_remove_xattr(user_ns, dentry, name); +#endif + if (err) + ksmbd_debug(SMB, + "remove acl xattr failed : %s\n", name); - } ++ } + } +out: + kvfree(xattr_list); + return err; +} -- if (extent_start >= end) -- break; +- if (start + length > inode->i_size) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_remove_sd_xattrs(struct mnt_idmap *idmap, ++#else +int ksmbd_vfs_remove_sd_xattrs(struct user_namespace *user_ns, ++#endif + struct dentry *dentry) +{ + char *name, *xattr_list = NULL; + ssize_t xattr_list_len; + int err = 0; - -- extent_end = vfs_llseek(f, extent_start, SEEK_HOLE); -- if (extent_end < 0) { -- if (extent_end != -ENXIO) -- ret = (int)extent_end; ++ + xattr_list_len = ksmbd_vfs_listxattr(dentry, &xattr_list); + if (xattr_list_len < 0) { + goto out; @@ -18906,7 +21063,11 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 + ksmbd_debug(SMB, "%s, len %zd\n", name, strlen(name)); + + if (!strncmp(name, XATTR_NAME_SD, XATTR_NAME_SD_LEN)) { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ err = ksmbd_vfs_remove_xattr(idmap, dentry, name); ++#else + err = ksmbd_vfs_remove_xattr(user_ns, dentry, name); ++#endif + if (err) + ksmbd_debug(SMB, "remove xattr failed : %s\n", name); + } @@ -18916,7 +21077,11 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 + return err; +} + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++static struct xattr_smb_acl *ksmbd_vfs_make_xattr_posix_acl(struct mnt_idmap *idmap, ++#else +static struct xattr_smb_acl *ksmbd_vfs_make_xattr_posix_acl(struct user_namespace *user_ns, ++#endif + struct inode *inode, + int acl_type) +{ @@ -18950,14 +21115,22 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 + switch (pa_entry->e_tag) { + case ACL_USER: + xa_entry->type = SMB_ACL_USER; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ xa_entry->uid = posix_acl_uid_translate(idmap, pa_entry); ++#else + xa_entry->uid = posix_acl_uid_translate(user_ns, pa_entry); ++#endif + break; + case ACL_USER_OBJ: + xa_entry->type = SMB_ACL_USER_OBJ; + break; + case ACL_GROUP: + xa_entry->type = SMB_ACL_GROUP; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ xa_entry->gid = posix_acl_gid_translate(idmap, pa_entry); ++#else + xa_entry->gid = posix_acl_gid_translate(user_ns, pa_entry); ++#endif + break; + case ACL_GROUP_OBJ: + xa_entry->type = SMB_ACL_GROUP_OBJ; @@ -18986,7 +21159,11 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 +} + +int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap, ++#else + struct user_namespace *user_ns, ++#endif + struct dentry *dentry, + struct smb_ntsd *pntsd, int len) +{ @@ -19019,13 +21196,25 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 + return rc; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ smb_acl = ksmbd_vfs_make_xattr_posix_acl(idmap, inode, ++#else + smb_acl = ksmbd_vfs_make_xattr_posix_acl(user_ns, inode, ++#endif + ACL_TYPE_ACCESS); + if (S_ISDIR(inode->i_mode)) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ def_smb_acl = ksmbd_vfs_make_xattr_posix_acl(idmap, inode, ++#else + def_smb_acl = ksmbd_vfs_make_xattr_posix_acl(user_ns, inode, ++#endif + ACL_TYPE_DEFAULT); + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = ndr_encode_posix_acl(&acl_ndr, idmap, inode, ++#else + rc = ndr_encode_posix_acl(&acl_ndr, user_ns, inode, ++#endif + smb_acl, def_smb_acl); + if (rc) { + pr_err("failed to encode ndr to posix acl\n"); @@ -19045,7 +21234,11 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 + goto out; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = ksmbd_vfs_setxattr(idmap, dentry, ++#else + rc = ksmbd_vfs_setxattr(user_ns, dentry, ++#endif + XATTR_NAME_SD, sd_ndr.data, + sd_ndr.offset, 0); + if (rc < 0) @@ -19060,7 +21253,11 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 +} + +int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap, ++#else + struct user_namespace *user_ns, ++#endif + struct dentry *dentry, + struct smb_ntsd **pntsd) +{ @@ -19072,7 +21269,11 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 + struct xattr_smb_acl *smb_acl = NULL, *def_smb_acl = NULL; + __u8 cmp_hash[XATTR_SD_HASH_SIZE] = {0}; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = ksmbd_vfs_getxattr(idmap, dentry, XATTR_NAME_SD, &n.data); ++#else + rc = ksmbd_vfs_getxattr(user_ns, dentry, XATTR_NAME_SD, &n.data); ++#endif + if (rc <= 0) + return rc; + @@ -19081,13 +21282,25 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 + if (rc) + goto free_n_data; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ smb_acl = ksmbd_vfs_make_xattr_posix_acl(idmap, inode, ++#else + smb_acl = ksmbd_vfs_make_xattr_posix_acl(user_ns, inode, ++#endif + ACL_TYPE_ACCESS); + if (S_ISDIR(inode->i_mode)) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ def_smb_acl = ksmbd_vfs_make_xattr_posix_acl(idmap, inode, ++#else + def_smb_acl = ksmbd_vfs_make_xattr_posix_acl(user_ns, inode, ++#endif + ACL_TYPE_DEFAULT); + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = ndr_encode_posix_acl(&acl_ndr, idmap, inode, smb_acl, ++#else + rc = ndr_encode_posix_acl(&acl_ndr, user_ns, inode, smb_acl, ++#endif + def_smb_acl); + if (rc) { + pr_err("failed to encode ndr to posix acl\n"); @@ -19134,7 +21347,11 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 + return rc; +} + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_set_dos_attrib_xattr(struct mnt_idmap *idmap, ++#else +int ksmbd_vfs_set_dos_attrib_xattr(struct user_namespace *user_ns, ++#endif + struct dentry *dentry, + struct xattr_dos_attrib *da) +{ @@ -19145,7 +21362,11 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 + if (err) + return err; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ err = ksmbd_vfs_setxattr(idmap, dentry, XATTR_NAME_DOS_ATTRIBUTE, ++#else + err = ksmbd_vfs_setxattr(user_ns, dentry, XATTR_NAME_DOS_ATTRIBUTE, ++#endif + (void *)n.data, n.offset, 0); + if (err) + ksmbd_debug(SMB, "failed to store dos attribute in xattr\n"); @@ -19154,14 +21375,22 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 + return err; +} + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_get_dos_attrib_xattr(struct mnt_idmap *idmap, ++#else +int ksmbd_vfs_get_dos_attrib_xattr(struct user_namespace *user_ns, ++#endif + struct dentry *dentry, + struct xattr_dos_attrib *da) +{ + struct ndr n; + int err; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ err = ksmbd_vfs_getxattr(idmap, dentry, XATTR_NAME_DOS_ATTRIBUTE, ++#else + err = ksmbd_vfs_getxattr(user_ns, dentry, XATTR_NAME_DOS_ATTRIBUTE, ++#endif + (char **)&n.data); + if (err > 0) { + n.length = err; @@ -19240,42 +21469,46 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 + length = maxbytes - start; + + if (start + length > inode->i_size) -+ length = inode->i_size - start; -+ -+ *out_count = 0; -+ end = start + length; -+ while (start < end && *out_count < in_count) { -+ extent_start = vfs_llseek(f, start, SEEK_DATA); -+ if (extent_start < 0) { -+ if (extent_start != -ENXIO) -+ ret = (int)extent_start; -+ break; -+ } -+ -+ if (extent_start >= end) -+ break; -+ -+ extent_end = vfs_llseek(f, extent_start, SEEK_HOLE); -+ if (extent_end < 0) { -+ if (extent_end != -ENXIO) -+ ret = (int)extent_end; - break; - } else if (extent_start >= extent_end) { - break; -@@ -1077,7 +1822,11 @@ int ksmbd_vfs_fqar_lseek(struct ksmbd_file *fp, loff_t start, loff_t length, + length = inode->i_size - start; + + *out_count = 0; +@@ -1074,26 +2106,58 @@ int ksmbd_vfs_fqar_lseek(struct ksmbd_file *fp, loff_t start, loff_t length, + return ret; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_remove_xattr(struct mnt_idmap *idmap, ++#else int ksmbd_vfs_remove_xattr(struct user_namespace *user_ns, ++#endif struct dentry *dentry, char *attr_name) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ return vfs_removexattr(idmap, dentry, attr_name); ++#else return vfs_removexattr(user_ns, dentry, attr_name); ++#endif +#else + return vfs_removexattr(dentry, attr_name); +#endif } ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_unlink(struct mnt_idmap *idmap, ++ struct dentry *dir, struct dentry *dentry) ++#else int ksmbd_vfs_unlink(struct user_namespace *user_ns, -@@ -1088,12 +1837,18 @@ int ksmbd_vfs_unlink(struct user_namespace *user_ns, + struct dentry *dir, struct dentry *dentry) ++#endif + { + int err = 0; +- ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ err = ksmbd_vfs_lock_parent(idmap, dir, dentry); ++#else err = ksmbd_vfs_lock_parent(user_ns, dir, dentry); ++#endif if (err) return err; - dget(dentry); @@ -19283,9 +21516,15 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 + dget(dentry); if (S_ISDIR(d_inode(dentry)->i_mode)) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ err = vfs_rmdir(idmap, d_inode(dir), dentry); ++ else ++ err = vfs_unlink(idmap, d_inode(dir), dentry, NULL); ++#else err = vfs_rmdir(user_ns, d_inode(dir), dentry); else err = vfs_unlink(user_ns, d_inode(dir), dentry, NULL); ++#endif +#else + err = vfs_rmdir(d_inode(dir), dentry); + else @@ -19294,7 +21533,7 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 dput(dentry); inode_unlock(d_inode(dir)); -@@ -1103,7 +1858,68 @@ int ksmbd_vfs_unlink(struct user_namespace *user_ns, +@@ -1103,7 +2167,68 @@ int ksmbd_vfs_unlink(struct user_namespace *user_ns, return err; } @@ -19363,7 +21602,7 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 loff_t offset, u64 ino, unsigned int d_type) { struct ksmbd_readdir_data *buf; -@@ -1111,7 +1927,13 @@ static bool __dir_empty(struct dir_context *ctx, const char *name, int namlen, +@@ -1111,7 +2236,13 @@ static bool __dir_empty(struct dir_context *ctx, const char *name, int namlen, buf = container_of(ctx, struct ksmbd_readdir_data, ctx); buf->dirent_count++; @@ -19377,7 +21616,7 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 } /** -@@ -1138,7 +1960,11 @@ int ksmbd_vfs_empty_dir(struct ksmbd_file *fp) +@@ -1138,7 +2269,11 @@ int ksmbd_vfs_empty_dir(struct ksmbd_file *fp) return err; } @@ -19389,7 +21628,7 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 int namlen, loff_t offset, u64 ino, unsigned int d_type) { -@@ -1148,7 +1974,11 @@ static bool __caseless_lookup(struct dir_context *ctx, const char *name, +@@ -1148,7 +2283,11 @@ static bool __caseless_lookup(struct dir_context *ctx, const char *name, buf = container_of(ctx, struct ksmbd_readdir_data, ctx); if (buf->used != namlen) @@ -19401,7 +21640,7 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 if (IS_ENABLED(CONFIG_UNICODE) && buf->um) { const struct qstr q_buf = {.name = buf->private, .len = buf->used}; -@@ -1162,9 +1992,17 @@ static bool __caseless_lookup(struct dir_context *ctx, const char *name, +@@ -1162,9 +2301,17 @@ static bool __caseless_lookup(struct dir_context *ctx, const char *name, if (!cmp) { memcpy((char *)buf->private, name, namlen); buf->dirent_count = 1; @@ -19419,7 +21658,7 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 } /** -@@ -1208,414 +2046,159 @@ static int ksmbd_vfs_lookup_in_dir(const struct path *dir, char *name, +@@ -1208,414 +2355,159 @@ static int ksmbd_vfs_lookup_in_dir(const struct path *dir, char *name, * @caseless: caseless filename lookup * * Return: 0 on success, otherwise error @@ -19646,16 +21885,17 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 - struct user_namespace *user_ns, - struct dentry *dentry, - struct smb_ntsd *pntsd, int len) -+ */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) -+int ksmbd_vfs_kern_path(struct ksmbd_work *work, char *name, -+ unsigned int flags, struct path *path, bool caseless) - { +-{ - int rc; - struct ndr sd_ndr = {0}, acl_ndr = {0}; - struct xattr_ntacl acl = {0}; - struct xattr_smb_acl *smb_acl, *def_smb_acl = NULL; - struct inode *inode = d_inode(dentry); ++ */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) ++int ksmbd_vfs_kern_path(struct ksmbd_work *work, char *name, ++ unsigned int flags, struct path *path, bool caseless) ++{ + struct ksmbd_share_config *share_conf = work->tcon->share_conf; + int err; @@ -19953,7 +22193,7 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 /** * ksmbd_vfs_init_kstat() - convert unix stat information to smb stat format -@@ -1637,7 +2220,7 @@ void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat) +@@ -1637,7 +2529,7 @@ void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat) time = ksmbd_UnixTimeToNT(kstat->ctime); info->ChangeTime = cpu_to_le64(time); @@ -19962,19 +22202,38 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 info->EndOfFile = 0; info->AllocationSize = 0; } else { -@@ -1657,7 +2240,11 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work, +@@ -1649,15 +2541,30 @@ void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat) + return info; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work, ++ struct mnt_idmap *idmap, ++ struct dentry *dentry, ++ struct ksmbd_kstat *ksmbd_kstat) ++#else + int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work, + struct user_namespace *user_ns, + struct dentry *dentry, + struct ksmbd_kstat *ksmbd_kstat) ++#endif + { u64 time; int rc; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ generic_fillattr(idmap, d_inode(dentry), ksmbd_kstat->kstat); ++#else generic_fillattr(user_ns, d_inode(dentry), ksmbd_kstat->kstat); ++#endif +#else + generic_fillattr(d_inode(dentry), ksmbd_kstat->kstat); +#endif time = ksmbd_UnixTimeToNT(ksmbd_kstat->kstat->ctime); ksmbd_kstat->create_time = time; -@@ -1667,9 +2254,9 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work, +@@ -1667,15 +2574,19 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work, * or that acl is disable in server's filesystem and the config is yes. */ if (S_ISDIR(ksmbd_kstat->kstat->mode)) @@ -19986,7 +22245,41 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 if (test_share_config_flag(work->tcon->share_conf, KSMBD_SHARE_FLAG_STORE_DOS_ATTRS)) { -@@ -1793,10 +2380,18 @@ int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work, + struct xattr_dos_attrib da; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = ksmbd_vfs_get_dos_attrib_xattr(idmap, dentry, &da); ++#else + rc = ksmbd_vfs_get_dos_attrib_xattr(user_ns, dentry, &da); ++#endif + if (rc > 0) { + ksmbd_kstat->file_attributes = cpu_to_le32(da.attr); + ksmbd_kstat->create_time = da.create_time; +@@ -1687,7 +2598,11 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work, + return 0; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ssize_t ksmbd_vfs_casexattr_len(struct mnt_idmap *idmap, ++#else + ssize_t ksmbd_vfs_casexattr_len(struct user_namespace *user_ns, ++#endif + struct dentry *dentry, char *attr_name, + int attr_name_len) + { +@@ -1704,7 +2619,11 @@ ssize_t ksmbd_vfs_casexattr_len(struct user_namespace *user_ns, + if (strncasecmp(attr_name, name, attr_name_len)) + continue; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ value_len = ksmbd_vfs_xattr_len(idmap, dentry, name); ++#else + value_len = ksmbd_vfs_xattr_len(user_ns, dentry, name); ++#endif + break; + } + +@@ -1793,10 +2712,18 @@ int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work, ret = vfs_copy_file_range(src_fp->filp, src_off, dst_fp->filp, dst_off, len, 0); @@ -20005,12 +22298,18 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 if (ret < 0) return ret; -@@ -1824,10 +2419,11 @@ void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock) +@@ -1823,11 +2750,17 @@ void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock) + locks_delete_block(flock); } ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap, ++ struct dentry *dentry) ++#else int ksmbd_vfs_set_init_posix_acl(struct user_namespace *user_ns, - struct inode *inode) + struct dentry *dentry) ++#endif { struct posix_acl_state acl_state; struct posix_acl *acls; @@ -20018,13 +22317,17 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 int rc; if (!IS_ENABLED(CONFIG_FS_POSIX_ACL)) -@@ -1856,14 +2452,29 @@ int ksmbd_vfs_set_init_posix_acl(struct user_namespace *user_ns, +@@ -1856,14 +2789,37 @@ int ksmbd_vfs_set_init_posix_acl(struct user_namespace *user_ns, return -ENOMEM; } posix_state_to_acl(&acl_state, acls->a_entries); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 2, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = set_posix_acl(idmap, dentry, ACL_TYPE_ACCESS, acls); ++#else + rc = set_posix_acl(user_ns, dentry, ACL_TYPE_ACCESS, acls); ++#endif +#else rc = set_posix_acl(user_ns, inode, ACL_TYPE_ACCESS, acls); +#endif @@ -20040,7 +22343,11 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 - acls); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 2, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = set_posix_acl(idmap, dentry, ACL_TYPE_DEFAULT, acls); ++#else + rc = set_posix_acl(user_ns, dentry, ACL_TYPE_DEFAULT, acls); ++#endif +#else + rc = set_posix_acl(user_ns, inode, ACL_TYPE_DEFAULT, acls); +#endif @@ -20050,12 +22357,18 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 if (rc < 0) ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_DEFAULT) failed, rc : %d\n", rc); -@@ -1874,16 +2485,21 @@ int ksmbd_vfs_set_init_posix_acl(struct user_namespace *user_ns, +@@ -1873,17 +2829,27 @@ int ksmbd_vfs_set_init_posix_acl(struct user_namespace *user_ns, + return rc; } ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap, ++ struct dentry *dentry, struct inode *parent_inode) ++#else int ksmbd_vfs_inherit_posix_acl(struct user_namespace *user_ns, - struct inode *inode, struct inode *parent_inode) + struct dentry *dentry, struct inode *parent_inode) ++#endif { struct posix_acl *acls; struct posix_acl_entry *pace; @@ -20073,13 +22386,17 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 if (!acls) return -ENOENT; pace = acls->a_entries; -@@ -1895,13 +2511,30 @@ int ksmbd_vfs_inherit_posix_acl(struct user_namespace *user_ns, +@@ -1895,13 +2861,39 @@ int ksmbd_vfs_inherit_posix_acl(struct user_namespace *user_ns, } } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 2, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = set_posix_acl(idmap, dentry, ACL_TYPE_ACCESS, acls); ++#else + rc = set_posix_acl(user_ns, dentry, ACL_TYPE_ACCESS, acls); ++#endif +#else rc = set_posix_acl(user_ns, inode, ACL_TYPE_ACCESS, acls); +#endif @@ -20092,8 +22409,13 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 if (S_ISDIR(inode->i_mode)) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 2, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ rc = set_posix_acl(idmap, dentry, ACL_TYPE_DEFAULT, ++ acls); ++#else + rc = set_posix_acl(user_ns, dentry, ACL_TYPE_DEFAULT, + acls); ++#endif +#else rc = set_posix_acl(user_ns, inode, ACL_TYPE_DEFAULT, acls); @@ -20105,7 +22427,7 @@ index 94b8ed4ef870..2fc7c6ac112f 100644 ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_DEFAULT) failed, rc : %d\n", rc); diff --git a/fs/ksmbd/vfs.h b/fs/ksmbd/vfs.h -index 593059ca8511..24f483ad4c6a 100644 +index 593059ca8511..d5fefbcecfaa 100644 --- a/fs/ksmbd/vfs.h +++ b/fs/ksmbd/vfs.h @@ -26,9 +26,48 @@ enum { @@ -20167,7 +22489,7 @@ index 593059ca8511..24f483ad4c6a 100644 char *wptr; char *rptr; int name_len; -@@ -71,6 +113,18 @@ struct ksmbd_kstat { +@@ -71,11 +113,31 @@ struct ksmbd_kstat { __le32 file_attributes; }; @@ -20183,10 +22505,23 @@ index 593059ca8511..24f483ad4c6a 100644 +} +#endif + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_lock_parent(struct mnt_idmap *idmap, struct dentry *parent, ++ struct dentry *child); ++int ksmbd_vfs_may_delete(struct mnt_idmap *idmap, struct dentry *dentry); ++int ksmbd_vfs_query_maximal_access(struct mnt_idmap *idmap, ++ struct dentry *dentry, __le32 *daccess); ++#else int ksmbd_vfs_lock_parent(struct user_namespace *user_ns, struct dentry *parent, struct dentry *child); int ksmbd_vfs_may_delete(struct user_namespace *user_ns, struct dentry *dentry); -@@ -88,6 +142,18 @@ int ksmbd_vfs_remove_file(struct ksmbd_work *work, char *name); + int ksmbd_vfs_query_maximal_access(struct user_namespace *user_ns, + struct dentry *dentry, __le32 *daccess); ++#endif + int ksmbd_vfs_create(struct ksmbd_work *work, const char *name, umode_t mode); + int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode); + int ksmbd_vfs_read(struct ksmbd_work *work, struct ksmbd_file *fp, +@@ -88,6 +150,18 @@ int ksmbd_vfs_remove_file(struct ksmbd_work *work, char *name); int ksmbd_vfs_link(struct ksmbd_work *work, const char *oldname, const char *newname); int ksmbd_vfs_getattr(const struct path *path, struct kstat *stat); @@ -20205,7 +22540,7 @@ index 593059ca8511..24f483ad4c6a 100644 int ksmbd_vfs_fp_rename(struct ksmbd_work *work, struct ksmbd_file *fp, char *newname); int ksmbd_vfs_truncate(struct ksmbd_work *work, -@@ -101,6 +167,9 @@ int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work, +@@ -101,20 +175,46 @@ int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work, unsigned int *chunk_count_written, unsigned int *chunk_size_written, loff_t *total_size_written); @@ -20213,11 +22548,26 @@ index 593059ca8511..24f483ad4c6a 100644 + const struct path *path, int flags, + __le32 option, int fexist); ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ssize_t ksmbd_vfs_getxattr(struct mnt_idmap *idmap, ++#else ssize_t ksmbd_vfs_getxattr(struct user_namespace *user_ns, ++#endif struct dentry *dentry, -@@ -111,7 +180,14 @@ ssize_t ksmbd_vfs_casexattr_len(struct user_namespace *user_ns, + char *xattr_name, + char **xattr_buf); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ssize_t ksmbd_vfs_casexattr_len(struct mnt_idmap *idmap, ++#else + ssize_t ksmbd_vfs_casexattr_len(struct user_namespace *user_ns, ++#endif + struct dentry *dentry, char *attr_name, int attr_name_len); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_setxattr(struct mnt_idmap *idmap, ++#else int ksmbd_vfs_setxattr(struct user_namespace *user_ns, ++#endif struct dentry *dentry, const char *attr_name, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0) void *attr_value, size_t attr_size, int flags); @@ -20229,10 +22579,91 @@ index 593059ca8511..24f483ad4c6a 100644 + size_t attr_size, int flags); int ksmbd_vfs_xattr_stream_name(char *stream_name, char **xattr_stream_name, size_t *xattr_stream_name_size, int s_type); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_remove_xattr(struct mnt_idmap *idmap, ++#else int ksmbd_vfs_remove_xattr(struct user_namespace *user_ns, -@@ -160,8 +236,8 @@ int ksmbd_vfs_get_dos_attrib_xattr(struct user_namespace *user_ns, ++#endif + struct dentry *dentry, char *attr_name); + int ksmbd_vfs_kern_path(struct ksmbd_work *work, + char *name, unsigned int flags, struct path *path, +@@ -131,37 +231,83 @@ struct file_allocated_range_buffer; + int ksmbd_vfs_fqar_lseek(struct ksmbd_file *fp, loff_t start, loff_t length, + struct file_allocated_range_buffer *ranges, + unsigned int in_count, unsigned int *out_count); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_unlink(struct mnt_idmap *idmap, struct dentry *dir, ++ struct dentry *dentry); ++#else + int ksmbd_vfs_unlink(struct user_namespace *user_ns, + struct dentry *dir, struct dentry *dentry); ++#endif + void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work, ++ struct mnt_idmap *idmap, ++ struct dentry *dentry, ++ struct ksmbd_kstat *ksmbd_kstat); ++#else + int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work, + struct user_namespace *user_ns, + struct dentry *dentry, + struct ksmbd_kstat *ksmbd_kstat); ++#endif + void ksmbd_vfs_posix_lock_wait(struct file_lock *flock); + int ksmbd_vfs_posix_lock_wait_timeout(struct file_lock *flock, long timeout); + void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_remove_acl_xattrs(struct mnt_idmap *idmap, ++ struct dentry *dentry); ++#else + int ksmbd_vfs_remove_acl_xattrs(struct user_namespace *user_ns, + struct dentry *dentry); ++#endif ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_remove_sd_xattrs(struct mnt_idmap *idmap, ++#else + int ksmbd_vfs_remove_sd_xattrs(struct user_namespace *user_ns, ++#endif + struct dentry *dentry); + int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap, ++#else + struct user_namespace *user_ns, ++#endif + struct dentry *dentry, + struct smb_ntsd *pntsd, int len); + int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ struct mnt_idmap *idmap, ++#else + struct user_namespace *user_ns, ++#endif + struct dentry *dentry, + struct smb_ntsd **pntsd); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_set_dos_attrib_xattr(struct mnt_idmap *idmap, ++ struct dentry *dentry, ++ struct xattr_dos_attrib *da); ++int ksmbd_vfs_get_dos_attrib_xattr(struct mnt_idmap *idmap, ++ struct dentry *dentry, ++ struct xattr_dos_attrib *da); ++#else + int ksmbd_vfs_set_dos_attrib_xattr(struct user_namespace *user_ns, struct dentry *dentry, struct xattr_dos_attrib *da); + int ksmbd_vfs_get_dos_attrib_xattr(struct user_namespace *user_ns, + struct dentry *dentry, + struct xattr_dos_attrib *da); ++#endif ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap, ++ struct dentry *dentry); ++int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap, ++ struct dentry *dentry, ++ struct inode *parent_inode); ++#else int ksmbd_vfs_set_init_posix_acl(struct user_namespace *user_ns, - struct inode *inode); + struct dentry *dentry); @@ -20240,9 +22671,10 @@ index 593059ca8511..24f483ad4c6a 100644 - struct inode *inode, + struct dentry *dentry, struct inode *parent_inode); ++#endif #endif /* __KSMBD_VFS_H__ */ diff --git a/fs/ksmbd/vfs_cache.c b/fs/ksmbd/vfs_cache.c -index da9163b00350..fab9736f5893 100644 +index 0ae5dd0829e9..ce0f20bcad67 100644 --- a/fs/ksmbd/vfs_cache.c +++ b/fs/ksmbd/vfs_cache.c @@ -5,6 +5,10 @@ @@ -20256,7 +22688,31 @@ index da9163b00350..fab9736f5893 100644 #include <linux/slab.h> #include <linux/vmalloc.h> -@@ -327,7 +331,9 @@ static void __ksmbd_close_fd(struct ksmbd_file_table *ft, struct ksmbd_file *fp) +@@ -251,7 +255,11 @@ static void __ksmbd_inode_close(struct ksmbd_file *fp) + filp = fp->filp; + if (ksmbd_stream_fd(fp) && (ci->m_flags & S_DEL_ON_CLS_STREAM)) { + ci->m_flags &= ~S_DEL_ON_CLS_STREAM; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ err = ksmbd_vfs_remove_xattr(file_mnt_idmap(filp), ++#else + err = ksmbd_vfs_remove_xattr(file_mnt_user_ns(filp), ++#endif + filp->f_path.dentry, + fp->stream.name); + if (err) +@@ -266,7 +274,11 @@ static void __ksmbd_inode_close(struct ksmbd_file *fp) + dir = dentry->d_parent; + ci->m_flags &= ~(S_DEL_ON_CLS | S_DEL_PENDING); + write_unlock(&ci->m_lock); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) ++ ksmbd_vfs_unlink(file_mnt_idmap(filp), dir, dentry); ++#else + ksmbd_vfs_unlink(file_mnt_user_ns(filp), dir, dentry); ++#endif + write_lock(&ci->m_lock); + } + write_unlock(&ci->m_lock); +@@ -327,7 +339,9 @@ static void __ksmbd_close_fd(struct ksmbd_file_table *ft, struct ksmbd_file *fp) locks_free_lock(smb_lock->fl); kfree(smb_lock); } @@ -20267,22 +22723,7 @@ index da9163b00350..fab9736f5893 100644 if (ksmbd_stream_fd(fp)) kfree(fp->stream.name); kmem_cache_free(filp_cache, fp); -@@ -364,12 +370,11 @@ static void __put_fd_final(struct ksmbd_work *work, struct ksmbd_file *fp) - - static void set_close_state_blocked_works(struct ksmbd_file *fp) - { -- struct ksmbd_work *cancel_work, *ctmp; -+ struct ksmbd_work *cancel_work; - - spin_lock(&fp->f_lock); -- list_for_each_entry_safe(cancel_work, ctmp, &fp->blocked_works, -+ list_for_each_entry(cancel_work, &fp->blocked_works, - fp_entry) { -- list_del(&cancel_work->fp_entry); - cancel_work->state = KSMBD_WORK_CLOSED; - cancel_work->cancel_fn(cancel_work->cancel_argv); - } -@@ -483,6 +488,36 @@ struct ksmbd_file *ksmbd_lookup_fd_cguid(char *cguid) +@@ -482,6 +496,36 @@ struct ksmbd_file *ksmbd_lookup_fd_cguid(char *cguid) return fp; } @@ -20319,7 +22760,7 @@ index da9163b00350..fab9736f5893 100644 struct ksmbd_file *ksmbd_lookup_fd_inode(struct inode *inode) { struct ksmbd_file *lfp; -@@ -530,7 +565,13 @@ static int __open_id(struct ksmbd_file_table *ft, struct ksmbd_file *fp, +@@ -529,7 +573,13 @@ static int __open_id(struct ksmbd_file_table *ft, struct ksmbd_file *fp, idr_preload(GFP_KERNEL); write_lock(&ft->lock); @@ -20333,7 +22774,7 @@ index da9163b00350..fab9736f5893 100644 if (ret >= 0) { id = ret; ret = 0; -@@ -666,6 +707,22 @@ void ksmbd_free_global_file_table(void) +@@ -665,6 +715,22 @@ void ksmbd_free_global_file_table(void) ksmbd_destroy_file_table(&global_ft); } diff --git a/patches/external/rt/0001-merge-CONFIG_PREEMPT_RT-Patch-Set.patch b/patches/external/rt/0001-merge-CONFIG_PREEMPT_RT-Patch-Set.patch index 0c97d1bfac0001f552262940e96eda8773eeb165..b9df4c7ddb765bc9b6fb63362e28ae680f397129 100644 --- a/patches/external/rt/0001-merge-CONFIG_PREEMPT_RT-Patch-Set.patch +++ b/patches/external/rt/0001-merge-CONFIG_PREEMPT_RT-Patch-Set.patch @@ -1,9 +1,9 @@ -From dc13f688b9e10e67cf4bcdfc3748fa2af74a8f4f Mon Sep 17 00:00:00 2001 +From 222b94a64043b238f6f26f0496954fe09c96705d Mon Sep 17 00:00:00 2001 From: Robert Nelson <robertcnelson@gmail.com> -Date: Wed, 3 May 2023 15:58:47 -0500 +Date: Wed, 17 May 2023 16:56:03 -0500 Subject: [PATCH] merge: CONFIG_PREEMPT_RT Patch Set -patch-6.1.12-rt7.patch.xz +patch-6.1.26-rt8.patch.xz Signed-off-by: Robert Nelson <robertcnelson@gmail.com> --- @@ -136,7 +136,7 @@ Signed-off-by: Robert Nelson <robertcnelson@gmail.com> kernel/entry/common.c | 4 +- kernel/hung_task.c | 11 +- kernel/ksysfs.c | 12 + - kernel/panic.c | 12 +- + kernel/panic.c | 10 +- kernel/printk/internal.h | 2 + kernel/printk/printk.c | 890 ++++++++++++++++-- kernel/printk/printk_safe.c | 32 + @@ -174,7 +174,7 @@ Signed-off-by: Robert Nelson <robertcnelson@gmail.com> net/netfilter/nf_tables_api.c | 4 +- net/openvswitch/datapath.c | 4 +- net/openvswitch/flow_table.c | 9 +- - 167 files changed, 2307 insertions(+), 605 deletions(-) + 167 files changed, 2305 insertions(+), 605 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index a08c9d092a33..4ce79eb994a6 100644 @@ -336,7 +336,7 @@ index de988cba9a4b..87efbfbf3c16 100644 return 0; } diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig -index 505c8a1ccbe0..6c01b2b970c7 100644 +index 43ff7c7a3ac9..21d8d76b0105 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -93,6 +93,7 @@ config ARM64 @@ -347,7 +347,7 @@ index 505c8a1ccbe0..6c01b2b970c7 100644 select ARCH_WANT_COMPAT_IPC_PARSE_VERSION if COMPAT select ARCH_WANT_DEFAULT_BPF_JIT select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT -@@ -200,6 +201,7 @@ config ARM64 +@@ -199,6 +200,7 @@ config ARM64 select HAVE_PERF_USER_STACK_DUMP select HAVE_PREEMPT_DYNAMIC_KEY select HAVE_REGS_AND_STACK_ACCESS_API @@ -464,7 +464,7 @@ index 43adbfa5ead7..bd3f2f4603ac 100644 local_daif_restore(DAIF_PROCCTX_NOIRQ); diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig -index 2ca5418457ed..d8a89c5f8f45 100644 +index 2b1141645d9e..d688aff0828a 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -151,6 +151,7 @@ config PPC @@ -475,7 +475,7 @@ index 2ca5418457ed..d8a89c5f8f45 100644 select ARCH_USE_BUILTIN_BSWAP select ARCH_USE_CMPXCHG_LOCKREF if PPC64 select ARCH_USE_MEMTEST -@@ -243,8 +244,10 @@ config PPC +@@ -242,8 +243,10 @@ config PPC select HAVE_PERF_EVENTS_NMI if PPC64 select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP @@ -958,7 +958,7 @@ index ed5dabd3c72d..5d778ea926f3 100644 } diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig -index 3efce05d7b57..392d51703096 100644 +index 3a6e176d77aa..43b8bf809962 100644 --- a/drivers/gpu/drm/i915/Kconfig +++ b/drivers/gpu/drm/i915/Kconfig @@ -3,7 +3,6 @@ config DRM_I915 @@ -1037,7 +1037,7 @@ index ecc990ec1b95..8d04b10681f0 100644 } diff --git a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c -index bfd1ffc71a48..f2e5f0af61fc 100644 +index fc4a84628985..fc937697fe14 100644 --- a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c +++ b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c @@ -1302,7 +1302,7 @@ static void execlists_dequeue(struct intel_engine_cs *engine) @@ -1090,7 +1090,7 @@ index bfd1ffc71a48..f2e5f0af61fc 100644 static void clear_ports(struct i915_request **ports, int count) { memset_p((void **)ports, NULL, count); -@@ -2468,7 +2461,7 @@ static void execlists_submission_tasklet(struct tasklet_struct *t) +@@ -2476,7 +2469,7 @@ static void execlists_submission_tasklet(struct tasklet_struct *t) } if (!engine->execlists.pending[0]) { @@ -1263,10 +1263,10 @@ index 5ce01ac72637..e8ad5ea31aff 100644 stats->rx_dropped = rx_drops; stats->tx_dropped = tx_drops; diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c -index 25129e723b57..1e8d902e1c8e 100644 +index 2dc8d215a591..7f933175cbda 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c -@@ -934,7 +934,7 @@ unsigned int aq_ring_fill_stats_data(struct aq_ring_s *self, u64 *data) +@@ -948,7 +948,7 @@ unsigned int aq_ring_fill_stats_data(struct aq_ring_s *self, u64 *data) /* This data should mimic aq_ethtool_queue_rx_stat_names structure */ do { count = 0; @@ -1275,7 +1275,7 @@ index 25129e723b57..1e8d902e1c8e 100644 data[count] = self->stats.rx.packets; data[++count] = self->stats.rx.jumbo_packets; data[++count] = self->stats.rx.lro_packets; -@@ -951,15 +951,15 @@ unsigned int aq_ring_fill_stats_data(struct aq_ring_s *self, u64 *data) +@@ -965,15 +965,15 @@ unsigned int aq_ring_fill_stats_data(struct aq_ring_s *self, u64 *data) data[++count] = self->stats.rx.xdp_tx; data[++count] = self->stats.rx.xdp_invalid; data[++count] = self->stats.rx.xdp_redirect; @@ -1594,7 +1594,7 @@ index 671f51135c26..53b7e95213a8 100644 #define FUN_INT_NAME_LEN (IFNAMSIZ + 16) diff --git a/drivers/net/ethernet/google/gve/gve_ethtool.c b/drivers/net/ethernet/google/gve/gve_ethtool.c -index 7b9a2d9d9624..50b384910c83 100644 +index 38df602f2869..274891a18ae5 100644 --- a/drivers/net/ethernet/google/gve/gve_ethtool.c +++ b/drivers/net/ethernet/google/gve/gve_ethtool.c @@ -177,14 +177,14 @@ gve_get_ethtool_stats(struct net_device *netdev, @@ -1825,7 +1825,7 @@ index f6fa63e4253c..1465ed7a6166 100644 /* Once we successfully copy the stats in, update the data pointer */ *data += size; diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c -index e6e349f0c945..f9f1f082b42b 100644 +index 68f390ce4f6e..6492d87107e1 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -419,10 +419,10 @@ static void i40e_get_netdev_stats_struct_tx(struct i40e_ring *ring, @@ -1925,10 +1925,10 @@ index 83cfc54a4706..6f171d1d85b7 100644 /* Once we successfully copy the stats in, update the data pointer */ *data += size; diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c -index 333582dabba1..a641a6619d51 100644 +index cfc57cfc46e4..14560e166ffe 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c -@@ -6371,10 +6371,10 @@ ice_fetch_u64_stats_per_ring(struct u64_stats_sync *syncp, +@@ -6393,10 +6393,10 @@ ice_fetch_u64_stats_per_ring(struct u64_stats_sync *syncp, unsigned int start; do { @@ -1982,10 +1982,10 @@ index ff911af16a4b..7d60da1b7bf4 100644 } spin_unlock(&adapter->stats64_lock); diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c -index 24a6ae19ad8e..a4598680d799 100644 +index b3aed4e2ca91..c25ddcdc3150 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c -@@ -6636,10 +6636,10 @@ void igb_update_stats(struct igb_adapter *adapter) +@@ -6656,10 +6656,10 @@ void igb_update_stats(struct igb_adapter *adapter) } do { @@ -1998,7 +1998,7 @@ index 24a6ae19ad8e..a4598680d799 100644 bytes += _bytes; packets += _packets; } -@@ -6652,10 +6652,10 @@ void igb_update_stats(struct igb_adapter *adapter) +@@ -6672,10 +6672,10 @@ void igb_update_stats(struct igb_adapter *adapter) for (i = 0; i < adapter->num_tx_queues; i++) { struct igb_ring *ring = adapter->tx_ring[i]; do { @@ -2052,7 +2052,7 @@ index 8cc077b712ad..5a26a7805ef8 100644 } spin_unlock(&adapter->stats64_lock); diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c -index 3b5b36206c44..fba30f5b24cf 100644 +index 1d9b70e0ff67..56d611fbeee8 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -4802,10 +4802,10 @@ void igc_update_stats(struct igc_adapter *adapter) @@ -2112,10 +2112,10 @@ index e88e3dfac8c2..eda7188e8df4 100644 } diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c -index 298cfbfcb7b6..ab8370c413f3 100644 +index faf3a094ac54..4507fba8747a 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c -@@ -9041,10 +9041,10 @@ static void ixgbe_get_ring_stats64(struct rtnl_link_stats64 *stats, +@@ -9047,10 +9047,10 @@ static void ixgbe_get_ring_stats64(struct rtnl_link_stats64 *stats, if (ring) { do { @@ -2128,7 +2128,7 @@ index 298cfbfcb7b6..ab8370c413f3 100644 stats->tx_packets += packets; stats->tx_bytes += bytes; } -@@ -9064,10 +9064,10 @@ static void ixgbe_get_stats64(struct net_device *netdev, +@@ -9070,10 +9070,10 @@ static void ixgbe_get_stats64(struct net_device *netdev, if (ring) { do { @@ -2319,10 +2319,10 @@ index ab33ba1c3023..ff97b140886a 100644 stats->tx_packets = _packets; stats->tx_bytes = _bytes; diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -index 53ee9dea6638..b5d1d9b33b75 100644 +index 49975924e242..7d6257fbc772 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -865,7 +865,7 @@ static void mtk_get_stats64(struct net_device *dev, +@@ -866,7 +866,7 @@ static void mtk_get_stats64(struct net_device *dev, } do { @@ -2331,7 +2331,7 @@ index 53ee9dea6638..b5d1d9b33b75 100644 storage->rx_packets = hw_stats->rx_packets; storage->tx_packets = hw_stats->tx_packets; storage->rx_bytes = hw_stats->rx_bytes; -@@ -877,7 +877,7 @@ static void mtk_get_stats64(struct net_device *dev, +@@ -878,7 +878,7 @@ static void mtk_get_stats64(struct net_device *dev, storage->rx_crc_errors = hw_stats->rx_fcs_errors; storage->rx_errors = hw_stats->rx_checksum_errors; storage->tx_aborted_errors = hw_stats->tx_skip; @@ -2340,7 +2340,7 @@ index 53ee9dea6638..b5d1d9b33b75 100644 storage->tx_errors = dev->stats.tx_errors; storage->rx_dropped = dev->stats.rx_dropped; -@@ -3707,13 +3707,13 @@ static void mtk_get_ethtool_stats(struct net_device *dev, +@@ -3708,13 +3708,13 @@ static void mtk_get_ethtool_stats(struct net_device *dev, do { data_dst = data; @@ -2357,7 +2357,7 @@ index 53ee9dea6638..b5d1d9b33b75 100644 static int mtk_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c -index 5bcf5bceff71..6ed496f6cbfb 100644 +index 67ecdb9e708f..8345499563a4 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -827,12 +827,12 @@ mlxsw_sp_port_get_sw_stats64(const struct net_device *dev, @@ -2470,10 +2470,10 @@ index 27f4786ace4f..a5ca5c4a7896 100644 stats->tx_bytes += data[1]; stats->tx_errors += data[2]; diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c -index 991059d6cb32..e82ddb0677aa 100644 +index af376b900067..cc97b3d00414 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c -@@ -686,7 +686,7 @@ static u64 *nfp_vnic_get_sw_stats(struct net_device *netdev, u64 *data) +@@ -881,7 +881,7 @@ static u64 *nfp_vnic_get_sw_stats(struct net_device *netdev, u64 *data) unsigned int start; do { @@ -2482,7 +2482,7 @@ index 991059d6cb32..e82ddb0677aa 100644 data[0] = nn->r_vecs[i].rx_pkts; tmp[0] = nn->r_vecs[i].hw_csum_rx_ok; tmp[1] = nn->r_vecs[i].hw_csum_rx_inner_ok; -@@ -694,10 +694,10 @@ static u64 *nfp_vnic_get_sw_stats(struct net_device *netdev, u64 *data) +@@ -889,10 +889,10 @@ static u64 *nfp_vnic_get_sw_stats(struct net_device *netdev, u64 *data) tmp[3] = nn->r_vecs[i].hw_csum_rx_error; tmp[4] = nn->r_vecs[i].rx_replace_buf_alloc_fail; tmp[5] = nn->r_vecs[i].hw_tls_rx; @@ -2495,7 +2495,7 @@ index 991059d6cb32..e82ddb0677aa 100644 data[1] = nn->r_vecs[i].tx_pkts; data[2] = nn->r_vecs[i].tx_busy; tmp[6] = nn->r_vecs[i].hw_csum_tx; -@@ -707,7 +707,7 @@ static u64 *nfp_vnic_get_sw_stats(struct net_device *netdev, u64 *data) +@@ -902,7 +902,7 @@ static u64 *nfp_vnic_get_sw_stats(struct net_device *netdev, u64 *data) tmp[10] = nn->r_vecs[i].hw_tls_tx; tmp[11] = nn->r_vecs[i].tls_tx_fallback; tmp[12] = nn->r_vecs[i].tls_tx_no_fallback; @@ -2624,10 +2624,10 @@ index d2c6a5dfdc0e..b7e24ae92525 100644 stats->rx_errors = priv->stats_rx.errors; stats->tx_errors = priv->stats_tx.errors; diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c -index 4ff1cfdb9730..f67dd7b28bd0 100644 +index d6683c0e34b5..8162f10778ae 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c -@@ -1366,12 +1366,12 @@ static void am65_cpsw_nuss_ndo_get_stats(struct net_device *dev, +@@ -1400,12 +1400,12 @@ static void am65_cpsw_nuss_ndo_get_stats(struct net_device *dev, cpu_stats = per_cpu_ptr(ndev_priv->stats, cpu); do { @@ -3052,7 +3052,7 @@ index b095a4b4957b..18d99fda997c 100644 } diff --git a/drivers/net/veth.c b/drivers/net/veth.c -index bd385ccd0d18..0f81ca77d04c 100644 +index a71786b3e7ba..9d42a8c6aab7 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -182,12 +182,12 @@ static void veth_get_ethtool_stats(struct net_device *dev, @@ -3102,10 +3102,10 @@ index bd385ccd0d18..0f81ca77d04c 100644 result->xdp_tx_err += xdp_tx_err; result->xdp_packets += packets; diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c -index 20b1b34a092a..1da9b7be4a4c 100644 +index 3f1883814ce2..c9cf5be14bd8 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c -@@ -2071,18 +2071,18 @@ static void virtnet_stats(struct net_device *dev, +@@ -2075,18 +2075,18 @@ static void virtnet_stats(struct net_device *dev, struct send_queue *sq = &vi->sq[i]; do { @@ -3128,7 +3128,7 @@ index 20b1b34a092a..1da9b7be4a4c 100644 tot->rx_packets += rpackets; tot->tx_packets += tpackets; -@@ -2693,12 +2693,12 @@ static void virtnet_get_ethtool_stats(struct net_device *dev, +@@ -2697,12 +2697,12 @@ static void virtnet_get_ethtool_stats(struct net_device *dev, stats_base = (u8 *)&rq->stats; do { @@ -3143,7 +3143,7 @@ index 20b1b34a092a..1da9b7be4a4c 100644 idx += VIRTNET_RQ_STATS_LEN; } -@@ -2707,12 +2707,12 @@ static void virtnet_get_ethtool_stats(struct net_device *dev, +@@ -2711,12 +2711,12 @@ static void virtnet_get_ethtool_stats(struct net_device *dev, stats_base = (u8 *)&sq->stats; do { @@ -3517,7 +3517,7 @@ index 64770c62bbec..c756c30c70c3 100644 return serial8250_do_startup(port); } diff --git a/drivers/tty/serial/8250/8250_fsl.c b/drivers/tty/serial/8250/8250_fsl.c -index 8aad15622a2e..74bb85b705e7 100644 +index 8adfaa183f77..eaf148245a10 100644 --- a/drivers/tty/serial/8250/8250_fsl.c +++ b/drivers/tty/serial/8250/8250_fsl.c @@ -58,7 +58,8 @@ int fsl8250_handle_irq(struct uart_port *port) @@ -3690,7 +3690,7 @@ index 3f33014022f0..594378d3c065 100644 } diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c -index 388172289627..8dab3b7ab3c9 100644 +index 2a3bd6918c77..02323b500f40 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -743,7 +743,7 @@ static void serial8250_set_sleep(struct uart_8250_port *p, int sleep) @@ -3876,7 +3876,7 @@ index 388172289627..8dab3b7ab3c9 100644 serial8250_rpm_put(up); } -@@ -2155,8 +2202,7 @@ static void serial8250_put_poll_char(struct uart_port *port, +@@ -2166,8 +2213,7 @@ static void serial8250_put_poll_char(struct uart_port *port, /* * First save the IER then disable the interrupts */ @@ -3886,7 +3886,7 @@ index 388172289627..8dab3b7ab3c9 100644 wait_for_xmitr(up, UART_LSR_BOTH_EMPTY); /* -@@ -2169,7 +2215,7 @@ static void serial8250_put_poll_char(struct uart_port *port, +@@ -2180,7 +2226,7 @@ static void serial8250_put_poll_char(struct uart_port *port, * and restore the IER */ wait_for_xmitr(up, UART_LSR_BOTH_EMPTY); @@ -3895,7 +3895,7 @@ index 388172289627..8dab3b7ab3c9 100644 serial8250_rpm_put(up); } -@@ -2178,8 +2224,10 @@ static void serial8250_put_poll_char(struct uart_port *port, +@@ -2189,8 +2235,10 @@ static void serial8250_put_poll_char(struct uart_port *port, int serial8250_do_startup(struct uart_port *port) { struct uart_8250_port *up = up_to_u8250p(port); @@ -3906,7 +3906,7 @@ index 388172289627..8dab3b7ab3c9 100644 int retval; u16 lsr; -@@ -2200,7 +2248,7 @@ int serial8250_do_startup(struct uart_port *port) +@@ -2211,7 +2259,7 @@ int serial8250_do_startup(struct uart_port *port) up->acr = 0; serial_port_out(port, UART_LCR, UART_LCR_CONF_MODE_B); serial_port_out(port, UART_EFR, UART_EFR_ECB); @@ -3915,7 +3915,7 @@ index 388172289627..8dab3b7ab3c9 100644 serial_port_out(port, UART_LCR, 0); serial_icr_write(up, UART_CSR, 0); /* Reset the UART */ serial_port_out(port, UART_LCR, UART_LCR_CONF_MODE_B); -@@ -2210,7 +2258,7 @@ int serial8250_do_startup(struct uart_port *port) +@@ -2221,7 +2269,7 @@ int serial8250_do_startup(struct uart_port *port) if (port->type == PORT_DA830) { /* Reset the port */ @@ -3924,7 +3924,7 @@ index 388172289627..8dab3b7ab3c9 100644 serial_port_out(port, UART_DA830_PWREMU_MGMT, 0); mdelay(10); -@@ -2309,6 +2357,8 @@ int serial8250_do_startup(struct uart_port *port) +@@ -2320,6 +2368,8 @@ int serial8250_do_startup(struct uart_port *port) if (retval) goto out; @@ -3933,7 +3933,7 @@ index 388172289627..8dab3b7ab3c9 100644 if (port->irq && !(up->port.flags & UPF_NO_THRE_TEST)) { unsigned char iir1; -@@ -2325,6 +2375,9 @@ int serial8250_do_startup(struct uart_port *port) +@@ -2336,6 +2386,9 @@ int serial8250_do_startup(struct uart_port *port) */ spin_lock_irqsave(&port->lock, flags); @@ -3943,7 +3943,7 @@ index 388172289627..8dab3b7ab3c9 100644 wait_for_xmitr(up, UART_LSR_THRE); serial_port_out_sync(port, UART_IER, UART_IER_THRI); udelay(1); /* allow THRE to set */ -@@ -2335,6 +2388,9 @@ int serial8250_do_startup(struct uart_port *port) +@@ -2346,6 +2399,9 @@ int serial8250_do_startup(struct uart_port *port) iir = serial_port_in(port, UART_IIR); serial_port_out(port, UART_IER, 0); @@ -3953,7 +3953,7 @@ index 388172289627..8dab3b7ab3c9 100644 spin_unlock_irqrestore(&port->lock, flags); if (port->irqflags & IRQF_SHARED) -@@ -2389,10 +2445,14 @@ int serial8250_do_startup(struct uart_port *port) +@@ -2400,10 +2456,14 @@ int serial8250_do_startup(struct uart_port *port) * Do a quick test to see if we receive an interrupt when we enable * the TX irq. */ @@ -3968,7 +3968,7 @@ index 388172289627..8dab3b7ab3c9 100644 if (lsr & UART_LSR_TEMT && iir & UART_IIR_NO_INT) { if (!(up->bugs & UART_BUG_TXEN)) { -@@ -2424,7 +2484,7 @@ int serial8250_do_startup(struct uart_port *port) +@@ -2435,7 +2495,7 @@ int serial8250_do_startup(struct uart_port *port) if (up->dma) { const char *msg = NULL; @@ -3977,7 +3977,7 @@ index 388172289627..8dab3b7ab3c9 100644 msg = "forbid DMA for kernel console"; else if (serial8250_request_dma(up)) msg = "failed to request DMA"; -@@ -2475,7 +2535,7 @@ void serial8250_do_shutdown(struct uart_port *port) +@@ -2486,7 +2546,7 @@ void serial8250_do_shutdown(struct uart_port *port) */ spin_lock_irqsave(&port->lock, flags); up->ier = 0; @@ -3986,7 +3986,7 @@ index 388172289627..8dab3b7ab3c9 100644 spin_unlock_irqrestore(&port->lock, flags); synchronize_irq(port->irq); -@@ -2841,7 +2901,7 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, +@@ -2852,7 +2912,7 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, if (up->capabilities & UART_CAP_RTOIE) up->ier |= UART_IER_RTOIE; @@ -3995,7 +3995,7 @@ index 388172289627..8dab3b7ab3c9 100644 if (up->capabilities & UART_CAP_EFR) { unsigned char efr = 0; -@@ -3306,7 +3366,7 @@ EXPORT_SYMBOL_GPL(serial8250_set_defaults); +@@ -3317,7 +3377,7 @@ EXPORT_SYMBOL_GPL(serial8250_set_defaults); #ifdef CONFIG_SERIAL_8250_CONSOLE @@ -4004,7 +4004,7 @@ index 388172289627..8dab3b7ab3c9 100644 { struct uart_8250_port *up = up_to_u8250p(port); -@@ -3314,6 +3374,18 @@ static void serial8250_console_putchar(struct uart_port *port, unsigned char ch) +@@ -3325,6 +3385,18 @@ static void serial8250_console_putchar(struct uart_port *port, unsigned char ch) serial_port_out(port, UART_TX, ch); } @@ -4023,7 +4023,7 @@ index 388172289627..8dab3b7ab3c9 100644 /* * Restore serial console when h/w power-off detected */ -@@ -3340,6 +3412,32 @@ static void serial8250_console_restore(struct uart_8250_port *up) +@@ -3351,6 +3423,32 @@ static void serial8250_console_restore(struct uart_8250_port *up) serial8250_out_MCR(up, up->mcr | UART_MCR_DTR | UART_MCR_RTS); } @@ -4056,7 +4056,7 @@ index 388172289627..8dab3b7ab3c9 100644 /* * Print a string to the serial port using the device FIFO * -@@ -3385,20 +3483,15 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s, +@@ -3396,20 +3494,15 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s, struct uart_port *port = &up->port; unsigned long flags; unsigned int ier, use_fifo; @@ -4079,7 +4079,7 @@ index 388172289627..8dab3b7ab3c9 100644 /* check scratch reg to see if port powered off during system sleep */ if (up->canary && (up->canary != serial_port_in(port, UART_SCR))) { -@@ -3432,10 +3525,12 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s, +@@ -3443,10 +3536,12 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s, */ !(up->port.flags & UPF_CONS_FLOW); @@ -4092,7 +4092,7 @@ index 388172289627..8dab3b7ab3c9 100644 /* * Finally, wait for transmitter to become empty -@@ -3448,8 +3543,7 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s, +@@ -3459,8 +3554,7 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s, if (em485->tx_stopped) up->rs485_stop_tx(up); } @@ -4102,7 +4102,7 @@ index 388172289627..8dab3b7ab3c9 100644 /* * The receive handling will happen properly because the -@@ -3461,8 +3555,7 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s, +@@ -3472,8 +3566,7 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s, if (up->msr_saved_flags) serial8250_modem_status(up); @@ -4112,7 +4112,7 @@ index 388172289627..8dab3b7ab3c9 100644 } static unsigned int probe_baud(struct uart_port *port) -@@ -3482,6 +3575,7 @@ static unsigned int probe_baud(struct uart_port *port) +@@ -3493,6 +3586,7 @@ static unsigned int probe_baud(struct uart_port *port) int serial8250_console_setup(struct uart_port *port, char *options, bool probe) { @@ -4120,7 +4120,7 @@ index 388172289627..8dab3b7ab3c9 100644 int baud = 9600; int bits = 8; int parity = 'n'; -@@ -3491,6 +3585,8 @@ int serial8250_console_setup(struct uart_port *port, char *options, bool probe) +@@ -3502,6 +3596,8 @@ int serial8250_console_setup(struct uart_port *port, char *options, bool probe) if (!port->iobase && !port->membase) return -ENODEV; @@ -4130,7 +4130,7 @@ index 388172289627..8dab3b7ab3c9 100644 uart_parse_options(options, &baud, &parity, &bits, &flow); else if (probe) diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig -index b0f62345bc84..bdd5ed63a436 100644 +index 583a340f9934..1f31320820a6 100644 --- a/drivers/tty/serial/8250/Kconfig +++ b/drivers/tty/serial/8250/Kconfig @@ -9,6 +9,7 @@ config SERIAL_8250 @@ -4389,10 +4389,10 @@ index 81d10b8e9dc0..8de40ae43082 100644 * To initialize a lockdep_map statically use this macro. * Note that _name must not be NULL. diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h -index ba2bd604359d..e3d1bc2eb27a 100644 +index b072449b0f1a..5f818dc98ca3 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h -@@ -3163,7 +3163,11 @@ struct softnet_data { +@@ -3165,7 +3165,11 @@ struct softnet_data { int defer_count; int defer_ipi_scheduled; struct sk_buff *defer_list; @@ -4705,10 +4705,10 @@ index 46040d66334a..ffe48e69b3f3 100644 - #endif /* _LINUX_U64_STATS_SYNC_H */ diff --git a/init/Kconfig b/init/Kconfig -index 0c214af99085..ca70073fd5fb 100644 +index 2028ed4d50f5..6fd196cb9ef3 100644 --- a/init/Kconfig +++ b/init/Kconfig -@@ -1585,6 +1585,10 @@ config PRINTK +@@ -1581,6 +1581,10 @@ config PRINTK very difficult to diagnose system problems, saying N here is strongly discouraged. @@ -4754,7 +4754,7 @@ index 6c61dba26f4d..f07117a94bbb 100644 cnt += tcnt; misses += tmisses; diff --git a/kernel/entry/common.c b/kernel/entry/common.c -index 846add8394c4..51de1080cb93 100644 +index be61332c66b5..c6301e520d47 100644 --- a/kernel/entry/common.c +++ b/kernel/entry/common.c @@ -155,7 +155,7 @@ static unsigned long exit_to_user_mode_loop(struct pt_regs *regs, @@ -4766,7 +4766,7 @@ index 846add8394c4..51de1080cb93 100644 schedule(); if (ti_work & _TIF_UPROBE) -@@ -385,7 +385,7 @@ void raw_irqentry_exit_cond_resched(void) +@@ -386,7 +386,7 @@ void raw_irqentry_exit_cond_resched(void) rcu_irq_exit_check_preempt(); if (IS_ENABLED(CONFIG_DEBUG_ENTRY)) WARN_ON_ONCE(!on_thread_stack()); @@ -4847,10 +4847,10 @@ index 65dba9076f31..ab18048e2186 100644 NULL }; diff --git a/kernel/panic.c b/kernel/panic.c -index 7834c9854e02..9dd9fa490656 100644 +index ca5452afb456..fb23d6ed7a64 100644 --- a/kernel/panic.c +++ b/kernel/panic.c -@@ -300,7 +300,6 @@ void panic(const char *fmt, ...) +@@ -322,7 +322,6 @@ void panic(const char *fmt, ...) panic_smp_self_stop(); console_verbose(); @@ -4858,7 +4858,7 @@ index 7834c9854e02..9dd9fa490656 100644 va_start(args, fmt); len = vscnprintf(buf, sizeof(buf), fmt, args); va_end(args); -@@ -317,6 +316,11 @@ void panic(const char *fmt, ...) +@@ -339,6 +338,11 @@ void panic(const char *fmt, ...) dump_stack(); #endif @@ -4870,23 +4870,7 @@ index 7834c9854e02..9dd9fa490656 100644 /* * If kgdb is enabled, give it a chance to run before we stop all * the other CPUs or else we won't be able to debug processes left -@@ -340,6 +344,7 @@ void panic(const char *fmt, ...) - * unfortunately means it may not be hardened to work in a - * panic situation. - */ -+ try_block_console_kthreads(10000); - smp_send_stop(); - } else { - /* -@@ -347,6 +352,7 @@ void panic(const char *fmt, ...) - * kmsg_dump, we will need architecture dependent extra - * works in addition to stopping other CPUs. - */ -+ try_block_console_kthreads(10000); - crash_smp_send_stop(); - } - -@@ -644,6 +650,8 @@ void __warn(const char *file, int line, void *caller, unsigned taint, +@@ -653,6 +657,8 @@ void __warn(const char *file, int line, void *caller, unsigned taint, { disable_trace_on_warning(); @@ -4895,7 +4879,7 @@ index 7834c9854e02..9dd9fa490656 100644 if (file) pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS\n", raw_smp_processor_id(), current->pid, file, line, -@@ -672,6 +680,8 @@ void __warn(const char *file, int line, void *caller, unsigned taint, +@@ -681,6 +687,8 @@ void __warn(const char *file, int line, void *caller, unsigned taint, /* Just a warning, don't kill lockdep. */ add_taint(taint, LOCKDEP_STILL_OK); @@ -6327,7 +6311,7 @@ index 3bba88c7ffc6..57cedc330660 100644 EXPORT_SYMBOL_GPL(hw_protection_shutdown); diff --git a/kernel/sched/core.c b/kernel/sched/core.c -index f730b6fe94a7..16ed5d422be8 100644 +index b23dcbeacdf3..8989559d3d3c 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1040,6 +1040,46 @@ void resched_curr(struct rq *rq) @@ -6377,7 +6361,7 @@ index f730b6fe94a7..16ed5d422be8 100644 void resched_cpu(int cpu) { struct rq *rq = cpu_rq(cpu); -@@ -2221,6 +2261,7 @@ void migrate_disable(void) +@@ -2224,6 +2264,7 @@ void migrate_disable(void) preempt_disable(); this_rq()->nr_pinned++; p->migration_disabled = 1; @@ -6385,7 +6369,7 @@ index f730b6fe94a7..16ed5d422be8 100644 preempt_enable(); } EXPORT_SYMBOL_GPL(migrate_disable); -@@ -2252,6 +2293,7 @@ void migrate_enable(void) +@@ -2255,6 +2296,7 @@ void migrate_enable(void) barrier(); p->migration_disabled = 0; this_rq()->nr_pinned--; @@ -6393,7 +6377,7 @@ index f730b6fe94a7..16ed5d422be8 100644 preempt_enable(); } EXPORT_SYMBOL_GPL(migrate_enable); -@@ -3274,6 +3316,76 @@ int migrate_swap(struct task_struct *cur, struct task_struct *p, +@@ -3277,6 +3319,76 @@ int migrate_swap(struct task_struct *cur, struct task_struct *p, } #endif /* CONFIG_NUMA_BALANCING */ @@ -6470,7 +6454,7 @@ index f730b6fe94a7..16ed5d422be8 100644 /* * wait_task_inactive - wait for a thread to unschedule. * -@@ -3292,7 +3404,7 @@ int migrate_swap(struct task_struct *cur, struct task_struct *p, +@@ -3295,7 +3407,7 @@ int migrate_swap(struct task_struct *cur, struct task_struct *p, */ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state) { @@ -6479,7 +6463,7 @@ index f730b6fe94a7..16ed5d422be8 100644 struct rq_flags rf; unsigned long ncsw; struct rq *rq; -@@ -3318,7 +3430,7 @@ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state +@@ -3321,7 +3433,7 @@ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state * is actually now running somewhere else! */ while (task_on_cpu(rq, p)) { @@ -6488,7 +6472,7 @@ index f730b6fe94a7..16ed5d422be8 100644 return 0; cpu_relax(); } -@@ -3331,9 +3443,10 @@ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state +@@ -3334,9 +3446,10 @@ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state rq = task_rq_lock(p, &rf); trace_sched_wait_task(p); running = task_on_cpu(rq, p); @@ -6501,7 +6485,7 @@ index f730b6fe94a7..16ed5d422be8 100644 ncsw = p->nvcsw | LONG_MIN; /* sets MSB */ task_rq_unlock(rq, p, &rf); -@@ -3363,7 +3476,7 @@ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state +@@ -3366,7 +3479,7 @@ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state * running right now), it's preempted, and we should * yield - it could be a while. */ @@ -6510,7 +6494,7 @@ index f730b6fe94a7..16ed5d422be8 100644 ktime_t to = NSEC_PER_SEC / HZ; set_current_state(TASK_UNINTERRUPTIBLE); -@@ -4644,6 +4757,9 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p) +@@ -4647,6 +4760,9 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p) p->on_cpu = 0; #endif init_task_preempt_count(p); @@ -6520,7 +6504,7 @@ index f730b6fe94a7..16ed5d422be8 100644 #ifdef CONFIG_SMP plist_node_init(&p->pushable_tasks, MAX_PRIO); RB_CLEAR_NODE(&p->pushable_dl_tasks); -@@ -6514,6 +6630,7 @@ static void __sched notrace __schedule(unsigned int sched_mode) +@@ -6517,6 +6633,7 @@ static void __sched notrace __schedule(unsigned int sched_mode) next = pick_next_task(rq, prev, &rf); clear_tsk_need_resched(prev); @@ -6528,7 +6512,7 @@ index f730b6fe94a7..16ed5d422be8 100644 clear_preempt_need_resched(); #ifdef CONFIG_SCHED_DEBUG rq->last_seen_need_resched_ns = 0; -@@ -6728,6 +6845,30 @@ static void __sched notrace preempt_schedule_common(void) +@@ -6731,6 +6848,30 @@ static void __sched notrace preempt_schedule_common(void) } while (need_resched()); } @@ -6559,7 +6543,7 @@ index f730b6fe94a7..16ed5d422be8 100644 #ifdef CONFIG_PREEMPTION /* * This is the entry point to schedule() from in-kernel preemption -@@ -6741,6 +6882,8 @@ asmlinkage __visible void __sched notrace preempt_schedule(void) +@@ -6744,6 +6885,8 @@ asmlinkage __visible void __sched notrace preempt_schedule(void) */ if (likely(!preemptible())) return; @@ -6568,7 +6552,7 @@ index f730b6fe94a7..16ed5d422be8 100644 preempt_schedule_common(); } NOKPROBE_SYMBOL(preempt_schedule); -@@ -6788,6 +6931,9 @@ asmlinkage __visible void __sched notrace preempt_schedule_notrace(void) +@@ -6791,6 +6934,9 @@ asmlinkage __visible void __sched notrace preempt_schedule_notrace(void) if (likely(!preemptible())) return; @@ -6578,7 +6562,7 @@ index f730b6fe94a7..16ed5d422be8 100644 do { /* * Because the function tracer can trace preempt_count_sub() -@@ -9045,7 +9191,9 @@ void __init init_idle(struct task_struct *idle, int cpu) +@@ -9048,7 +9194,9 @@ void __init init_idle(struct task_struct *idle, int cpu) /* Set the preempt count _outside_ the spinlocks! */ init_idle_preempt_count(idle, cpu); @@ -6590,10 +6574,10 @@ index f730b6fe94a7..16ed5d422be8 100644 * The idle tasks have their own, simple scheduling class: */ diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c -index 2c3d0d49c80e..32fd5278d2b7 100644 +index f70c4a7fb4ef..2e2f24075556 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c -@@ -4883,7 +4883,7 @@ check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr) +@@ -4934,7 +4934,7 @@ check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr) ideal_runtime = sched_slice(cfs_rq, curr); delta_exec = curr->sum_exec_runtime - curr->prev_sum_exec_runtime; if (delta_exec > ideal_runtime) { @@ -6602,7 +6586,7 @@ index 2c3d0d49c80e..32fd5278d2b7 100644 /* * The current task ran long enough, ensure it doesn't get * re-elected due to buddy favours. -@@ -4907,7 +4907,7 @@ check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr) +@@ -4958,7 +4958,7 @@ check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr) return; if (delta > ideal_runtime) @@ -6611,7 +6595,7 @@ index 2c3d0d49c80e..32fd5278d2b7 100644 } static void -@@ -5053,7 +5053,7 @@ entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr, int queued) +@@ -5104,7 +5104,7 @@ entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr, int queued) * validating it and just reschedule. */ if (queued) { @@ -6620,7 +6604,7 @@ index 2c3d0d49c80e..32fd5278d2b7 100644 return; } /* -@@ -5202,7 +5202,7 @@ static void __account_cfs_rq_runtime(struct cfs_rq *cfs_rq, u64 delta_exec) +@@ -5253,7 +5253,7 @@ static void __account_cfs_rq_runtime(struct cfs_rq *cfs_rq, u64 delta_exec) * hierarchy can be throttled */ if (!assign_cfs_rq_runtime(cfs_rq) && likely(cfs_rq->curr)) @@ -6629,7 +6613,7 @@ index 2c3d0d49c80e..32fd5278d2b7 100644 } static __always_inline -@@ -5953,7 +5953,7 @@ static void hrtick_start_fair(struct rq *rq, struct task_struct *p) +@@ -6004,7 +6004,7 @@ static void hrtick_start_fair(struct rq *rq, struct task_struct *p) if (delta < 0) { if (task_current(rq, p)) @@ -6638,7 +6622,7 @@ index 2c3d0d49c80e..32fd5278d2b7 100644 return; } hrtick_start(rq, delta); -@@ -7630,7 +7630,7 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_ +@@ -7678,7 +7678,7 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_ return; preempt: @@ -6647,7 +6631,7 @@ index 2c3d0d49c80e..32fd5278d2b7 100644 /* * Only set the backward buddy when the current task is still * on the rq. This can happen when a wakeup gets interleaved -@@ -11783,7 +11783,7 @@ static void task_fork_fair(struct task_struct *p) +@@ -11907,7 +11907,7 @@ static void task_fork_fair(struct task_struct *p) * 'current' within the tree based on its new key value. */ swap(curr->vruntime, se->vruntime); @@ -6656,7 +6640,7 @@ index 2c3d0d49c80e..32fd5278d2b7 100644 } se->vruntime -= cfs_rq->min_vruntime; -@@ -11810,7 +11810,7 @@ prio_changed_fair(struct rq *rq, struct task_struct *p, int oldprio) +@@ -11934,7 +11934,7 @@ prio_changed_fair(struct rq *rq, struct task_struct *p, int oldprio) */ if (task_current(rq, p)) { if (p->prio > oldprio) @@ -6680,10 +6664,10 @@ index ee7f23c76bd3..e13090e33f3c 100644 /* diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h -index d6d488e8eb55..52aeec99f168 100644 +index 5f18460f62f0..89bc8b536c95 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h -@@ -2350,6 +2350,15 @@ extern void reweight_task(struct task_struct *p, int prio); +@@ -2351,6 +2351,15 @@ extern void reweight_task(struct task_struct *p, int prio); extern void resched_curr(struct rq *rq); extern void resched_cpu(int cpu); @@ -6834,7 +6818,7 @@ index c8a6913c067d..82f3e68fbe22 100644 } early_initcall(spawn_ksoftirqd); diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c -index 3ae661ab6260..0a56c61710ea 100644 +index e4f0e3b0c4f4..9e2cfba065de 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1805,7 +1805,7 @@ void hrtimer_interrupt(struct clock_event_device *dev) @@ -6882,10 +6866,10 @@ index 717fcb9fb14a..e6219da89933 100644 /* diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c -index a387bdc6af01..255b7a745bb5 100644 +index 3360d638071a..cac47c941e02 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c -@@ -2650,11 +2650,19 @@ unsigned int tracing_gen_ctx_irq_test(unsigned int irqs_status) +@@ -2657,11 +2657,19 @@ unsigned int tracing_gen_ctx_irq_test(unsigned int irqs_status) if (softirq_count() >> (SOFTIRQ_SHIFT + 1)) trace_flags |= TRACE_FLAG_BH_OFF; @@ -6907,7 +6891,7 @@ index a387bdc6af01..255b7a745bb5 100644 (min_t(unsigned int, migration_disable_value(), 0xf)) << 4; } -@@ -4240,15 +4248,17 @@ unsigned long trace_total_entries(struct trace_array *tr) +@@ -4247,15 +4255,17 @@ unsigned long trace_total_entries(struct trace_array *tr) static void print_lat_help_header(struct seq_file *m) { @@ -6934,7 +6918,7 @@ index a387bdc6af01..255b7a745bb5 100644 } static void print_event_info(struct array_buffer *buf, struct seq_file *m) -@@ -4282,14 +4292,16 @@ static void print_func_help_header_irq(struct array_buffer *buf, struct seq_file +@@ -4289,14 +4299,16 @@ static void print_func_help_header_irq(struct array_buffer *buf, struct seq_file print_event_info(buf, m); @@ -6960,7 +6944,7 @@ index a387bdc6af01..255b7a745bb5 100644 void diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c -index 2a2ea9b6f762..0638b10566b2 100644 +index e67923986496..eed261e2f753 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -208,6 +208,7 @@ static int trace_define_common_fields(void) @@ -7134,10 +7118,10 @@ index 9ffd40b8270c..bc75fa1e4666 100644 u64_stats_add(&stats->rx_packets, rxpackets); u64_stats_add(&stats->rx_bytes, rxbytes); diff --git a/net/core/dev.c b/net/core/dev.c -index 70e06853ba25..6678dc114607 100644 +index a25b8741b159..dec69ba97e5e 100644 --- a/net/core/dev.c +++ b/net/core/dev.c -@@ -4582,15 +4582,6 @@ static void rps_trigger_softirq(void *data) +@@ -4585,15 +4585,6 @@ static void rps_trigger_softirq(void *data) #endif /* CONFIG_RPS */ @@ -7153,7 +7137,7 @@ index 70e06853ba25..6678dc114607 100644 /* * Check if this softnet_data structure is another cpu one * If yes, queue it to our IPI list and return 1 -@@ -6648,6 +6639,30 @@ static void skb_defer_free_flush(struct softnet_data *sd) +@@ -6651,6 +6642,30 @@ static void skb_defer_free_flush(struct softnet_data *sd) } } @@ -7184,7 +7168,7 @@ index 70e06853ba25..6678dc114607 100644 static __latent_entropy void net_rx_action(struct softirq_action *h) { struct softnet_data *sd = this_cpu_ptr(&softnet_data); -@@ -10469,12 +10484,12 @@ void dev_fetch_sw_netstats(struct rtnl_link_stats64 *s, +@@ -10472,12 +10487,12 @@ void dev_fetch_sw_netstats(struct rtnl_link_stats64 *s, stats = per_cpu_ptr(netstats, cpu); do { @@ -7199,7 +7183,7 @@ index 70e06853ba25..6678dc114607 100644 s->rx_packets += rx_packets; s->rx_bytes += rx_bytes; -@@ -11389,7 +11404,11 @@ static int __init net_dev_init(void) +@@ -11392,7 +11407,11 @@ static int __init net_dev_init(void) INIT_CSD(&sd->csd, rps_trigger_softirq, sd); sd->cpu = i; #endif @@ -7313,7 +7297,7 @@ index c8d137ef5980..b71ccaec0991 100644 static int diff --git a/net/core/skbuff.c b/net/core/skbuff.c -index 51db260f471f..9f6572e6f197 100644 +index cd4b3a610961..60ec16b6e97a 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -6662,6 +6662,11 @@ nodefer: __kfree_skb(skb); @@ -7330,7 +7314,7 @@ index 51db260f471f..9f6572e6f197 100644 + } } diff --git a/net/dsa/slave.c b/net/dsa/slave.c -index a9fde48cffd4..83e419afa89e 100644 +index 5fe075bf479e..28ee63ec1d1d 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -976,12 +976,12 @@ static void dsa_slave_get_ethtool_stats(struct net_device *dev, @@ -7385,10 +7369,10 @@ index 8370726ae7bf..487f8e98deaa 100644 counters.packets += packets; counters.bytes += bytes; diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c -index cebfd148bb40..1e922f95a98d 100644 +index 30efa26f977f..43d6aca83145 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c -@@ -2396,9 +2396,9 @@ static inline u64 sta_get_tidstats_msdu(struct ieee80211_sta_rx_stats *rxstats, +@@ -2397,9 +2397,9 @@ static inline u64 sta_get_tidstats_msdu(struct ieee80211_sta_rx_stats *rxstats, u64 value; do { @@ -7400,7 +7384,7 @@ index cebfd148bb40..1e922f95a98d 100644 return value; } -@@ -2464,9 +2464,9 @@ static inline u64 sta_get_stats_bytes(struct ieee80211_sta_rx_stats *rxstats) +@@ -2465,9 +2465,9 @@ static inline u64 sta_get_stats_bytes(struct ieee80211_sta_rx_stats *rxstats) u64 value; do { @@ -7413,7 +7397,7 @@ index cebfd148bb40..1e922f95a98d 100644 return value; } diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c -index b52afe316dc4..35b5f806fdda 100644 +index f1f43894efb8..dc5165d3eec4 100644 --- a/net/mpls/af_mpls.c +++ b/net/mpls/af_mpls.c @@ -1079,9 +1079,9 @@ static void mpls_get_stats(struct mpls_dev *mdev, @@ -7449,7 +7433,7 @@ index 03af6a2ffd56..fb7cabc71366 100644 seq_printf(seq, "%3X %8LX %8LX %8LX %16LX %16LX\n", i, (u64)conns, (u64)inpkts, diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c -index 3ba8c291fcaa..d829f6df78b6 100644 +index 12d815b9aa13..202b8f907778 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -1546,10 +1546,10 @@ static int nft_dump_stats(struct sk_buff *skb, struct nft_stats __percpu *stats) diff --git a/patches/external/wireless_regdb/0001-Add-wireless-regdb-regulatory-database-file.patch b/patches/external/wireless_regdb/0001-Add-wireless-regdb-regulatory-database-file.patch index 67b2fc6ecbcc5443494d39c1aa228f839c51a584..589c374e8457c75a507c50d642547cca9ca34c59 100644 --- a/patches/external/wireless_regdb/0001-Add-wireless-regdb-regulatory-database-file.patch +++ b/patches/external/wireless_regdb/0001-Add-wireless-regdb-regulatory-database-file.patch @@ -1,6 +1,6 @@ -From 051ae300ae2deaf455f0433691949cf2c56a4e13 Mon Sep 17 00:00:00 2001 +From d7a44a1e086889672736dff4d7ba0639ec4bb239 Mon Sep 17 00:00:00 2001 From: Robert Nelson <robertcnelson@gmail.com> -Date: Wed, 3 May 2023 16:00:01 -0500 +Date: Wed, 17 May 2023 16:57:27 -0500 Subject: [PATCH] Add wireless-regdb regulatory database file https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git/commit/?id=43f81b4d0819ae1f9f6e31af7f563e9135aec9b6 diff --git a/patches/external/wpanusb/0001-merge-wpanusb-https-git.beagleboard.org-beagleconnec.patch b/patches/external/wpanusb/0001-merge-wpanusb-https-git.beagleboard.org-beagleconnec.patch index 0485cda75637ed7c4bdda3f0c9807c03f3d4f418..b5118a05fdfe030b226e8797ef28d9627b875abe 100644 --- a/patches/external/wpanusb/0001-merge-wpanusb-https-git.beagleboard.org-beagleconnec.patch +++ b/patches/external/wpanusb/0001-merge-wpanusb-https-git.beagleboard.org-beagleconnec.patch @@ -1,6 +1,6 @@ -From ad79002056dd1af5861252754b3568cdd6fa70b4 Mon Sep 17 00:00:00 2001 +From 6edf6190e3afd27d42c9a84e42a76e628fef5358 Mon Sep 17 00:00:00 2001 From: Robert Nelson <robertcnelson@gmail.com> -Date: Wed, 3 May 2023 15:36:37 -0500 +Date: Wed, 17 May 2023 16:51:31 -0500 Subject: [PATCH] merge: wpanusb: https://git.beagleboard.org/beagleconnect/linux/wpanusb diff --git a/patches/ref_omap2plus_defconfig b/patches/ref_omap2plus_defconfig index 31753f6d155983e3be00b488eb7e7b4705eb8791..b4ce1c4023118af4e78e1a9247f61c4cebc4bd20 100644 --- a/patches/ref_omap2plus_defconfig +++ b/patches/ref_omap2plus_defconfig @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm 6.1.12 Kernel Configuration +# Linux/arm 6.1.26 Kernel Configuration # CONFIG_CC_VERSION_TEXT="arm-linux-gnueabi-gcc (GCC) 12.2.0" CONFIG_CC_IS_GCC=y @@ -149,7 +149,6 @@ CONFIG_GENERIC_SCHED_CLOCK=y CONFIG_CC_IMPLICIT_FALLTHROUGH="-Wimplicit-fallthrough=5" CONFIG_GCC11_NO_ARRAY_BOUNDS=y -CONFIG_GCC12_NO_ARRAY_BOUNDS=y CONFIG_CC_NO_ARRAY_BOUNDS=y CONFIG_CGROUPS=y CONFIG_PAGE_COUNTER=y @@ -1276,7 +1275,6 @@ CONFIG_NET_SCH_INGRESS=m # CONFIG_NET_CLS=y # CONFIG_NET_CLS_BASIC is not set -# CONFIG_NET_CLS_TCINDEX is not set # CONFIG_NET_CLS_ROUTE4 is not set # CONFIG_NET_CLS_FW is not set CONFIG_NET_CLS_U32=m @@ -1860,6 +1858,7 @@ CONFIG_PCI_ENDPOINT_TEST=m # CONFIG_HISI_HIKEY_USB is not set # CONFIG_OPEN_DICE is not set # CONFIG_VCPU_STALL_DETECTOR is not set +CONFIG_DMA_BUF_PHYS=y # CONFIG_C2PORT is not set # @@ -2863,6 +2862,7 @@ CONFIG_SERIAL_MCTRL_GPIO=y # CONFIG_NOZOMI is not set # CONFIG_NULL_TTY is not set # CONFIG_HVC_DCC is not set +# CONFIG_RPMSG_TTY is not set CONFIG_SERIAL_DEV_BUS=y CONFIG_SERIAL_DEV_CTRL_TTYPORT=y # CONFIG_TTY_PRINTK is not set @@ -2894,6 +2894,7 @@ CONFIG_I2C_BOARDINFO=y CONFIG_I2C_COMPAT=y CONFIG_I2C_CHARDEV=y # CONFIG_I2C_MUX is not set +# CONFIG_I2C_ATR is not set CONFIG_I2C_HELPER_AUTO=y CONFIG_I2C_ALGOBIT=m @@ -3368,7 +3369,6 @@ CONFIG_SENSORS_LM75=m # CONFIG_SENSORS_PC87427 is not set # CONFIG_SENSORS_NTC_THERMISTOR is not set # CONFIG_SENSORS_NCT6683 is not set -# CONFIG_SENSORS_NCT6775 is not set # CONFIG_SENSORS_NCT6775_I2C is not set # CONFIG_SENSORS_NCT7802 is not set # CONFIG_SENSORS_NCT7904 is not set @@ -3596,10 +3596,13 @@ CONFIG_MFD_TPS65217=y CONFIG_MFD_TI_LP873X=y CONFIG_MFD_TI_LP87565=y CONFIG_MFD_TPS65218=y +# CONFIG_MFD_TPS65219 is not set # CONFIG_MFD_TPS6586X is not set CONFIG_MFD_TPS65910=y # CONFIG_MFD_TPS65912_I2C is not set # CONFIG_MFD_TPS65912_SPI is not set +# CONFIG_MFD_TPS6594_I2C is not set +# CONFIG_MFD_TPS6594_SPI is not set CONFIG_TWL4030_CORE=y CONFIG_TWL4030_POWER=y CONFIG_MFD_TWL4030_AUDIO=y @@ -3858,6 +3861,11 @@ CONFIG_V4L_PLATFORM_DRIVERS=y # # Chips&Media media platform drivers # +# CONFIG_VIDEO_WAVE_VPU is not set + +# +# IMG media platform drivers +# # # Intel media platform drivers @@ -3961,6 +3969,7 @@ CONFIG_VIDEO_APTINA_PLL=m # CONFIG_VIDEO_IMX334 is not set # CONFIG_VIDEO_IMX335 is not set # CONFIG_VIDEO_IMX355 is not set +# CONFIG_VIDEO_IMX390 is not set # CONFIG_VIDEO_IMX412 is not set # CONFIG_VIDEO_MT9M001 is not set # CONFIG_VIDEO_MT9M032 is not set @@ -3977,6 +3986,7 @@ CONFIG_VIDEO_MT9P031=m # CONFIG_VIDEO_OV08D10 is not set # CONFIG_VIDEO_OV13858 is not set # CONFIG_VIDEO_OV13B10 is not set +# CONFIG_VIDEO_OV2312 is not set # CONFIG_VIDEO_OV2640 is not set # CONFIG_VIDEO_OV2659 is not set # CONFIG_VIDEO_OV2680 is not set @@ -4136,6 +4146,14 @@ CONFIG_VIDEO_TVP5150=m # CONFIG_VIDEO_THS7303 is not set # end of Miscellaneous helper chips +# +# Video serializers and deserializers +# +# CONFIG_VIDEO_DS90UB913 is not set +# CONFIG_VIDEO_DS90UB953 is not set +# CONFIG_VIDEO_DS90UB960 is not set +# end of Video serializers and deserializers + # # Media SPI Adapters # @@ -4543,8 +4561,6 @@ CONFIG_DRM_TI_TPD12S015=m # CONFIG_DRM_STI is not set # CONFIG_DRM_ETNAVIV is not set # CONFIG_DRM_LOGICVC is not set -# CONFIG_DRM_MXSFB is not set -# CONFIG_DRM_IMX_LCDIF is not set # CONFIG_DRM_ARCPGU is not set # CONFIG_DRM_BOCHS is not set # CONFIG_DRM_CIRRUS_QEMU is not set @@ -4825,6 +4841,7 @@ CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM=y # CONFIG_SND_SOC_FSL_ESAI is not set # CONFIG_SND_SOC_FSL_MICFIL is not set # CONFIG_SND_SOC_FSL_XCVR is not set +# CONFIG_SND_SOC_FSL_RPMSG is not set # CONFIG_SND_SOC_IMX_AUDMUX is not set # end of SoC Audio for Freescale CPUs @@ -5942,10 +5959,23 @@ CONFIG_WKUP_M3_RPROC=m # # Rpmsg drivers # +CONFIG_RPMSG=m +# CONFIG_RPMSG_CHAR is not set +# CONFIG_RPMSG_CTRL is not set +# CONFIG_RPMSG_NS is not set # CONFIG_RPMSG_QCOM_GLINK_RPM is not set # CONFIG_RPMSG_VIRTIO is not set # end of Rpmsg drivers +# +# Rpmsg virtual device drivers +# +CONFIG_RPMSG_KDRV=m +# CONFIG_RPMSG_KDRV_DEMO is not set +# CONFIG_RPMSG_KDRV_DISPLAY is not set +CONFIG_RPMSG_KDRV_ETH_SWITCH=m +# end of Rpmsg virtual device drivers + # CONFIG_SOUNDWIRE is not set # diff --git a/patches/soc/ti/beagleboard_dtbs/0001-Add-BeagleBoard.org-Device-Tree-Changes.patch b/patches/soc/ti/beagleboard_dtbs/0001-Add-BeagleBoard.org-Device-Tree-Changes.patch index 23fb429714825b55c0e8656b9664051d563e9918..463aa47c7bcb1d0951388ffab5e3638d30f14cfd 100644 --- a/patches/soc/ti/beagleboard_dtbs/0001-Add-BeagleBoard.org-Device-Tree-Changes.patch +++ b/patches/soc/ti/beagleboard_dtbs/0001-Add-BeagleBoard.org-Device-Tree-Changes.patch @@ -1,11 +1,11 @@ -From b3b8cc6d728e91fac598bd1c55c4d40d83587543 Mon Sep 17 00:00:00 2001 +From 115bb0a424a89913abf30dd97e68649829b2984d Mon Sep 17 00:00:00 2001 From: Robert Nelson <robertcnelson@gmail.com> -Date: Thu, 4 May 2023 11:57:03 -0500 +Date: Wed, 17 May 2023 16:58:51 -0500 Subject: [PATCH] Add BeagleBoard.org Device Tree Changes https://git.beagleboard.org/beagleboard/BeagleBoard-DeviceTrees/-/tree/v6.1.x-ti -https://git.beagleboard.org/beagleboard/BeagleBoard-DeviceTrees/-/commit/b92841690e5994821c7882201880e50955278ecd +https://git.beagleboard.org/beagleboard/BeagleBoard-DeviceTrees/-/commit/0e19df9ed0244271ac27cf9135dbdb453b97255d Signed-off-by: Robert Nelson <robertcnelson@gmail.com> --- arch/arm/boot/dts/am335x-bbb-bone-buses.dtsi | 85 + @@ -31,11 +31,14 @@ Signed-off-by: Robert Nelson <robertcnelson@gmail.com> .../arm/boot/dts/am335x-sancloud-bbe-lite.dts | 6 + arch/arm/boot/dts/am335x-sancloud-bbe.dts | 5 + arch/arm/boot/dts/am33xx-l4.dtsi | 4 +- - arch/arm/boot/dts/am33xx.dtsi | 7 + + arch/arm/boot/dts/am33xx.dtsi | 6 + arch/arm/boot/dts/am5729-beagleboneai.dts | 9 + arch/arm/boot/dts/am57xx-beagle-x15-revb1.dts | 5 + arch/arm/boot/dts/am57xx-beagle-x15-revc.dts | 5 + arch/arm/boot/dts/am57xx-beagle-x15.dts | 5 + + arch/arm/boot/dts/dra7.dtsi | 9 +- + arch/arm/boot/dts/omap34xx.dtsi | 11 +- + arch/arm/boot/dts/omap4.dtsi | 9 +- .../boot/dts/overlays/AM335X-PRU-UIO-00A0.dts | 28 + .../boot/dts/overlays/AM57XX-PRU-UIO-00A0.dts | 55 + arch/arm/boot/dts/overlays/BB-ADC-00A0.dts | 112 + @@ -72,8 +75,10 @@ Signed-off-by: Robert Nelson <robertcnelson@gmail.com> arch/arm/boot/dts/overlays/PB-MIKROBUS-0.dts | 107 + arch/arm/boot/dts/overlays/PB-MIKROBUS-1.dts | 108 + include/dt-bindings/board/am335x-bone-pins.h | 253 ++ + include/dt-bindings/mux/ti-serdes.h | 82 - + include/dt-bindings/pinctrl/k3.h | 7 - include/dt-bindings/pinctrl/omap.h | 4 +- - 65 files changed, 10846 insertions(+), 328 deletions(-) + 70 files changed, 10855 insertions(+), 436 deletions(-) create mode 100644 arch/arm/boot/dts/am335x-bbb-bone-buses.dtsi create mode 100644 arch/arm/boot/dts/am335x-bone-common-univ.dtsi create mode 100644 arch/arm/boot/dts/am335x-boneblack-uboot-univ.dts @@ -7799,23 +7804,26 @@ index 7e50fe633d8a..4b5cc56929f1 100644 pruss: pruss@0 { compatible = "ti,am3356-pruss"; diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi -index 32d397b3950b..6df6f439ae8d 100644 +index ad5b1050d4b1..6df6f439ae8d 100644 --- a/arch/arm/boot/dts/am33xx.dtsi +++ b/arch/arm/boot/dts/am33xx.dtsi -@@ -633,6 +633,13 @@ target-module@56000000 { - * Closed source PowerVR driver, no child device - * binding or driver in mainline - */ -+ gpu: gpu@0 { -+ compatible = "ti,am3352-sgx530", "img,sgx530"; -+ reg = <0x0 0x10000>; -+ interrupts = <37>; +@@ -629,10 +629,16 @@ target-module@56000000 { + #size-cells = <1>; + ranges = <0 0x56000000 0x1000000>; + ++ /* ++ * Closed source PowerVR driver, no child device ++ * binding or driver in mainline ++ */ + gpu: gpu@0 { + compatible = "ti,am3352-sgx530", "img,sgx530"; + reg = <0x0 0x10000>; + interrupts = <37>; + clocks = <&gfx_fck_div_ck>; + clock-names = "fclk"; -+ }; + }; }; }; - }; diff --git a/arch/arm/boot/dts/am5729-beagleboneai.dts b/arch/arm/boot/dts/am5729-beagleboneai.dts index 149cfafb90bf..82e17ab6426c 100644 --- a/arch/arm/boot/dts/am5729-beagleboneai.dts @@ -7909,6 +7917,74 @@ index 0a8b16505ed9..028928f8d43e 100644 }; &tpd12s015 { +diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi +index 38737ca12541..97ce0c4f1df7 100644 +--- a/arch/arm/boot/dts/dra7.dtsi ++++ b/arch/arm/boot/dts/dra7.dtsi +@@ -847,19 +847,12 @@ target-module@56000000 { + <SYSC_IDLE_SMART>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, +- <SYSC_IDLE_SMART>, +- <SYSC_IDLE_SMART_WKUP>; ++ <SYSC_IDLE_SMART>; + clocks = <&gpu_clkctrl DRA7_GPU_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0 0x56000000 0x2000000>; +- +- gpu: gpu@0 { +- compatible = "ti,dra7-sgx544", "img,sgx544"; +- reg = <0x0 0x10000>; +- interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>; +- }; + }; + + crossbar_mpu: crossbar@4a002a48 { +diff --git a/arch/arm/boot/dts/omap34xx.dtsi b/arch/arm/boot/dts/omap34xx.dtsi +index 1ae53a348781..2eb73ae7ef3e 100644 +--- a/arch/arm/boot/dts/omap34xx.dtsi ++++ b/arch/arm/boot/dts/omap34xx.dtsi +@@ -164,13 +164,12 @@ sgx_module: target-module@50000000 { + clock-names = "fck", "ick"; + #address-cells = <1>; + #size-cells = <1>; +- ranges = <0 0x50000000 0x10000>; ++ ranges = <0 0x50000000 0x4000>; + +- sgx: gpu@0 { +- compatible = "ti,omap3530-sgx530", "img,sgx530"; +- reg = <0x0 0x10000>; /* 64kB */ +- interrupts = <21>; +- }; ++ /* ++ * Closed source PowerVR driver, no child device ++ * binding or driver in mainline ++ */ + }; + }; + +diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi +index ce48f19c4c54..2bbff9032be3 100644 +--- a/arch/arm/boot/dts/omap4.dtsi ++++ b/arch/arm/boot/dts/omap4.dtsi +@@ -501,11 +501,10 @@ sgx_module: target-module@56000000 { + #size-cells = <1>; + ranges = <0 0x56000000 0x2000000>; + +- gpu@0 { +- compatible = "ti,omap4430-sgx540", "img,sgx540"; +- reg = <0x0 0x2000000>; /* 32MB */ +- interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>; +- }; ++ /* ++ * Closed source PowerVR driver, no child device ++ * binding or driver in mainline ++ */ + }; + + /* diff --git a/arch/arm/boot/dts/overlays/AM335X-PRU-UIO-00A0.dts b/arch/arm/boot/dts/overlays/AM335X-PRU-UIO-00A0.dts new file mode 100644 index 000000000000..f3016efca2d7 @@ -12004,6 +12080,115 @@ index 000000000000..54e92664ba79 +#define P2_35(mode) AM33XX_IOPAD(0x08e0, mode) /* U5: lcd_vsync */ + +#endif +diff --git a/include/dt-bindings/mux/ti-serdes.h b/include/dt-bindings/mux/ti-serdes.h +index 0d7aec677df9..d3116c52ab72 100644 +--- a/include/dt-bindings/mux/ti-serdes.h ++++ b/include/dt-bindings/mux/ti-serdes.h +@@ -117,86 +117,4 @@ + #define J721S2_SERDES0_LANE3_USB 0x2 + #define J721S2_SERDES0_LANE3_IP4_UNUSED 0x3 + +-/* J784S4 */ +- +-#define J784S4_SERDES0_LANE0_IP1_UNUSED 0x0 +-#define J784S4_SERDES0_LANE0_PCIE1_LANE0 0x1 +-#define J784S4_SERDES0_LANE0_IP3_UNUSED 0x2 +-#define J784S4_SERDES0_LANE0_IP4_UNUSED 0x3 +- +-#define J784S4_SERDES0_LANE1_IP1_UNUSED 0x0 +-#define J784S4_SERDES0_LANE1_PCIE1_LANE1 0x1 +-#define J784S4_SERDES0_LANE1_IP3_UNUSED 0x2 +-#define J784S4_SERDES0_LANE1_IP4_UNUSED 0x3 +- +-#define J784S4_SERDES0_LANE2_PCIE3_LANE0 0x0 +-#define J784S4_SERDES0_LANE2_PCIE1_LANE2 0x1 +-#define J784S4_SERDES0_LANE2_IP3_UNUSED 0x2 +-#define J784S4_SERDES0_LANE2_IP4_UNUSED 0x3 +- +-#define J784S4_SERDES0_LANE3_PCIE3_LANE1 0x0 +-#define J784S4_SERDES0_LANE3_PCIE1_LANE3 0x1 +-#define J784S4_SERDES0_LANE3_USB 0x2 +-#define J784S4_SERDES0_LANE3_IP4_UNUSED 0x3 +- +-#define J784S4_SERDES1_LANE0_QSGMII_LANE3 0x0 +-#define J784S4_SERDES1_LANE0_PCIE0_LANE0 0x1 +-#define J784S4_SERDES1_LANE0_IP3_UNUSED 0x2 +-#define J784S4_SERDES1_LANE0_IP4_UNUSED 0x3 +- +-#define J784S4_SERDES1_LANE1_QSGMII_LANE4 0x0 +-#define J784S4_SERDES1_LANE1_PCIE0_LANE1 0x1 +-#define J784S4_SERDES1_LANE1_IP3_UNUSED 0x2 +-#define J784S4_SERDES1_LANE1_IP4_UNUSED 0x3 +- +-#define J784S4_SERDES1_LANE2_QSGMII_LANE1 0x0 +-#define J784S4_SERDES1_LANE2_PCIE0_LANE2 0x1 +-#define J784S4_SERDES1_LANE2_PCIE2_LANE0 0x2 +-#define J784S4_SERDES1_LANE2_IP4_UNUSED 0x3 +- +-#define J784S4_SERDES1_LANE3_QSGMII_LANE2 0x0 +-#define J784S4_SERDES1_LANE3_PCIE0_LANE3 0x1 +-#define J784S4_SERDES1_LANE3_PCIE2_LANE1 0x2 +-#define J784S4_SERDES1_LANE3_IP4_UNUSED 0x3 +- +-#define J784S4_SERDES2_LANE0_QSGMII_LANE5 0x0 +-#define J784S4_SERDES2_LANE0_IP2_UNUSED 0x1 +-#define J784S4_SERDES2_LANE0_IP3_UNUSED 0x2 +-#define J784S4_SERDES2_LANE0_IP4_UNUSED 0x3 +- +-#define J784S4_SERDES2_LANE1_QSGMII_LANE6 0x0 +-#define J784S4_SERDES2_LANE1_IP2_UNUSED 0x1 +-#define J784S4_SERDES2_LANE1_IP3_UNUSED 0x2 +-#define J784S4_SERDES2_LANE1_IP4_UNUSED 0x3 +- +-#define J784S4_SERDES2_LANE2_QSGMII_LANE7 0x0 +-#define J784S4_SERDES2_LANE2_QSGMII_LANE1 0x1 +-#define J784S4_SERDES2_LANE2_IP3_UNUSED 0x2 +-#define J784S4_SERDES2_LANE2_IP4_UNUSED 0x3 +- +-#define J784S4_SERDES2_LANE3_QSGMII_LANE8 0x0 +-#define J784S4_SERDES2_LANE3_QSGMII_LANE2 0x1 +-#define J784S4_SERDES2_LANE3_IP3_UNUSED 0x2 +-#define J784S4_SERDES2_LANE3_IP4_UNUSED 0x3 +- +-#define J784S4_SERDES4_LANE0_EDP_LANE0 0x0 +-#define J784S4_SERDES4_LANE0_QSGMII_LANE5 0x1 +-#define J784S4_SERDES4_LANE0_IP3_UNUSED 0x2 +-#define J784S4_SERDES4_LANE0_IP4_UNUSED 0x3 +- +-#define J784S4_SERDES4_LANE1_EDP_LANE1 0x0 +-#define J784S4_SERDES4_LANE1_QSGMII_LANE6 0x1 +-#define J784S4_SERDES4_LANE1_IP3_UNUSED 0x2 +-#define J784S4_SERDES4_LANE1_IP4_UNUSED 0x3 +- +-#define J784S4_SERDES4_LANE2_EDP_LANE2 0x0 +-#define J784S4_SERDES4_LANE2_QSGMII_LANE7 0x1 +-#define J784S4_SERDES4_LANE2_IP3_UNUSED 0x2 +-#define J784S4_SERDES4_LANE2_IP4_UNUSED 0x3 +- +-#define J784S4_SERDES4_LANE3_EDP_LANE3 0x0 +-#define J784S4_SERDES4_LANE3_QSGMII_LANE8 0x1 +-#define J784S4_SERDES4_LANE3_USB 0x2 +-#define J784S4_SERDES4_LANE3_IP4_UNUSED 0x3 +- + #endif /* _DT_BINDINGS_MUX_TI_SERDES */ +diff --git a/include/dt-bindings/pinctrl/k3.h b/include/dt-bindings/pinctrl/k3.h +index b5aca149664e..6bb9df1a264d 100644 +--- a/include/dt-bindings/pinctrl/k3.h ++++ b/include/dt-bindings/pinctrl/k3.h +@@ -8,13 +8,6 @@ + #ifndef _DT_BINDINGS_PINCTRL_TI_K3_H + #define _DT_BINDINGS_PINCTRL_TI_K3_H + +-/* +- * These bindings are deprecated, because they do not match the actual +- * concept of bindings but rather contain pure register values. +- * Instead include the header in the DTS source directory. +- */ +-#warning "These bindings are deprecated. Instead, use the header in the DTS source directory." +- + #define PULLUDEN_SHIFT (16) + #define PULLTYPESEL_SHIFT (17) + #define RXACTIVE_SHIFT (18) diff --git a/include/dt-bindings/pinctrl/omap.h b/include/dt-bindings/pinctrl/omap.h index f48245ff87e5..625718042413 100644 --- a/include/dt-bindings/pinctrl/omap.h diff --git a/version.sh b/version.sh index d4916fe37e3bcc3ab354c23ccc664743a69442ab..40a285e38f860c921865d1d111f2a6c44d85389b 100644 --- a/version.sh +++ b/version.sh @@ -45,10 +45,10 @@ toolchain="gcc_12_arm" #Kernel KERNEL_REL=6.1 -KERNEL_TAG=${KERNEL_REL}.12 -kernel_rt=".12-rt7" +KERNEL_TAG=${KERNEL_REL}.26 +kernel_rt=".26-rt8" #Kernel Build -BUILD=${build_prefix}1 +BUILD=${build_prefix}1.1 #v6.X-rcX + upto SHA #prev_KERNEL_SHA="" @@ -60,7 +60,7 @@ BRANCH="${branch_prefix}${KERNEL_REL}${branch_postfix}" DISTRO=xross ti_git_old_release="78816b00ff46ccb75f8d9676a716bf7e07541d54" -ti_git_new_release="78816b00ff46ccb75f8d9676a716bf7e07541d54" +ti_git_new_release="5618571dbfea8f91cafc5595ec360037da9fd5ac" #TISDK="08.06.00.006" #