799786 Commits

Author SHA1 Message Date
myfluxi
d79806e11a
msm: kgsl: Report correct GPU frequency in sysfs
Change-Id: I1aac90d0554b9de0511ffb78042177a5a23855ce
Signed-off-by: Alex Naidis <alex.naidis@linux.com>
Signed-off-by: atndko <z1281552865@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:56:17 +07:00
Park Ju Hyung
49feb90ede
drm/msm: use kmem_cache pool for struct vblank_work
These get allocated and freed millions of times on this kernel tree.

Use a dedicated kmem_cache pool and avoid costly dynamic memory allocations.

Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
Signed-off-by: Nauval Rizky <enuma.alrizky@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:56:17 +07:00
azrim
241a81ebcb
Revert "msm: adreno: Relax CPU latency requirements to save power"
This reverts commit 582b23590ceba71b1ed78982db6b880e1da0ee6c.

Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:45 +07:00
Park Ju Hyung
3a36008952
zram: use crc32c instead of jhash in dedup
crc32c is accelerated in arm64 and is faster than jhash.

Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
Change-Id: Ic4040e5ee941dca61fbfa6ac3b0f8d9a5f22a3dc
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:45 +07:00
Cosmin Tanislav
9a640a495a
display: sde: do not pass around offset string
Signed-off-by: Andrzej Perczak <linux@andrzejperczak.com>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:26 +07:00
Vaisakh Murali
4aac8ab4db
input/fp: goodix: Inline resume, suspend and cleanup functions
These functions are small and queried extensively, making them inlined
and static should speed up the function

[ghostrider-reborn]: Silence logging while we're at it

Signed-off-by: Vaisakh Murali <mvaisakh@statixos.com>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: Adithya R <gh0strider.2k18.reborn@gmail.com>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:26 +07:00
azrim
0ab970b946
msm: dsi-staging: Force enable ULPS
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:26 +07:00
Yaroslav Furman
62ef810a0b
msm: npu_dev: Initialize mutex_lock earlier
It's needed in npu_hw_info_init.
Warning is a bit dirty, idk why.

