Methods for configuring file access permissions and electronic devices
By modifying the access control list at the operating system kernel level and configuring read, write, and execute permissions for applications and users, the problem of insufficient data isolation between different applications in existing technologies is solved, achieving higher security and data protection.
Patent Information
- Application Number
- CN202111603395.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-24
- Publication Date
- 2026-11-10
- Estimated Expiration
- 2041-12-24
AI Technical Summary
In existing operating systems, file access permissions for different applications are configured at the user level, which poses security risks and fails to effectively isolate data from different applications, leading to data leaks and security risks.
By modifying the access control list of files at the operating system kernel level, configuring read, write, and execute permissions for different applications and users, and using system calls and hook functions to reduce the impact on kernel performance, a security policy can be implemented.
Secure isolation of file access permissions is implemented at the kernel level, reducing the risk of data leakage and improving the security of the operating system.
Smart Images

Figure CN116340910B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of operating systems, and more particularly to methods for configuring file access permissions and electronic devices. Background Technology
[0002] With the development of electronic technology, more and more electronic devices are becoming part of consumers' daily lives. Consumers can install multiple applications on their electronic devices to meet the different needs of different users.
[0003] Most existing operating systems' file systems support configuring file access permissions in file attributes. These permissions include read, write, and execute permissions. However, the specific implementation of these permissions varies across different operating systems. For example, in Linux, the file owner, group, and other users each have different permissions.
[0004] In other operating systems based on Linux, especially consumer-facing operating systems, consumers often perform operations on electronic devices through different applications or under different users. For example, in Android, different read and write permissions can be assigned to different applications.
[0005] However, assigning different read and write permissions to different applications is implemented at the user level, not at the kernel level, which poses a security risk. Summary of the Invention
[0006] This application provides a method for configuring file access permissions and an electronic device, relating to the field of operating systems. The method for configuring file access permissions provided in this application allows for configuring different access permissions for a file by modifying its access control list. These access permissions include read permissions, write permissions, execute permissions, and read access permissions for different applications and / or users.
[0007] In a first aspect, embodiments of this application provide a method for configuring file access permissions. The method includes: a first owner passing a first parameter to an operating system via a first system call; the first parameter includes a first identifier and a first permission; the first permission includes at least one of read permission, write permission, execute permission, and read access control list permission; the first identifier includes an application identifier and / or a user identifier; after receiving the first parameter, the operating system determines that the first file is in the virtual directory corresponding to the first identifier, and then the operating system modifies the access control list of the first file according to the first parameter; the access control list of the first file is used to determine the access permissions of the first file.
[0008] In the above embodiments, the identifier and permissions can be passed to the operating system through a first system call, and the operating system can then add the corresponding parameters to the access control list to configure the access permissions.
[0009] In conjunction with some embodiments of the first aspect, in some embodiments, the first system call is a system call for writing to an access control list; the method further includes: if the operating system determines that the declared value of the first system call is a predetermined value, determining that the parameter passed by the first system call is the first parameter.
[0010] In the above embodiments, by inserting hook functions into system calls that write access control lists and adding new declaration values, such as "user.sechmdfs", when the declaration value is "user.sechmdfs", it indicates that the parameter passed by the system call is the first parameter. This modification makes it unknown to other modules of the operating system kernel, thereby reducing the impact on the performance of the operating system kernel.
[0011] In conjunction with some embodiments of the first aspect, in some embodiments, after the operating system receives the first parameter, and after the operating system determines that the first file is not in the virtual directory corresponding to the first identifier, the operating system modifies the access control list of the first file according to the first parameter, and saves the second parameter in the access control list of the first file. The second parameter is used to determine whether to perform the operation of creating or deleting a hard link; the operating system creates or deletes a hard link of the first file in the virtual directory corresponding to the first identifier based on the second parameter.
[0012] In the above embodiments, after receiving the first parameter, the operating system also needs to determine whether the file is in the virtual directory of the application and / or user indicated by the first parameter, and then determine whether a hard link needs to be created or deleted for the file.
[0013] In conjunction with some embodiments of the first aspect, in some embodiments, the access permissions of the first file are queried through a second system call; during the process of querying the access permissions of the first file through the second system call, after the operating system determines that the declared value of the second system call is a conventional value, the operating system determines a third parameter, the third parameter including one or more access control list entries in the access control list of the first file; the operating system returns the third parameter.
[0014] In the above embodiments, the application and / or user can query file access permissions.
[0015] In conjunction with some embodiments of the first aspect, in some embodiments, before the operating system returns the third parameter, the operating system further includes: converting the one or more access control list entries into a readable format.
[0016] In the above embodiments, since the first parameter is configured by the operating system and the operating system modifies the access control list according to the first parameter, the operating system can convert the file's access control list into a readable format and return it to the upper-layer application and / or user.
[0017] In conjunction with some embodiments of the first aspect, in some embodiments, the length of the access control list entries of the access control list of the first file is fixed, or the length of the access control list entries of the access control list of the first file is variable.
[0018] In the above embodiments, since the access control list of the file needs to be modified, the length of the access control list needs to be redesigned, which can be either fixed-length or variable-length.
[0019] In conjunction with some embodiments of the first aspect, in some embodiments, the length of the access control list entries of the access control list of the first file is variable; the access control list entries of the access control list of the first file include a first field and a second field; the first field is used to indicate the length of the application identifier, and the second field is used to indicate the length of the user identifier.
[0020] In the above embodiments, when the length of the access control list entries of the first file's access control list is not fixed, the length of the access control list can be determined by the first field and the second field to avoid wasting memory.
[0021] Secondly, embodiments of this application provide an electronic device, which includes: one or more processors and a memory; the memory is coupled to the one or more processors, and the memory is used to store computer program code, the computer program code including computer instructions, and the one or more processors call the computer instructions to cause the electronic device to execute: a first owner passes a first parameter to the operating system through a first system call, the first parameter including: a first identifier and a first permission; the first permission includes at least one of read permission, write permission, execute permission, and read access control list permission, the first identifier including: application identifier and / or user identifier; after receiving the first parameter, the operating system determines that the first file is in the virtual directory corresponding to the first identifier, and then the operating system modifies the access control list of the first file according to the first parameter, the access control list of the first file being used to determine the access permissions of the first file.
[0022] In the above embodiments, the identifier and permissions can be passed to the operating system through a first system call, and the operating system can then add the corresponding parameters to the access control list to configure the access permissions.
[0023] In conjunction with some embodiments of the second aspect, in some embodiments, the first system call is a system call for writing to an access control list; the method further includes: if the operating system determines that the declared value of the first system call is a predetermined value, determining that the parameter passed by the first system call is the first parameter.
[0024] In conjunction with some embodiments of the second aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the electronic device to execute: after the operating system receives the first parameter, after the operating system determines that the first file is not in the virtual directory corresponding to the first identifier, the operating system modifies the access control list of the first file according to the first parameter, and saves the second parameter in the access control list of the first file, the second parameter being used to determine whether to perform the operation of creating or deleting a hard link; the operating system creates or deletes a hard link of the first file in the virtual directory corresponding to the first identifier based on the second parameter.
[0025] In conjunction with some embodiments of the second aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the electronic device to perform: querying the access permissions of the first file via a second system call; during the process of querying the access permissions of the first file via the second system call, after the operating system determines that the declared value of the second system call is a conventional value, the operating system determines a third parameter, the third parameter including one or more access control list entries in the access control list of the first file; the operating system returns the third parameter.
[0026] In conjunction with some embodiments of the second aspect, in some embodiments, the one or more processors are also configured to invoke computer instructions to cause the electronic device to execute: the operating system converts the one or more access control list entries into a readable format.
[0027] In conjunction with some embodiments of the second aspect, in some embodiments, the length of the access control list entries of the access control list of the first file is fixed, or the length of the access control list entries of the access control list of the first file is variable.
[0028] In conjunction with some embodiments of the second aspect, in some embodiments, the length of the access control list entries of the access control list of the first file is variable; the access control list entries of the access control list of the first file include a first field and a second field; the first field is used to indicate the length of the application identifier, and the second field is used to indicate the length of the user identifier.
[0029] Thirdly, embodiments of this application provide a chip system applied to an electronic device. The chip system includes one or more processors, which are used to invoke computer instructions to cause the electronic device to perform the methods described in the first aspect and any possible implementation thereof.
[0030] Fourthly, embodiments of this application provide a computer program product containing instructions that, when the computer program product is run on an electronic device, cause the electronic device to perform the method described in the first aspect and any possible implementation thereof.
[0031] Fifthly, embodiments of this application provide a computer-readable storage medium including instructions that, when executed on an electronic device, cause the electronic device to perform the method described in the first aspect and any possible implementation thereof.
[0032] It is understood that the electronic device provided in the second aspect, the chip system provided in the third aspect, the computer program product provided in the fourth aspect, and the computer storage medium provided in the fifth aspect are all used to execute the methods provided in the embodiments of this application. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods, and will not be repeated here. Attached Figure Description
[0033] Figure 1A , Figure 1B This is an exemplary schematic diagram illustrating the read / write permissions of external storage media for different applications provided in the embodiments of this application.
[0034] Figure 2 An exemplary schematic diagram illustrating the access permissions of files provided in this application embodiment.
[0035] Figure 3 An exemplary schematic diagram of a method for configuring file access permissions provided in an embodiment of this application.
[0036] Figure 4A This is an exemplary schematic diagram of an access control list provided in an embodiment of this application.
[0037] Figure 4B Another exemplary schematic diagram of the access control list provided in the embodiments of this application.
[0038] Figure 5 An exemplary schematic diagram of an access control list storing a second parameter provided for an embodiment of this application.
[0039] Figure 6 This is an exemplary schematic diagram illustrating the reading of access permissions from an access control list, as provided in an embodiment of this application.
[0040] Figure 7A This is an exemplary schematic diagram of a synchronization access control list provided in an embodiment of this application.
[0041] Figure 7B Another exemplary schematic diagram of the synchronization access control list provided in the embodiments of this application.
[0042] Figure 8 This is an exemplary schematic diagram of the electronic device hardware architecture provided in the embodiments of this application.
[0043] Figure 9A , Figure 9B , Figure 9C , Figure 9D This is an exemplary schematic diagram of the electronic device software architecture provided in the embodiments of this application. Detailed Implementation
[0044] The terminology used in the following embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification and appended claims of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to include the plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this application refers to and includes any or all possible combinations of one or more of the listed items.
[0045] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.
[0046] The term "user interface (UI)" used in the following embodiments of this application refers to the medium interface through which an application or operating system interacts and exchanges information with the user. It realizes the conversion between the internal form of information and the form that the user can accept. The user interface is source code written in a specific computer language such as Java or Extensible Markup Language (XML). The interface source code is parsed and rendered on the electronic device, ultimately presenting content that the user can recognize. A common form of user interface is the graphical user interface (GUI), which refers to a user interface related to computer operation displayed graphically. It can be visible interface elements such as text, icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, and widgets displayed on the screen of an electronic device.
[0047] When an electronic device first runs an application, or during the application's execution, it may request permissions from the user, such as read / write permissions on external storage. For example, in the Android operating system, application developers can use commands such as "<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" / > "To grant an application permission to read data from external storage media, similarly, application developers can use commands such as..."<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" / > "Request permission for the application to write data on external storage media."
[0048] When multiple applications are configured with read / write permissions on external storage media, the data of different applications will be exposed to each other, which can lead to security risks such as data leakage and malicious attacks.
[0049] Figure 1A , Figure 1B This is an exemplary schematic diagram illustrating the read / write permissions of external storage media for different applications provided in the embodiments of this application.
[0050] like Figure 1A As shown, the data security storage card, USB flash drive, mobile hard drive, and other electronic devices that establish a telecommunications connection with electronic device 1 can all be external storage media in the embodiments of this application.
[0051] The applications on electronic device 1 include: Application 1, Application 2, Map, Navigation, Calendar, Gallery, Call, etc. Different applications can be configured with different external storage media read / write permissions. For example, Application 1 may have read / write permissions allowed, Application 2 may have read / write permissions allowed, Call may have read / write permissions not allowed, and Gallery may have read / write permissions allowed.
[0052] like Figure 1B As shown, since both application 1 and application 2 have read and write permissions on their external storage media, application 1 can modify the data stored by application 2 on the external storage media, and application 2 can also modify the data stored by application 1 on the external storage media.
[0053] Clearly, in this situation, the data from different applications is not isolated and can be modified by each other, making it impossible to guarantee the security of the application data.
[0054] Furthermore, the Android operating system also provides instructions such as "Context.MODE_PRIVATE" and "Context.MODE_WORLD_READABLE" to configure the read and write permissions of files saved by an application for other applications.
[0055] Clearly, the aforementioned instructions can only distinguish between the read and write permissions of the application itself and other applications. However, the Android operating system does not provide instructions that allow saved files to be readable or writable by some applications while being neither readable nor writable by others.
[0056] Furthermore, the read / write permission configuration methods provided by these instructions only apply to user-level security policies and pose security risks. For example, in a distributed scenario, electronic device 1 and electronic device 2 establish a telecommunications connection, and both electronic device 1 and electronic device 2 run application 1. Electronic device 1 is used by consumer 1, and electronic device 2 is used by consumer 2. Data stored by application 1 on electronic device 1 for consumer 1 can be read by application 1 on electronic device 2 and thus obtained by consumer 2.
[0057] To address the aforementioned data security issues, this application provides a file access permission configuration method that allows configuration of access permissions in the file's extended attributes. These access permissions include read permissions, write permissions, and execute permissions for different applications and / or different users. Figure 2As shown. Access permissions may also include whether applications and / or users can view files, etc., which are not limited here.
[0058] Figure 2 An exemplary schematic diagram illustrating the access permissions of files provided in this application embodiment.
[0059] like Figure 2 As shown, the extended attributes of file 1 include access control lists (acl, access controllists), which include access permissions for different applications and / or users.
[0060] exist Figure 2 As shown, the operating system can determine whether to respond to different applications and / or users' read, write, or execute requests for the file based on the file's access control list.
[0061] Understandably, by configuring access permissions for different applications or users in the file's access control list, a security policy is implemented at the kernel level to protect data security.
[0062] The following is an exemplary description of a method for configuring file access permissions provided in an embodiment of this application.
[0063] First, the file access permission configuration method provided in this application embodiment can configure access permissions for different applications and / or different users for a file. These access permissions include read permissions, write permissions, and execute permissions.
[0064] Secondly, the file access permission configuration method provided in this application's embodiments configures access permissions for different applications and / or users by modifying the access control list in the file's extended attributes.
[0065] To reduce the impact of the virtual directory creation method provided in this application embodiment on the performance of the operating system, the virtual directory creation method provided in this application embodiment adds hook functions at appropriate locations in the virtual file system (VFS), thereby reducing the modification to the operating system and minimizing the impact on the performance of the operating system kernel.
[0066] The following is combined Figure 3 The content shown exemplifies the method for configuring file access permissions provided in the embodiments of this application.
[0067] Figure 3 An exemplary schematic diagram of a method for configuring file access permissions provided in an embodiment of this application.
[0068] like Figure 3As shown, the method for configuring file access permissions provided in this application embodiment includes:
[0069] S301: User-level applications and / or users pass the first parameter through a system call. The operating system obtains the first parameter, which is used to configure the access permissions of the first file.
[0070] The file owner can configure access permissions for their files via system calls. In this context, the user-level application and / or user is the file owner. The file owner passes the first parameter to the operating system through the system call. This first parameter determines the file's access permissions.
[0071] The first parameter includes: a user identifier and / or an application identifier, as well as the user's and / or application's access permissions to the file. The user identifier can be a username, such as a consumer's email address or phone number, and is not limited here. For example, the user identifier could be xxx@example.com. The application identifier (application identifier) can be the application's package name, etc., and is not limited here. For example, The package name is "com.huawei.wallet". The package name is "com.autonavi.minimap". Users can be system accounts logged in on electronic devices, such as... account, Accounts, etc., are not specified here.
[0072] The first parameter also includes a first identifier, which includes the access permissions to be configured.
[0073] Optionally, in some embodiments of this application, the system call can be the `setxattr()` method inserted into the first hook function. The format of the `setxattr()` method can be `setxattr(name, value, size, flags)`. The `name` parameter can be "user.sechmdfs". When the `name` parameter is "user.sechmdfs", the first hook function is triggered to modify the access list. The first hook function parses the `value` parameter, which can be in the format "application name:username:permissions", for example, "app1:acc1:rw". "app1:acc1:rw" indicates that application 1 (app1) and user 1 (acc1) have read and write permissions (rw). "app1:acc1:rw" is the first parameter in this embodiment of the application, and this first parameter is passed to the operating system through the existing system call `setxattr()` method.
[0074] Table 1 is an exemplary schematic table of the value parameter and permissions in the setxattr() method provided in the embodiments of this application.
[0075] Table 1
[0076]
[0077]
[0078] As shown in Table 1, when the value is "app1::r", it means granting read permission to app1 (application 1); when the value is "app1::x", it means granting execute permission to app1 (application 1); when the value is "app1::rw", it means granting read and write permissions to app1 (application 1); when the value is "app1::rwx", it means granting read, write, and execute permissions to app1 (application 1); when the value is ":acc1:w", it means granting write permission to all applications under acc1 (user 1); when the value is ":acc1:rwx", it means granting write, read, and execute permissions to all applications under acc1 (user 1); when the value is "app1:acc1:rwx", it means granting write, read, and execute permissions to app1 (application 1) under acc1 (user 1).
[0079] It is worth noting that the content in Table 1 is only an example of the value that can be taken in the setxattr() method. The value can also be other values and is not limited to the content shown in Table 1.
[0080] Optionally, if the access permissions of file 1 include read, write, and execute permissions for non-owner applications and / or users, a hard link to the file can be created in the virtual directory corresponding to the application and / or user.
[0081] Understandably, reusing the `setxattr()` method can reduce modifications to the operating system kernel, thereby minimizing the impact on kernel performance. This reuse can be achieved by adding a new input parameter, "user.sechmdfs", to the `name` parameter, as mentioned above.
[0082] Optionally, in some embodiments of this application, a new system call may be added, which can be used for access permissions of the configuration file.
[0083] Optionally, in some embodiments of this application, after a file is created but before access permissions are configured, the access control list of the file may include access permission assignments to the owner. The access permissions of the file to the owner may be default access permissions, which may include read permissions, write permissions, and execute permissions.
[0084] S302: The operating system determines whether the first file is in the virtual directory corresponding to the application and / or user.
[0085] The operating system determines whether the first file is in the virtual directory corresponding to the application and / or user. If yes, it proceeds to step S304; otherwise, it proceeds to step S303. The virtual directory can also be referred to as a sandbox.
[0086] If the first file is located in the virtual directory corresponding to the application and / or user, then the file is not visible to other applications and / or users. Even if the file owner has assigned read and write permissions to other applications and / or users, because the file is invisible to them, they still cannot read or write it.
[0087] S303: Modify the access control list of the first file according to the first parameter.
[0088] If the operating system determines that the first file is not in the virtual directory corresponding to the application and / or user, it will configure the permissions of the first file according to the access control list of the first file as the first parameter.
[0089] Step S303 can be executed in the first hook function.
[0090] The format of an access control list can be as follows: Figure 4A , Figure 4B As shown.
[0091] Figure 4A This is an exemplary schematic diagram of an access control list provided in an embodiment of this application.
[0092] like Figure 4A As shown, an entry in an access control list can include an application identifier, a user identifier, and a permission identifier. The length of an access control list entry can be variable and not fixed; its length is equal to the length of the user identifier, the length of the user identifier, and the length of the permission identifier.
[0093] The permission identifier can be "r", "w", "x" or any combination of the three identifiers, where "r" indicates read permission, "w" indicates write permission, and "x" indicates execute permission.
[0094] Alternatively, in some embodiments of this application, an entry in the access control list can also be of fixed length. When the sum of the lengths of the application identifier, user identifier, and permission identifier is less than the total length of the access control list entry, zeros can be added after the permission identifier. Alternatively, in some embodiments of this application, the application identifier, user identifier, and permission identifier can also be configured to have fixed lengths. When the length of the application identifier of application 1 is less than the application identifier length, zeros can also be added. Similar zero-padding operations can also be performed on the user identifier and permission identifier.
[0095] The zeros used to supplement the length can also be other placeholders, which are not limited here.
[0096] Figure 4B Another exemplary schematic diagram of the access control list provided in the embodiments of this application.
[0097] To further reduce the waste of storage resources caused by fixed-length access control lists, and thus further mitigate the impact on kernel performance, optionally, in some embodiments of this application, the access control list can be as follows: Figure 4B The streaming format.
[0098] like Figure 4B As shown, the access control list entries include field 1, application identifier, field 2, user identifier, and permission identifier. Field 1 indicates the length of the application identifier, and field 2 indicates the length of the user identifier.
[0099] The operating system kernel reads, such as Figure 4B When accessing an access control list entry as shown, the system first reads field 1 to determine the length of the user identifier as n, and then determines that the 2nd to (n+1)th bytes of the access control list entry are the user identifier. Next, the operating system kernel reads the (n+2)th byte, i.e., field 2, to determine the length of the application identifier as m, and then determines that the (n+3)th to (m+n+2)th bytes of the access control list entry are the application identifier. Finally, the operating system reads the (m+n+3)th byte to determine the permission identifier.
[0100] exist Figure 4B As shown in the access control list entries, the operating system kernel can determine the length of the access control list entry based on field 1 and field 2, and then allocate storage resources of the same length to it. This allows for the storage of complete access control list information without incurring additional storage resource allocation overhead.
[0101] Because the length of the modified access control list entry is different from the length of the control list entry configured in the setxattr() method of the system call, the first hook function also needs to request new storage resources to store the control list entry.
[0102] S304: Modify the access control list of the first file according to the first parameter, and after successful modification, create a hard link to the first file in the directory corresponding to the application and / or user indicated by the first parameter.
[0103] After the operating system kernel modifies the access control list of the first file, the first file is invisible to other applications and / or users because it resides in the virtual directory of its owner. Therefore, the operating system kernel also needs to create hard links to the first file in locations visible to other applications and / or users, allowing them to access the first file after being configured with appropriate access permissions.
[0104] Optionally, in some embodiments of this application, the modification operation of the access control list and the operation of creating a hard link for the first file can be performed in a single system call. For example, if the modification operation of the access control list can be performed in a single system call in step S301, then the operation of creating a hard link for the first file can also be performed in that system call.
[0105] Optionally, in some embodiments of this application, the modification operation of the access control list and the operation of creating a hard link for the first file can be performed in different system calls. For example, if the modification operation of the access control list is located in the first hook function of the setxattr() method, then a second hook function needs to be inserted in another system call, and the operation of creating a hard link for the first file needs to be performed in the second hook function.
[0106] Regardless of whether the first hook function and the second hook function are in the same system call, the first hook function needs to pass a second parameter to the second hook function, where the second parameter is used to indicate whether the second hook function should perform the operation of establishing a hard link.
[0107] The following describes the method for passing the second parameter by way of example, with reference to steps S3041 and S3042.
[0108] S3041: Optional, the first hook function modifies the access control list of the first file according to the first parameter, and saves the second parameter in the access control list.
[0109] The first hook function modifies the access control list of the first file based on the first parameter, where the modified access control list entries are as follows: Figure 4A , Figure 4B As shown. The modified access control list includes, for example: Figure 4A , Figure 4B This refers to one or more modified access control list entries. In addition, a second parameter, such as..., needs to be stored in the access control list. Figure 5 As shown.
[0110] Considering that the first hook function is inserted into the system call's `setxattr()` method, which writes the access control list entries to the storage medium, and since the first hook function modifies the access control list, it can request storage resources to store the modified access control list. This allows the first hook function to request larger storage resources, enabling it to store the second parameter after storing the access control list.
[0111] Figure 5 An exemplary schematic diagram of an access control list storing a second parameter provided for an embodiment of this application.
[0112] like Figure 5 As shown, the first hook function can be used to determine the size occupied by an access control list entry. For example, if the size occupied by an access control list entry is size1, then the first hook function can request a storage resource of size2. Here, size2 is greater than size1. The storage resource requested in the first hook function is used to store the access control list entry, and the remaining storage resource is used to store the second parameter.
[0113] like Figure 5 As shown, an access control list includes one or more access control list entries, for example... Figure 5 Access control list entries 1 and 2, field 3, and pointer.
[0114] Field 3 indicates whether to create or delete a hard link. For example, field 3 can take the values 0, 1, and 2. 0 indicates no modification, 1 indicates a hard link needs to be created, and 2 indicates a hard link needs to be deleted. The operating system kernel can determine the application and / or user that needs to create a hard link based on the access control list entry pointed to by the access control list pointer.
[0115] The pointer size can vary depending on the bitness of the operating system; a 32-bit operating system can use 4 bytes, while a 64-bit operating system can use 8 bytes.
[0116] For example, in Figure 5 In the code, the pointer points to access control list entry 2. Access control list entry 2 can be "com.huawei.wallet::rw", and field 3 has a value of 1. Therefore, it needs to... Create a hard link to file 1 in the corresponding virtual directory.
[0117] It's worth noting that in the `setxattr()` system call, the content written to the storage resource is controlled by two parameters: the `value` parameter and the `size` parameter. The `size` parameter indicates the size of the storage medium being written.
[0118] Optionally, in some embodiments of this application, the size indicated is the size of the access control list entry. The data stored in memory allocated by the first hook function includes: a pointer, field 3, and one or more access control list entries.
[0119] S3042: Optional, the second hook function determines the application and / or user indicated by the first parameter based on the second parameter, and creates or deletes a hard link to the first file in the virtual directory of the application and / or user indicated by the first parameter.
[0120] After the first hook function in the VFS layer modifies the access control list of the first file, it will continue to call the corresponding interface of the real file system below the VFS layer to perform the actual access control list modification operation. After the access control list modification operation is completed in the real file system below, the second hook function determines whether to create or delete a hard link to the first file in the virtual directory of the application and / or user indicated by the first parameter.
[0121] The second hook function can obtain during execution. Figure 5 The access control list field 3 shown and the access control list entry pointed to by the access control list pointer are used to determine whether a hard link to the first file is created in the virtual directory of the application and / or user indicated by the first parameter.
[0122] Field 3 can take the values 0, 1, or 2. 0 indicates no modification, 1 indicates a hard link needs to be created, and 2 indicates a hard link needs to be deleted. The application and / or user indicated by the first parameter can be determined based on the access control list entry.
[0123] S305: Optional, user-level applications and / or users query access permissions for the first file via a system call, and the operating system returns a third parameter.
[0124] Optionally, user-level applications and / or users can obtain access permissions to the first file through system calls such as the getxattr() method, i.e., obtain the third parameter of the first file. The third parameter includes an access control list, meaning it contains one or more access control list entries.
[0125] The input parameters for the `getxattr()` method are `pathname`, `name`, `value`, and `size`. If the access permissions for the first file are configured using the `getxattr()` method in step S301, and the value of `name` is "user.sechmdfs", the `getxattr()` method will return access control list entries, such as "app1:acc1:rw;app2:acc2:rx;", where ";" is the separator. "app1:acc1:rw;app2:acc2:rx;" indicates that file 1 grants read and write permissions to `app1` (application 1) under `acc1` (user 1); and that file 1 grants read and execute permissions to `app2` (application 2) under `acc2` (user 2).
[0126] Optionally, in some embodiments of this application, the getxattr() method can be refactored so that when the value of name is “user.sechmdfs”, the getxattr() method will return an access control list entry.
[0127] Optionally, in some embodiments of this application, a third hook function can be inserted into the system call getxattr() method. The third hook function is triggered when the value of name is "user.sechmdfs", or when the application and / or user in the application layer uses the system call getxattr() method, and then the contents of the third hook function are executed to read the access control list entry.
[0128] Figure 6 This is an exemplary schematic diagram illustrating the reading of access permissions from an access control list, as provided in an embodiment of this application.
[0129] like Figure 6 As shown, methods for reading access permissions from an access control list include:
[0130] S601: The third hook function is triggered when an application at the application layer and / or a user uses the system call getxattr() method.
[0131] S602: Determine if name equals "user.sechmdfs"
[0132] Determine if name is equal to "user.sechmdfs". If yes, proceed to step S604; otherwise, proceed to step S603.
[0133] S603: End hook function
[0134] S604: Read access control list entries and return access permissions.
[0135] Since name equals "user.sechmdfs" in step S602, the operating system reads the access control list in the storage medium and then returns one or more access control list entries.
[0136] Optionally, in some embodiments of this application, one or more access control list entries in the access control list may be converted into a readable format and then the readable access permissions may be returned.
[0137] The file access permission configuration method provided in this application can be applied not only to a single electronic device, but also to a distributed scenario.
[0138] In a distributed scenario, the file access control list is also synchronized, such as... Figure 7A and Figure 7B As shown.
[0139] Figure 7A This is an exemplary schematic diagram of a synchronization access control list provided in an embodiment of this application.
[0140] S701: Modify the access permissions of file 1 so that application 2 can read file 1.
[0141] The owner of file 1 on electronic device 1 can modify the access permissions of file 1. The method for modifying the access permissions of file 1 can be found in [reference needed]. Figure 3 The contents shown will not be repeated here. Among them, file 1 can be located on electronic device 2.
[0142] In this case, modifying the access permissions of file 1 to allow application 2 to read file 1, the value of the setxattr() method can be "app2::rw".
[0143] S702: Access Control List for Synchronization File 1
[0144] After receiving the access control list of file 1 from electronic device 1, electronic device 2 can update the access control list of file 1. After updating the access control list of file 1, application 2 on the electronic device can read file 1.
[0145] Alternatively, in some embodiments of this application, the electronic device 2 receives the operation to modify the access control list and then performs the modification of the access control list, rather than directly receiving the modified access control list.
[0146] Different users can log in to electronic device 1 and electronic device 2, or the same user can log in.
[0147] Figure 7B Another exemplary schematic diagram of the synchronization access control list provided in the embodiments of this application.
[0148] like Figure 7B As shown, in a distributed scenario, electronic device 1 and electronic device 2 establish a telecommunications connection, such as a Bluetooth connection or a Wi-Fi connection. Both electronic device 1 and electronic device 2 run application 1 and application 2, respectively. The data of application 1 and application 2 is stored in their respective virtual directories, and the data of application 1 and application 2 is not visible to each other.
[0149] Before authorization, the file view of application 2 on electronic device 2 includes: the root directory includes directory 1 and directory 2, and directory 1 under the root directory includes local directories and remote directories. The file view of application 2 on electronic device 1 is the same as the file view of application 2 on electronic device 2.
[0150] Directory 1 is a directory provided by the distributed file system; directory 2 is a directory provided by the local file system.
[0151] After application 1 on electronic device 1 authorizes application 2 to file 1, the file view of application 2 on different electronic devices changes, as shown in the following figure. Figure 7B As shown. Among them, file 1 can be located on electronic device 2.
[0152] After application 1 on electronic device 1 grants read and write permissions to application 2 for file 1, electronic device 2 creates a hard link to file 1 in the virtual directory of application 2 on electronic device 2. In this case, the file view of application 2 on electronic device 2 will change.
[0153] After application 1 on electronic device 1 grants read and write permissions to application 2 for file 1, the file view of application 2 on electronic device 2 includes: file 1 in the local directory under directory 1 in the root directory, and file 1 in directory 2.
[0154] The file view of application 2 on electronic device 1 includes: file 1 in a remote directory under the root directory.
[0155] By comparing the file views of application 2 on electronic device 2 before and after authorization, it can be found that after authorization, the operating system on electronic device 2 will create a hard link to file 1 in the virtual directory of application 2 on electronic device 2, and file 1 will appear in the file view of application 2 on electronic device 2.
[0156] Since a telecommunications connection is established between electronic device 1 and electronic device 2, when a hard link to file 1 is stored in the virtual directory of application 2 on electronic device 2, file 1 will also appear in the remote directory under directory 1 of electronic device 1.
[0157] Optionally, in some embodiments of this application, the operation of application 1 on electronic device 1 granting read and write permissions of file 1 to application 2 may be by sending the operation of modifying the access control list of file 1 to electronic device 2; alternatively, in some embodiments of this application, the operation of application 1 on electronic device 1 granting read and write permissions of file 1 to application 2 may be by electronic device 1 synchronizing the access control list of file 1 to electronic device 2 after modifying the access control list of file 1, which is not limited here.
[0158] Correspondingly, after application 1 on electronic device 1 authorizes application 2, and then application 1 on electronic device 1 revokes permission for application 2, the hard link of file 1 in the virtual directory corresponding to application 2 will be deleted.
[0159] Understandably, when a file is located in a virtual directory, changes in file access permissions will also be accompanied by the deletion and creation of hard links for that file.
[0160] Finally, the hardware and software architectures of the electronic devices provided in the embodiments of this application are introduced.
[0161] Figure 8 This is an exemplary schematic diagram of the electronic device hardware architecture provided in the embodiments of this application.
[0162] The electronic device can be a mobile phone, tablet computer, desktop computer, laptop computer, handheld computer, notebook computer, ultra-mobile personal computer (UMPC), netbook, as well as cellular phone, personal digital assistant (PDA), augmented reality (AR) device, virtual reality (VR) device, artificial intelligence (AI) device, wearable device, in-vehicle device, smart home device and / or smart city device. The embodiments of this application do not impose any special restrictions on the specific type of the electronic device.
[0163] The electronic device may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0164] It is understood that the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device. In other embodiments of this application, the electronic device may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0165] Processor 110 may include one or more processing units, such as application processors (APs), modem processors, graphics processing units (GPUs), image signal processors (ISPs), controllers, video codecs, digital signal processors (DSPs), baseband processors, and / or neural network processing units (NPUs). These different processing units may be independent devices or integrated into one or more processors.
[0166] The processor 110 may also include a memory for storing instructions and data.
[0167] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0168] It is understood that the interface connection relationships between the modules illustrated in the embodiments of the present invention are merely illustrative and do not constitute a limitation on the structure of the electronic device. In other embodiments of this application, the electronic device may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0169] The charging management module 140 is used to receive charging input from the charger. The power management module 141 is used to connect the battery 142, and the charging management module 140 is connected to the processor 110.
[0170] The wireless communication function of the electronic device can be implemented through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor, and baseband processor. Mobile communication module 150 can provide solutions for wireless communication applications in electronic devices, including 2G / 3G / 4G / 5G. The modem processor can include a modulator and a demodulator.
[0171] The wireless communication module 160 can provide solutions for wireless communication applications in electronic devices, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies.
[0172] Electronic devices utilize a GPU, a display screen 194, and an application processor to achieve display functionality. The GPU is a microprocessor for image processing, connecting the display screen 194 and the application processor. The display screen 194 is used to display images, videos, etc.
[0173] The ISP is used to process data fed back by the camera 193. The camera 193 is used to capture still images or videos. In some embodiments, the electronic device may include one or N cameras 193, where N is a positive integer greater than 1.
[0174] A digital signal processor (DSP) is used to process digital signals, including digital image signals and other digital signals. A video codec is used to compress or decompress digital video. An NPU (Neural Processing Unit) is a neural network (NN) computing processor that, by borrowing the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, rapidly processes input information and can continuously learn. NPUs enable intelligent cognitive applications in electronic devices, such as image recognition, facial recognition, speech recognition, and text understanding.
[0175] Internal memory 121 may include one or more random access memory (RAM) and one or more non-volatile memory (NVM).
[0176] Random access memory (RAM) can include static random-access memory (SRAM), dynamic random-access memory (DRAM), synchronous dynamic random-access memory (SDRAM), and double data rate synchronous dynamic random-access memory (DDR SDRAM, such as fifth-generation DDR SDRAM, generally referred to as DDR5 SDRAM). Non-volatile memory can include disk storage devices and flash memory. Flash memory can be classified according to its operating principle, including NOR FLASH, NAND FLASH, and 3D NAND FLASH; according to the level of its storage cells, including single-level cell (SLC), multi-level cell (MLC), triple-level cell (TLC), and quad-level cell (QLC); and according to its storage specification, including universal flash storage (UFS) and embedded multimedia card (eMMC). Random access memory (RAM) can be directly read and written by the processor 110. It can be used to store executable programs (such as machine instructions) of the operating system or other running programs, as well as user and application data. Non-volatile memory can also store executable programs and user and application data, and can be pre-loaded into RAM for direct read and write by the processor 110.
[0177] The external memory interface 120 can be used to connect to external non-volatile memory, thereby expanding the storage capacity of the electronic device. The electronic device can implement audio functions, such as music playback and recording, through an audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.
[0178] Audio module 170 is used to convert digital audio information into analog audio signal output, and also to convert analog audio input into digital audio signal. Speaker 170A, also called a "loudspeaker," is used to convert audio electrical signals into sound signals. Receiver 170B, also called a "handpiece," is used to convert audio electrical signals into sound signals. Microphone 170C, also called a "microphone" or "voice transducer," is used to convert sound signals into electrical signals. Headphone jack 170D is used to connect wired headphones.
[0179] The pressure sensor 180A senses pressure signals and converts them into electrical signals. The gyroscope sensor 180B determines the motion posture of the electronic device. The barometric pressure sensor 180C measures air pressure. The magnetic sensor 180D includes a Hall effect sensor. The accelerometer sensor 180E detects the magnitude of acceleration in various directions (typically three axes) of the electronic device. The distance sensor 180F measures distance. The proximity sensor 180G may include, for example, a light-emitting diode (LED) and a photodetector, such as a photodiode. The LED may be an infrared LED. The ambient light sensor 180L senses ambient light intensity. The fingerprint sensor 180H collects fingerprints. The temperature sensor 180J detects temperature. The touch sensor 180K, also known as a "touch device," is used for temperature detection. The bone conduction sensor 180M acquires vibration signals.
[0180] Button 190 includes the power button, volume buttons, etc.
[0181] Motor 191 can generate vibration alerts. Indicator 192 can be an indicator light, used to indicate charging status, battery level changes, messages, missed calls, notifications, etc. SIM card interface 195 is used to connect a SIM card.
[0182] Figure 9A , Figure 9B , Figure 9C , Figure 9D This is an exemplary schematic diagram of the electronic device software architecture provided in the embodiments of this application.
[0183] The software system of an electronic device can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application uses a Linux system as an example to illustrate the software structure of an electronic device.
[0184] like Figure 9A and Figure 9B As shown, a Linux system can include a user layer and a kernel layer. The user layer can also be called user mode or user space, and the kernel layer can also be called kernel mode or kernel space.
[0185] Linux systems can also include system calls, which are the smallest functional unit of the operating system. Linux systems can also include a shell, which can be called a command interpreter and provides a graphical interface for the user.
[0186] The user layer includes applications such as Application 1 and Application 2. These user-layer applications can use system calls to pass file access permission configuration commands and permission query commands to the kernel-level file system.
[0187] The file system can include a virtual file system and a real file system. Upon receiving an access permission configuration command, the virtual file system modifies the access control list (ACL) in the file's extended attributes using the access control list modification module. This module then passes the specific operations to the real file system, which performs the corresponding actions.
[0188] Upon receiving an access permission query command, the virtual file system uses the access control list modification module to read the access control list from the file's extended attributes. This module then passes the specific operations to the real file system, which executes them. After determining the file's access permissions, a system call is used to return the information to the user-level application.
[0189] After modifying the access control list of a file, optionally, if the file is located in a virtual directory, the application and / or user information is passed to the hard link modification module, which then creates or deletes hard links to the file. Similarly, the hard link modification module passes the specific operations to be performed to the real file system, which then executes the operations.
[0190] The access control list modification module can be used to execute steps S301, S302, S303, S305, and S3041; the hard link modification module can be used to execute step S3042.
[0191] The access control list modification module can be located in the first hook function, or in the method or function pointed to by the first hook function; or, the access control list modification module can be located in the third hook function, or in the method or function pointed to by the third hook function.
[0192] The hard link modification module can be located in the second hook function, or in the method or function pointed to by the second hook function.
[0193] like Figure 9C and Figure 9DAs shown, Linux systems can also include a security framework (LSM, Linux Security Module). The LSM includes an access control list modification module and a hard link modification module. The functions of the access control list modification module and the hard link modification module can be found in the above text. Figure 9A , Figure 9B The description in the text will not be repeated here.
[0194] The access control list modification module can be triggered by the first hook function, which can be in the extended attribute writing function in the virtual file system, such as the setxattr() function mentioned above.
[0195] The access control list modification module can be triggered by a third hook function, which can be in the extended attribute reading function in the virtual file system, such as the getxattr() function mentioned above.
[0196] The hard link modification module can be triggered by the second hook function, which can be in the extended attribute write security check function in the virtual file system.
[0197] As used in the above embodiments, depending on the context, the term "when..." can be interpreted as meaning "if...", "after...", "in response to determining...", or "in response to detecting...". Similarly, depending on the context, the phrase "when determining..." or "if (the stated condition or event) is interpreted as meaning "if determining...", "in response to determining...", "when (the stated condition or event) is detected", or "in response to detecting (the stated condition or event)".
[0198] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. This computer program product includes one or more computer instructions. When these computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.
[0199] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A method for configuring file access permissions, characterized in that, include: The first owner passes a first parameter to the operating system through a first system call. The first parameter is used to configure the access permissions of the first file. The first parameter includes a first identifier and a first permission. The first permission includes at least one of read permission, write permission, execute permission, and read access control list permission. The first identifier includes an application identifier and a user identifier. If the operating system determines that the declaration value of the first system call is a predefined value, the operating system receives the first parameter. After receiving the first parameter, if the operating system determines that the first file is not in the virtual directory corresponding to the first owner, the operating system modifies the access control list of the first file according to the first parameter. The access control list of the first file is used to determine the access permissions of the first file. If the operating system determines that the first file is in the virtual directory corresponding to the first owner, and there is no hard link to the first file in the virtual directory indicated by the first identifier, then the operating system modifies the access control list of the first file according to the first parameter, and then creates a hard link to the first file in the virtual directory indicated by the first identifier.
2. The method according to claim 1, characterized in that, The method further includes: The access permissions of the first file are queried via a second system call; During the process of querying the access permissions of the first file through the second system call, after the operating system determines that the declaration value of the second system call is a conventional value, the operating system determines a third parameter, which includes one or more access control list entries in the access control list of the first file. The operating system returns the third parameter.
3. The method according to claim 2, characterized in that, Before the operating system returns the third parameter, the following is also included: The operating system converts the one or more access control list entries into a readable format.
4. The method according to any one of claims 1-3, characterized in that, The access control list entries of the first file have a fixed length, or the access control list entries of the first file have a variable length.
5. The method according to claim 4, characterized in that, The length of the access control list entries in the access control list of the first file is variable. The access control list entries of the first file's access control list include a first field and a second field; The first field is used to indicate the length of the application identifier, and the second field is used to indicate the length of the user identifier.
6. An electronic device, characterized in that, The electronic device includes: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code including computer instructions, and the one or more processors call the computer instructions to cause the electronic device to perform the method as described in any one of claims 1 to 5.
7. A chip system applied to an electronic device, the chip system comprising one or more processors, the processors being configured to invoke computer instructions to cause the electronic device to perform the method as described in any one of claims 1 to 6.
8. A computer-readable storage medium comprising instructions, characterized in that, When the instructions are executed on an electronic device, the electronic device causes the electronic device to perform the method as described in any one of claims 1 to 6.
9. A computer program product comprising computer instructions that, when executed by one or more processors, implement the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
ACL (access control list) authority control method and device
CN107688753A
