Skip to content

Commit 117eab5

Browse files
committed
Merge tag 'vfs-6.17-rc1.coredump' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull coredump updates from Christian Brauner: "This contains an extension to the coredump socket and a proper rework of the coredump code. - This extends the coredump socket to allow the coredump server to tell the kernel how to process individual coredumps. This allows for fine-grained coredump management. Userspace can decide to just let the kernel write out the coredump, or generate the coredump itself, or just reject it. * COREDUMP_KERNEL The kernel will write the coredump data to the socket. * COREDUMP_USERSPACE The kernel will not write coredump data but will indicate to the parent that a coredump has been generated. This is used when userspace generates its own coredumps. * COREDUMP_REJECT The kernel will skip generating a coredump for this task. * COREDUMP_WAIT The kernel will prevent the task from exiting until the coredump server has shutdown the socket connection. The flexible coredump socket can be enabled by using the "@@" prefix instead of the single "@" prefix for the regular coredump socket: @@/run/systemd/coredump.socket - Cleanup the coredump code properly while we have to touch it anyway. Split out each coredump mode in a separate helper so it's easy to grasp what is going on and make the code easier to follow. The core coredump function should now be very trivial to follow" * tag 'vfs-6.17-rc1.coredump' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: (31 commits) cleanup: add a scoped version of CLASS() coredump: add coredump_skip() helper coredump: avoid pointless variable coredump: order auto cleanup variables at the top coredump: add coredump_cleanup() coredump: auto cleanup prepare_creds() cred: add auto cleanup method coredump: directly return coredump: auto cleanup argv coredump: add coredump_write() coredump: use a single helper for the socket coredump: move pipe specific file check into coredump_pipe() coredump: split pipe coredumping into coredump_pipe() coredump: move core_pipe_count to global variable coredump: prepare to simplify exit paths coredump: split file coredumping into coredump_file() coredump: rename do_coredump() to vfs_coredump() selftests/coredump: make sure invalid paths are rejected coredump: validate socket path in coredump_parse() coredump: don't allow ".." in coredump socket path ...
2 parents 7879d7a + 5c21c5f commit 117eab5

File tree

14 files changed

+2246
-607
lines changed

14 files changed

+2246
-607
lines changed

Documentation/security/credentials.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,5 +555,5 @@ the VFS, and that can be done by calling into such as ``vfs_mkdir()`` with a
555555
different set of credentials. This is done in the following places:
556556

557557
* ``sys_faccessat()``.
558-
* ``do_coredump()``.
558+
* ``vfs_coredump()``.
559559
* nfs4recover.c.

Documentation/translations/zh_CN/security/credentials.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,5 +475,5 @@ const指针上操作,因此不需要进行类型转换,但需要临时放弃
475475
如 ``vfs_mkdir()`` 来实现。以下是一些进行此操作的位置:
476476

477477
* ``sys_faccessat()``.
478-
* ``do_coredump()``.
478+
* ``vfs_coredump()``.
479479
* nfs4recover.c.

drivers/base/firmware_loader/main.c

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -822,26 +822,6 @@ static void fw_log_firmware_info(const struct firmware *fw, const char *name,
822822
{}
823823
#endif
824824

825-
/*
826-
* Reject firmware file names with ".." path components.
827-
* There are drivers that construct firmware file names from device-supplied
828-
* strings, and we don't want some device to be able to tell us "I would like to
829-
* be sent my firmware from ../../../etc/shadow, please".
830-
*
831-
* Search for ".." surrounded by either '/' or start/end of string.
832-
*
833-
* This intentionally only looks at the firmware name, not at the firmware base
834-
* directory or at symlink contents.
835-
*/
836-
static bool name_contains_dotdot(const char *name)
837-
{
838-
size_t name_len = strlen(name);
839-
840-
return strcmp(name, "..") == 0 || strncmp(name, "../", 3) == 0 ||
841-
strstr(name, "/../") != NULL ||
842-
(name_len >= 3 && strcmp(name+name_len-3, "/..") == 0);
843-
}
844-
845825
/* called from request_firmware() and request_firmware_work_func() */
846826
static int
847827
_request_firmware(const struct firmware **firmware_p, const char *name,
@@ -862,6 +842,17 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
862842
goto out;
863843
}
864844

845+
846+
/*
847+
* Reject firmware file names with ".." path components.
848+
* There are drivers that construct firmware file names from
849+
* device-supplied strings, and we don't want some device to be
850+
* able to tell us "I would like to be sent my firmware from
851+
* ../../../etc/shadow, please".
852+
*
853+
* This intentionally only looks at the firmware name, not at
854+
* the firmware base directory or at symlink contents.
855+
*/
865856
if (name_contains_dotdot(name)) {
866857
dev_warn(device,
867858
"Firmware load for '%s' refused, path contains '..' component\n",

0 commit comments

Comments
 (0)