[    7.090579] ------------[ cut here ]------------
[    7.095339] WARNING: CPU: 6 PID: 1 at __mutex_lock_common+0xcc0/0x102c
[    7.096826] i2c_geni 884000.i2c: i2c error :-107
[    7.102045] CPU: 6 PID: 1 Comm: swapper/0 Tainted: G S      W       4.14.207-F1xy-Q-surya/6feb547eb0 #148
[    7.102046] Hardware name: Qualcomm Technologies, Inc. SDMMAGPIE PM6150 IDP (DT)
[    7.102049] task: 00000000a1ec88c7 task.stack: 00000000efa6f57d
[    7.106801] aw8624_i2c_read: i2c_read cnt=0 error=-107
[    7.116611] pc : __mutex_lock_common+0xcc0/0x102c
[    7.116613] lr : __mutex_lock_common+0xcc0/0x102c
[    7.116615] sp : ffffff801005b940 pstate : 60c00005
[    7.124400] aw8624_read_chipid  reg 24
[    7.130287] x29: ffffff801005b9a0 x28: ffffffdbf090f800
[    7.130290] x27: 0000000000000012 x26: 0000000000000002
[    7.135573] aw8624_read_chipid aw8624 detected
[    7.140398] x25: ffffff976fe6cf8c x24: 0000000000000000
[    7.140401] x23: 0000000000000000
[    7.150052] aw8624_haptic 3-005a: aw8624_i2c_probe: aw8624_read_chipid ret=0
[    7.150239] x22: ffffff976f3cc67c
[    7.154365] aw8624_interrupt_setup: reg SYSINT=0x0
[    7.159642] x21: 0000000000000000 x20: 0000000000000000
[    7.159645] x19: ffffffdbecfb4080 x18: ffffff977081a8d0
[    7.166825] genirq: irq_chip msmgpio-dc did not update eff. affinity mask of irq 259
[    7.213125] x17: ffffff977166d000 x16: 0000000000000001
[    7.218586] x15: ffffff97702c6d99 x14: 0000000000003739
[    7.224049] x13: 0000000000000004 x12: 00000000081cb39f
[    7.229512] x11: 0000000000000015 x10: ffffff97705a6d48
[    7.234973] x9 : f74f7dd9b21f2400 x8 : f74f7dd9b21f2400
[    7.240435] x7 : ffffff976eb2c544 x6 : 0000000000000000
[    7.245897] x5 : ffffff976eb2f0d8 x4 : ffffff976eb2c6f8
[    7.251359] x3 : ffffff976eb2be08 x2 : ffffff976eae9b04
[    7.256822] x1 : 0000000000000000 x0 : 0000000000000028
[    7.262285]
[    7.262285] PC: 0xffffff976fc6583c:
[    7.267388] 583c  97fff55d 17ffff38 12800e39 17ffff37 d4210000 17fffe30 97c8920c 34ff9f40
[    7.275797] 585c  f000d188 b94a7908 35ff9ee8 b0001520 910d1400 900011e1 9123c821 97bb14de
[    7.284198] 587c  d4210000 17fffcf0 91002276 aa1603e0 94000a20 f0004dda b943b748 340000a8
[    7.292595] 589c  91008260 12800001 97bad64f 340019c0 aa1303fb f8458f77 eb1b02ff 54001400
[    7.300995]
[    7.300995] LR: 0xffffff976fc6583c:
[    7.306096] 583c  97fff55d 17ffff38 12800e39 17ffff37 d4210000 17fffe30 97c8920c 34ff9f40
[    7.314504] 585c  f000d188 b94a7908 35ff9ee8 b0001520 910d1400 900011e1 9123c821 97bb14de
[    7.322902] 587c  d4210000 17fffcf0 91002276 aa1603e0 94000a20 f0004dda b943b748 340000a8
[    7.331300] 589c  91008260 12800001 97bad64f 340019c0 aa1303fb f8458f77 eb1b02ff 54001400
[    7.339699]
[    7.339699] SP: 0xffffff801005b900:
[    7.340283] aw8624_haptic_get_f0 t_f0_trace_ms:136
[    7.344800] b900  6fc6587c ffffff97 60c00005 00000000 ffffffc8 ffffff80 b21f2400 f74f7dd9
[    7.351282] aw8624->f0_calib_data=60
[    7.358218] b920  ffffffff ffffffff 6fc6587c ffffff97 1005b9a0 ffffff80 6fc6587c ffffff97
[    7.362196] aw8624_haptic_f0_calibration final trim_lra=0x3c
[    7.370297] b940  1005b960 ffffff80 6eb5ce38 ffffff97 00000028 00000000 6fc68208 ffffff97
[    7.378898] input: aw8624_haptic as /devices/platform/soc/884000.i2c/i2c-3/3-005a/input/input2
[    7.384505] b960  1005b990 ffffff80 6eae9bf0 ffffff97 aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa
[    7.393448] aw8624_i2c_probe probe completed successfully!
[    7.401750]
[    7.401752] Call trace:
[    7.401754] __mutex_lock_common+0xcc0/0x102c
[    7.401756] mutex_lock_nested+0x24/0x2c
[    7.408320] i2c_geni a8c000.i2c: Bus frequency not specified, default to 400KHz.
[    7.408927] npu_enable_core_power+0x1c/0x258
[    7.409192] nq-nci 0-0028: nqx_probe: probing NFCC NQxxx exited successfully
[    7.411990] wl2866d_probe,enrty
[    7.415909] npu_probe+0x3ac/0xc0c
[    7.415915] platform_drv_probe+0x64/0xb8
[    7.415918] driver_probe_device+0x418/0x450
[    7.415920] __driver_attach+0xd0/0x108
[    7.420223] wl2866d_init: en_gpio is 1262
[    7.427538] bus_for_each_dev+0x88/0xd0
[    7.427540] driver_attach+0x20/0x28
[    7.427542] bus_add_driver+0x11c/0x1d8
[    7.427544] driver_register+0xa4/0xf0
[    7.427546] __platform_driver_register+0x40/0x48
[    7.433565] wl2866d_get_id:wl2866d id is 85
[    7.439247] npu_init+0x1c/0x44
[    7.439250] do_one_initcall+0x138/0x210
[    7.453560] wl2866d_print_reg:wl2866d info is reg 3, value 85
[    7.454476] kernel_init_freeable+0x1f8/0x288
[    7.458595] wl2866d_print_reg:wl2866d info is reg 4, value 85
[    7.462536] kernel_init+0x10/0x1f8
[    7.462540] ret_from_fork+0x10/0x18
[    7.462542] ---[ end trace bce58fa0c97bea72 ]---

Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
Signed-off-by: Panchajanya1999 <panchajanya@azure-dev.live>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:26 +07:00
Tyler Nijmeh
994baac2fd
media: v4l: Use interruptible waits
Allow these tasks to be preempted in order to reduce latency.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:26 +07:00
Park Ju Hyung
de3664c9ac
msm: camera: Use kmem_cache pool for struct sync_user_payload
These get allocated and freed millions of times on this kernel tree.

