···177177#define SMACK_CIPSO_MAXCATNUM 184 /* 23 * 8 */178178179179/*180180- * Flag for transmute access180180+ * Flags for untraditional access modes.181181+ * It shouldn't be necessary to avoid conflicts with definitions182182+ * in fs.h, but do so anyway.181183 */182182-#define MAY_TRANSMUTE 64184184+#define MAY_TRANSMUTE 0x00001000 /* Controls directory labeling */185185+#define MAY_LOCK 0x00002000 /* Locks should be writes, but ... */186186+183187/*184188 * Just to make the common cases easier to deal with185189 */···192188#define MAY_NOT 0193189194190/*195195- * Number of access types used by Smack (rwxat)191191+ * Number of access types used by Smack (rwxatl)196192 */197197-#define SMK_NUM_ACCESS_TYPE 5193193+#define SMK_NUM_ACCESS_TYPE 6198194199195/* SMACK data */200196struct smack_audit_data {
+10
security/smack/smack_access.c
···8484 *8585 * Do the object check first because that is more8686 * likely to differ.8787+ *8888+ * Allowing write access implies allowing locking.8789 */8890int smk_access_entry(char *subject_label, char *object_label,8991 struct list_head *rule_list)···10199 }102100 }103101102102+ /*103103+ * MAY_WRITE implies MAY_LOCK.104104+ */105105+ if ((may & MAY_WRITE) == MAY_WRITE)106106+ may |= MAY_LOCK;104107 return may;105108}106109···252245static inline void smack_str_from_perm(char *string, int access)253246{254247 int i = 0;248248+255249 if (access & MAY_READ)256250 string[i++] = 'r';257251 if (access & MAY_WRITE)···263255 string[i++] = 'a';264256 if (access & MAY_TRANSMUTE)265257 string[i++] = 't';258258+ if (access & MAY_LOCK)259259+ string[i++] = 'l';266260 string[i] = '\0';267261}268262/**
+8-3
security/smack/smack_lsm.c
···185185 smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_TASK);186186 smk_ad_setfield_u_tsk(&ad, ctp);187187188188- rc = smk_curacc(skp->smk_known, MAY_READWRITE, &ad);188188+ rc = smk_curacc(skp->smk_known, mode, &ad);189189 return rc;190190}191191···11461146 * @file: the object11471147 * @cmd: unused11481148 *11491149- * Returns 0 if current has write access, error code otherwise11491149+ * Returns 0 if current has lock access, error code otherwise11501150 */11511151static int smack_file_lock(struct file *file, unsigned int cmd)11521152{···1154115411551155 smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);11561156 smk_ad_setfield_u_fs_path(&ad, file->f_path);11571157- return smk_curacc(file->f_security, MAY_WRITE, &ad);11571157+ return smk_curacc(file->f_security, MAY_LOCK, &ad);11581158}1159115911601160/**···1178117811791179 switch (cmd) {11801180 case F_GETLK:11811181+ break;11811182 case F_SETLK:11821183 case F_SETLKW:11841184+ smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);11851185+ smk_ad_setfield_u_fs_path(&ad, file->f_path);11861186+ rc = smk_curacc(file->f_security, MAY_LOCK, &ad);11871187+ break;11831188 case F_SETOWN:11841189 case F_SETSIG:11851190 smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
+8-2
security/smack/smackfs.c
···139139 * SMK_LOADLEN: Smack rule length140140 */141141#define SMK_OACCESS "rwxa"142142-#define SMK_ACCESS "rwxat"142142+#define SMK_ACCESS "rwxatl"143143#define SMK_OACCESSLEN (sizeof(SMK_OACCESS) - 1)144144#define SMK_ACCESSLEN (sizeof(SMK_ACCESS) - 1)145145#define SMK_OLOADLEN (SMK_LABELLEN + SMK_LABELLEN + SMK_OACCESSLEN)···281281 case 't':282282 case 'T':283283 perm |= MAY_TRANSMUTE;284284+ break;285285+ case 'l':286286+ case 'L':287287+ perm |= MAY_LOCK;284288 break;285289 default:286290 return perm;···456452 /*457453 * Minor hack for backward compatibility458454 */459459- if (count != SMK_OLOADLEN && count != SMK_LOADLEN)455455+ if (count < SMK_OLOADLEN || count > SMK_LOADLEN)460456 return -EINVAL;461457 } else {462458 if (count >= PAGE_SIZE) {···596592 seq_putc(s, 'a');597593 if (srp->smk_access & MAY_TRANSMUTE)598594 seq_putc(s, 't');595595+ if (srp->smk_access & MAY_LOCK)596596+ seq_putc(s, 'l');599597600598 seq_putc(s, '\n');601599}