Use a dedicated kmem_cache pool and avoid costly dynamic memory allocations.

Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:25 +07:00
Park Ju Hyung
ee048b3737
msm: vidc: Use kmem_cache pool for struct msm_vidc_buffer
These get allocated and freed millions of times on this kernel tree.

Use a dedicated kmem_cache pool and avoid costly dynamic memory allocations.

Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:25 +07:00
Sultan Alsawaf
ea3f44576c
msm/sde/rotator: Remove unneeded PM QoS requests
When the rotator is actually used (still an unsolved question in
computer science), these PM QoS requests block some CPUs in the LITTLE
cluster from entering deep idle because the driver assumes that display
rotating work occurs on a hardcoded set of CPUs, which is false. We
already have the IRQ PM QoS machinery for display rendering operations
that actually matter, so this cruft is unneeded.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Adithya R <gh0strider.2k18.reborn@gmail.com>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:25 +07:00
Anil Kumar Kanakanti
cb757e702d
msm: camera: cci: Fix logic to update cci clk freq
When multiple frequency slaves running on a same I2C bus,
then there is a chance of overriding I2C bus frequency
even if another I2C operation is running. This could lead
to CCI timeout at driver level. Updated synchronization logic,
to properly update I2C clock frequency, only when no other
I2C operation running.

CRs-Fixed: 2800250
Change-Id: Ia341d7cda118497bf1acea8ea59f7f03124f31c3
Signed-off-by: Anil Kumar Kanakanti <akanakan@codeaurora.org>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:25 +07:00
guocx4
c3db76993d
msm: camera: Fix out of memory issue
When initialize front sensor, allocating i2c_list failed sometimes
Then camera showed blank screen, so change kzalloc to kvzalloc to
ensure request memory success.

Change-Id: Ifcc5911c5a7eeb05641deed44edb4d96f4aa7e4b
Signed-off-by: guocx4 <guocx4@mt.com>
Reviewed-on: https://gerrit.mot.com/1300923
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Jian Zhang <zhangjo@motorola.com>
Reviewed-by: Zhenxin Xi <xizx@motorola.com>
Submit-Approved: Jira Key
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:25 +07:00
a7301c
b484580a6f
Revert "msm: camera: eeprom: Fix OOB read/write in EEPROM"
This reverts commit 53a55fb72a89684035b6b5533943f8c1769f439d.
Which causes camera failed to launch.

Change-Id: I3ab3d41cbdb8d48945319adc17a06b9368646245
Signed-off-by: a7301c <a7301c@motorola.com>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:25 +07:00
a7301c
1da57ea806
Revert "msm: camera: eeprom: Fix OOB condition for memory map count"
This reverts commit b3fd77235fa23e048ca94bd1048876aa9b432030.
So that it can pick up:
8303c7e (CR) Revert "msm: camera: eeprom: Fix OOB read/write in EEPROM"

Change-Id: Ifa8cfe4fe6876420e2cdd2e702dcc2670cd66538
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:24 +07:00
chenglong1
127dff4f94
msm: camera: Fix EEPROM device handle leak.
When EEPROM read failed, the EEPROM device handle was created,
but not released. That will cause EEPROM device acquire be rejected
till phone reboot.

Change-Id: Ife5ea9b4866f33aee137a60328530a3b4c7cb08b
Signed-off-by: chenglong1 <chenglong1@mt.com>
Reviewed-on: https://gerrit.mot.com/1313487
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Long Cheng <chengl1@motorola.com>
Reviewed-by: Zilong Zhang <zhangzl7@mt.com>
Reviewed-by: Dawei Wang <wangdw10@motorola.com>
Reviewed-by: Chuanxin Guo <guocx4@motorola.com>
Reviewed-by: Zhichao Chen <chenzc2@motorola.com>
Reviewed-by: Zhenxin Xi <xizx@motorola.com>
Submit-Approved: Jira Key
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:24 +07:00
Chris Ye
42d78d3fb6
msm-camera: Enable initial skip for dual camera synchronization
For portrait mode with dual camera synchronization, enable initial skip
to make sure two sensors both start streaming with synchronization
signal.  This fixed the portrait mode switching stability issue.

Bug: 136756925
Change-Id: I2e6e8c463bffd04da441f3da3033e6596f30e72a
Signed-off-by: Chris Ye <lzye@google.com>
Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:24 +07:00
UtsavBalar1231
158bcde7fc
msm: vidc: Remove pm_qos usage
Signed-off-by: UtsavBalar1231 <utsavbalar1231@gmail.com>
Signed-off-by: alk3pInjection <webmaster@raspii.tech>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:24 +07:00
Demon000
13df79bc1f
Revert "msm: vidc: Inline HAL_FLIP value with omx counterpart"
This break screenshot taking, by generating an image with
the wrong metadata.

The commit mentions that this patch inlines the available
image flip values with the OMX component, but the only
place I could find similar values defined are display HAL,
and they followed the old values.

enum struct DRMRotation {
  FLIP_H = 0x1,
  FLIP_V = 0x2,
  ROT_180 = FLIP_H | FLIP_V,
  ROT_90 = 0x4,
};

Bring back the old values to fix this.

This reverts commit 6601e4f5a2a2ce0040291b8ab2c9893e634a2e9f.

Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:24 +07:00
Park Ju Hyung
4f6a1ad205
msm: vidc: Avoid dynamic memory allocation for small voting data
Most voting data are rather small and can fit on the stack,
eliminating the need to allocate them dynamically. Reserve a
stack buffer for this purpose to avoid the overhead of dynamic
memory allocation.

Co-authored-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
Signed-off-by: Vishalcj17 <vishalcj@aospa.co>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:24 +07:00
Vincent Palomares
16e7a86bce
msm:sde:rotator Async suspend/resume callbacks.
Make rotator suspend/resume callbacks asynchronous, improving
suspend/resume latency.

Bug: 134703102
Change-Id: I13b306478241369acec4d1e70392f66e7a10ced9
Signed-off-by: Vincent Palomares <paillon@google.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:23 +07:00
Sultan Alsawaf
6725661568
ASoC: dsp: amrwb_in: Fix AUDIO_GET_AMRWB_ENC_CONFIG ioctl
The non-blocking if-statement here causes the AUDIO_GET_AMRWB_ENC_CONFIG
ioctl to always return -EFAULT, even upon success. Fix it by correctly
guarding the -EFAULT return value.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:23 +07:00
Panchajanya1999
417551edae
techpack/codecs: aac: Hardcode max_bitrate to 384k
Our DSP is supposed to support this.

Change-Id: Ib93ee2ec1b0c1a2fd1269f64d5f133db65d1b4a0
Suggested-by: Steve Kondik <shade@chemlab.org>
Signed-off-by: Panchajanya1999 <panchajanya@azure-dev.live>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:23 +07:00
Panchajanya1999
c580d005af
techpack/audio: tas256x: Provide correct samplerates to switch cases
Seems like Texas guys made a mistake which went un-noticed.

Change-Id: Ibff21be4040a769ab3b6466a4619fa7f4daa0d71
Signed-off-by: Panchajanya1999 <panchajanya@azure-dev.live>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:23 +07:00
celtare21
bacc1c814d
techpack: audio: Remove pm_qos usage
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:23 +07:00
Panchajanya1999
cc1e0becea
techpack/audio: sm6150: Remove pm_qos usage
Change-Id: I69e6010b20f895faf61951d97e9028c8909bada7
Signed-off-by: Panchajanya1999 <panchajanya@azure-dev.live>
Signed-off-by: Adithya R <gh0strider.2k18.reborn@gmail.com>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:23 +07:00
Rick Yiu
752da5ea14
sched: use sysctl to control energy aware feature
Energy aware feature control is previously done through debugfs,
which will be deprecated, so move the control to sysctl.

Bug: 141333728
Test: function works as expected
Change-Id: I55411d3bb2669ba1fae3225d67cdf1cf8b3b3a7f
Signed-off-by: Rick Yiu <rickyiu@google.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:55:23 +07:00
Andrzej Perczak
759fa2eaf2
dts: sdmmagpie: Fixup ddr freqs for Xiaomi devices
Our sdmmagpie variant has different CPU freqs which should be reflected
in ddr configs. Most of these aren't harmful as frequencies will be
rounded up, however, it is not a case for max freq scenario.

This commit was made upon atoll and sm6150 configs.

Signed-off-by: Andrzej Perczak <linux@andrzejperczak.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:47 +07:00
Eric Dumazet
023c7cdcef
net: increase SOMAXCONN to 4096
SOMAXCONN is /proc/sys/net/core/somaxconn default value.

It has been defined as 128 more than 20 years ago.

Since it caps the listen() backlog values, the very small value has
caused numerous problems over the years, and many people had
to raise it on their hosts after beeing hit by problems.

Google has been using 1024 for at least 15 years, and we increased
this to 4096 after TCP listener rework has been completed, more than
4 years ago. We got no complain of this change breaking any
legacy application.

Many applications indeed setup a TCP listener with listen(fd, -1);
meaning they let the system select the backlog.

Raising SOMAXCONN lowers chance of the port being unavailable under
even small SYNFLOOD attack, and reduces possibilities of side channel
vulnerabilities.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Willy Tarreau <w@1wt.eu>
Cc: Yue Cao <ycao009@ucr.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Andrzej Perczak <linux@andrzejperczak.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:47 +07:00
Maciej Żenczykowski
81092382f5
net-tcp: extend tcp_tw_reuse sysctl to enable loopback only optimization
This changes the /proc/sys/net/ipv4/tcp_tw_reuse from a boolean
to an integer.

It now takes the values 0, 1 and 2, where 0 and 1 behave as before,
while 2 enables timewait socket reuse only for sockets that we can
prove are loopback connections:
  ie. bound to 'lo' interface or where one of source or destination
  IPs is 127.0.0.0/8, ::ffff:127.0.0.0/104 or ::1.

This enables quicker reuse of ephemeral ports for loopback connections
- where tcp_tw_reuse is 100% safe from a protocol perspective
(this assumes no artificially induced packet loss on 'lo').

This also makes estblishing many loopback connections *much* faster
(allocating ports out of the first half of the ephemeral port range
is significantly faster, then allocating from the second half)

Without this change in a 32K ephemeral port space my sample program
(it just establishes and closes [::1]:ephemeral -> [::1]:server_port
connections in a tight loop) fails after 32765 connections in 24 seconds.
With it enabled 50000 connections only take 4.7 seconds.

This is particularly problematic for IPv6 where we only have one local
address and cannot play tricks with varying source IP from 127.0.0.0/8
pool.

Signed-off-by: Maciej Żenczykowski <maze@google.com>
Cc: Neal Cardwell <ncardwell@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Cc: Wei Wang <weiwan@google.com>
Change-Id: I0377961749979d0301b7b62871a32a4b34b654e1
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Andrzej Perczak <linux@andrzejperczak.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:47 +07:00
Eric Dumazet
72f63196e2
tcp: increase tcp_max_syn_backlog max value
tcp_max_syn_backlog default value depends on memory size
and TCP ehash size. Before this patch, the max value
was 2048 [1], which is considered too small nowadays.

Increase it to 4096 to match the recent SOMAXCONN change.

[1] This is with TCP ehash size being capped to 524288 buckets.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Willy Tarreau <w@1wt.eu>
Cc: Yue Cao <ycao009@ucr.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Andrzej Perczak <linux@andrzejperczak.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:46 +07:00
Petri Gynther
d7d60fe052
defconfig: Simplify log buffer allocation
Switch to 1 MiB static log buffer in __log_buf[]:
  define __LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT)
  static char __log_buf[__LOG_BUF_LEN] __aligned(LOG_ALIGN);

instead of having the log buffer reallocated at boot by:
  setup_log_buf()
    log_buf_add_cpu()
      log_buf_len_update()
    new_log_buf = memblock_virt_alloc_nopanic()

There is no need to do this reallocation for the log buffer.

Signed-off-by: Petri Gynther <pgynther@google.com>
Signed-off-by: Andrzej Perczak <linux@andrzejperczak.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:25 +07:00
Kuniyuki Iwashima
99bbec5617
BACKPORT: af_unix: Cut unix_validate_addr() out of unix_mkname().
unix_mkname() tests socket address length and family and does some
processing based on the address type.  It is called in the early stage,
and therefore some instructions are redundant and can end up in vain.

The address length/family tests are done twice in unix_bind().  Also, the
address type is rechecked later in unix_bind() and unix_find_other(), where
we can do the same processing.  Moreover, in the BSD address case, the hash
is set to 0 but never used and confusing.

This patch moves the address tests out of unix_mkname(), and the following
patches move the other part into appropriate places and remove
unix_mkname() finally.

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:17 +07:00
Kuniyuki Iwashima
15c720d53f
BACKPORT: af_unix: Pass struct sock to unix_autobind().
We do not use struct socket in unix_autobind() and pass struct sock to
unix_bind_bsd() and unix_bind_abstract().  Let's pass it to unix_autobind()
as well.

Also, this patch fixes these errors by checkpatch.pl.

  ERROR: do not use assignment in if condition
  #1795: FILE: net/unix/af_unix.c:1795:
  +	if (test_bit(SOCK_PASSCRED, &sock->flags) && !u->addr

  CHECK: Logical continuations should be on the previous line
  #1796: FILE: net/unix/af_unix.c:1796:
  +	if (test_bit(SOCK_PASSCRED, &sock->flags) && !u->addr
  +	    && (err = unix_autobind(sock)) != 0)

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:17 +07:00
Kuniyuki Iwashima
22f18e1dff
BACKPORT: af_unix: Use offsetof() instead of sizeof().
The length of the AF_UNIX socket address contains an offset to the member
sun_path of struct sockaddr_un.

Currently, the preceding member is just sun_family, and its type is
sa_family_t and resolved to short.  Therefore, the offset is represented by
sizeof(short).  However, it is not clear and fragile to changes in struct
sockaddr_storage or sockaddr_un.

This commit makes it clear and robust by rewriting sizeof() with
offsetof().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:17 +07:00
Vincent Whitchurch
9d512a46d3
BACKPORT: af_unix: fix regression in read after shutdown
On kernels before v5.15, calling read() on a unix socket after
shutdown(SHUT_RD) or shutdown(SHUT_RDWR) would return the data
previously written or EOF.  But now, while read() after
shutdown(SHUT_RD) still behaves the same way, read() after
shutdown(SHUT_RDWR) always fails with -EINVAL.

This behaviour change was apparently inadvertently introduced as part of
a bug fix for a different regression caused by the commit adding sockmap
support to af_unix, commit 94531cfcbe79c359 ("af_unix: Add
unix_stream_proto for sockmap").  Those commits, for unclear reasons,
started setting the socket state to TCP_CLOSE on shutdown(SHUT_RDWR),
while this state change had previously only been done in
unix_release_sock().

Restore the original behaviour.  The sockmap tests in
tests/selftests/bpf continue to pass after this patch.

Fixes: d0c6416bd7091647f60 ("unix: Fix an issue in unix_shutdown causing the other end read/write failures")
Link: https://lore.kernel.org/lkml/20211111140000.GA10779@axis.com/
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
Tested-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:17 +07:00
Jiang Wang
14e39dbbbc
BACKPORT: unix: Fix an issue in unix_shutdown causing the other end read/write failures
Commit 94531cfcbe79 ("af_unix: Add unix_stream_proto for sockmap") sets
unix domain socket peer state to TCP_CLOSE in unix_shutdown. This could
happen when the local end is shutdown but the other end is not. Then,
the other end will get read or write failures which is not expected.
Fix the issue by setting the local state to shutdown.

Fixes: 94531cfcbe79 ("af_unix: Add unix_stream_proto for sockmap")
Reported-by: Casey Schaufler <casey@schaufler-ca.com>
Suggested-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Jiang Wang <jiang.wang@bytedance.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Casey Schaufler <casey@schaufler-ca.com>
Reviewed-by: Casey Schaufler <casey@schaufler-ca.com>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20211004232530.2377085-1-jiang.wang@bytedance.com
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:17 +07:00
Eric Dumazet
bf474237db
BACKPORT: af_unix: fix potential NULL deref in unix_dgram_connect()
syzbot was able to trigger NULL deref in unix_dgram_connect() [1]

This happens in

	if (unix_peer(sk))
		sk->sk_state = other->sk_state = TCP_ESTABLISHED; // crash because @other is NULL

Because locks have been dropped, unix_peer() might be non NULL,
while @other is NULL (AF_UNSPEC case)

We need to move code around, so that we no longer access
unix_peer() and sk_state while locks have been released.

[1]
general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
CPU: 0 PID: 10341 Comm: syz-executor239 Not tainted 5.14.0-rc7-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:unix_dgram_connect+0x32a/0xc60 net/unix/af_unix.c:1226
Code: 00 00 45 31 ed 49 83 bc 24 f8 05 00 00 00 74 69 e8 eb 5b a6 f9 48 8d 7d 12 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 48 89 fa 83 e2 07 38 d0 7f 08 84 c0 0f 85 e0 07 00 00
RSP: 0018:ffffc9000a89fcd8 EFLAGS: 00010202
RAX: dffffc0000000000 RBX: 0000000000000004 RCX: 0000000000000000
RDX: 0000000000000002 RSI: ffffffff87cf4ef5 RDI: 0000000000000012
RBP: 0000000000000000 R08: 0000000000000000 R09: ffff88802e1917c3
R10: ffffffff87cf4eba R11: 0000000000000001 R12: ffff88802e191740
R13: 0000000000000000 R14: ffff88802e191d38 R15: ffff88802e1917c0
FS:  00007f3eb0052700(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000004787d0 CR3: 0000000029c0a000 CR4: 00000000001506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 __sys_connect_file+0x155/0x1a0 net/socket.c:1890
 __sys_connect+0x161/0x190 net/socket.c:1907
 __do_sys_connect net/socket.c:1917 [inline]
 __se_sys_connect net/socket.c:1914 [inline]
 __x64_sys_connect+0x6f/0xb0 net/socket.c:1914
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x446a89
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 a1 15 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f3eb0052208 EFLAGS: 00000246 ORIG_RAX: 000000000000002a
RAX: ffffffffffffffda RBX: 00000000004cc4d8 RCX: 0000000000446a89
RDX: 000000000000006e RSI: 0000000020000180 RDI: 0000000000000003
RBP: 00000000004cc4d0 R08: 00007f3eb0052700 R09: 0000000000000000
R10: 00007f3eb0052700 R11: 0000000000000246 R12: 00000000004cc4dc
R13: 00007ffd791e79cf R14: 00007f3eb0052300 R15: 0000000000022000
Modules linked in:
---[ end trace 4eb809357514968c ]---
RIP: 0010:unix_dgram_connect+0x32a/0xc60 net/unix/af_unix.c:1226
Code: 00 00 45 31 ed 49 83 bc 24 f8 05 00 00 00 74 69 e8 eb 5b a6 f9 48 8d 7d 12 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 48 89 fa 83 e2 07 38 d0 7f 08 84 c0 0f 85 e0 07 00 00
RSP: 0018:ffffc9000a89fcd8 EFLAGS: 00010202
RAX: dffffc0000000000 RBX: 0000000000000004 RCX: 0000000000000000
RDX: 0000000000000002 RSI: ffffffff87cf4ef5 RDI: 0000000000000012
RBP: 0000000000000000 R08: 0000000000000000 R09: ffff88802e1917c3
R10: ffffffff87cf4eba R11: 0000000000000001 R12: ffff88802e191740
R13: 0000000000000000 R14: ffff88802e191d38 R15: ffff88802e1917c0
FS:  00007f3eb0052700(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ffd791fe960 CR3: 0000000029c0a000 CR4: 00000000001506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400

Fixes: 83301b5367a9 ("af_unix: Set TCP_ESTABLISHED for datagram sockets too")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Cong Wang <cong.wang@bytedance.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:17 +07:00
Cong Wang
fab851e398
BACKPORT: af_unix: Add a dummy ->close() for sockmap
Unlike af_inet, unix_proto is very different, it does not even
have a ->close(). We have to add a dummy implementation to
satisfy sockmap. Normally it is just a nop, it is introduced only
for sockmap to replace it.

Signed-off-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210704190252.11866-6-xiyou.wangcong@gmail.com
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:16 +07:00
Cong Wang
91f6fc0c04
BACKPORT: af_unix: Set TCP_ESTABLISHED for datagram sockets too
Currently only unix stream socket sets TCP_ESTABLISHED,
datagram socket can set this too when they connect to its
peer socket. At least __ip4_datagram_connect() does the same.

This will be used to determine whether an AF_UNIX datagram
socket can be redirected to in sockmap.

Signed-off-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210704190252.11866-5-xiyou.wangcong@gmail.com
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:16 +07:00
Cong Wang
d38cddd8d1
BACKPORT: af_unix: Implement ->read_sock() for sockmap
Implement ->read_sock() for AF_UNIX datagram socket, it is
pretty much similar to udp_read_sock().

Signed-off-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210704190252.11866-4-xiyou.wangcong@gmail.com
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:16 +07:00
Al Viro
01639c2cf8
BACKPORT: __unix_find_socket_byname(): don't pass hash and type separately
We only care about exclusive or of those, so pass that directly.
Makes life simpler for callers as well...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:16 +07:00
Al Viro
c02dc49940
BACKPORT: unix_bind(): take BSD and abstract address cases into new helpers
unix_bind_bsd() and unix_bind_abstract() respectively.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:16 +07:00
Al Viro
eae9aedaf1
BACKPORT: unix_bind(): separate BSD and abstract cases
We do get some duplication that way, but it's minor compared to
parts that are different.  What we get is an ability to change
locking in BSD case without making failure exits very hard to
follow.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:16 +07:00
Al Viro
6ee63fc31e
BACKPORT: unix_bind(): allocate addr earlier
makes it easier to massage; we do pay for that by extra work
(kmalloc+memcpy+kfree) in some error cases, but those are not
on the hot paths anyway.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:16 +07:00
Al Viro
014fd34ebb
BACKPORT: af_unix: take address assignment/hash insertion into a new helper
Duplicated logics in all bind variants (autobind, bind-to-path,
bind-to-abstract) gets taken into a common helper.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:15 +07:00
gushengxian
ef1d50304a
BACKPORT: af_unix: remove the repeated word "and"
Remove the repeated word "and".

Signed-off-by: gushengxian <gushengxian@yulong.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:15 +07:00
Or Cohen
5d161b6f7e
BACKPORT: net/af_unix: Remove unused old_pid variable
Commit 109f6e39fa07c48f5801 ("af_unix: Allow SO_PEERCRED
to work across namespaces.") introduced the old_pid variable
in unix_listen, but it's never used.
Remove the declaration and the call to put_pid.

Signed-off-by: Or Cohen <orcohen@paloaltonetworks.com>
Link: https://lore.kernel.org/r/20201011153527.18628-1-orcohen@paloaltonetworks.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:15 +07:00
Jing Xiangfeng
059df2ec23
BACKPORT: net: unix: remove redundant assignment to variable 'err'
After commit 37ab4fa7844a ("net: unix: allow bind to fail on mutex lock"),
the assignment to err is redundant. So remove it.

Signed-off-by: Jing Xiangfeng <jingxiangfeng@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-26 14:54:15 +07:00